Commit 1b51f242 authored by James Bottomley's avatar James Bottomley

gdth driver update to 3.04

From: 	Leubner, Achim <Achim_Leubner@adaptec.com>

- Support for drives > 2 TB implemented
- 64-bit DMA support depending on the controller firmware version implemented
- Some important bug fixes made
parent b3701e0e
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* <achim_leubner@adaptec.com> * <achim_leubner@adaptec.com>
* *
* $Id: gdth.h,v 1.50 2003/09/17 08:29:58 achim Exp $ * $Id: gdth.h,v 1.57 2004/03/31 11:52:09 achim Exp $
*/ */
#include <linux/version.h> #include <linux/version.h>
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
/* defines, macros */ /* defines, macros */
/* driver version */ /* driver version */
#define GDTH_VERSION_STR "2.08" #define GDTH_VERSION_STR "3.04"
#define GDTH_VERSION 2 #define GDTH_VERSION 3
#define GDTH_SUBVERSION 8 #define GDTH_SUBVERSION 4
/* protocol version */ /* protocol version */
#define PROTOCOL_VERSION 1 #define PROTOCOL_VERSION 1
...@@ -134,6 +134,11 @@ ...@@ -134,6 +134,11 @@
#define PCI_DEVICE_ID_VORTEX_GDTNEWRX 0x300 #define PCI_DEVICE_ID_VORTEX_GDTNEWRX 0x300
#endif #endif
#ifndef PCI_DEVICE_ID_VORTEX_GDTNEWRX2
/* new(2) GDT Rx Controller */
#define PCI_DEVICE_ID_VORTEX_GDTNEWRX2 0x301
#endif
#ifndef PCI_DEVICE_ID_INTEL_SRC #ifndef PCI_DEVICE_ID_INTEL_SRC
/* Intel Storage RAID Controller */ /* Intel Storage RAID Controller */
#define PCI_DEVICE_ID_INTEL_SRC 0x600 #define PCI_DEVICE_ID_INTEL_SRC 0x600
...@@ -146,8 +151,7 @@ ...@@ -146,8 +151,7 @@
/* limits */ /* limits */
#define GDTH_SCRATCH PAGE_SIZE /* 4KB scratch buffer */ #define GDTH_SCRATCH PAGE_SIZE /* 4KB scratch buffer */
#define GDTH_SCRATCH_ORD 0 /* order 0 means 1 page */ #define GDTH_MAXCMDS 120
#define GDTH_MAXCMDS 124
#define GDTH_MAXC_P_L 16 /* max. cmds per lun */ #define GDTH_MAXC_P_L 16 /* max. cmds per lun */
#define GDTH_MAX_RAW 2 /* max. cmds per raw device */ #define GDTH_MAX_RAW 2 /* max. cmds per raw device */
#define MAXOFFSETS 128 #define MAXOFFSETS 128
...@@ -221,6 +225,8 @@ ...@@ -221,6 +225,8 @@
#define GDT_CLUST_RESET 24 /* releases the cluster drives*/ #define GDT_CLUST_RESET 24 /* releases the cluster drives*/
#define GDT_FREEZE_IO 25 /* freezes all IOs */ #define GDT_FREEZE_IO 25 /* freezes all IOs */
#define GDT_UNFREEZE_IO 26 /* unfreezes all IOs */ #define GDT_UNFREEZE_IO 26 /* unfreezes all IOs */
#define GDT_X_INIT_HOST 29 /* ext. init: 64 bit support */
#define GDT_X_INFO 30 /* ext. info for drives>2TB */
/* raw service commands */ /* raw service commands */
#define GDT_RESERVE 14 /* reserve dev. to raw serv. */ #define GDT_RESERVE 14 /* reserve dev. to raw serv. */
...@@ -230,9 +236,11 @@ ...@@ -230,9 +236,11 @@
#define GDT_RESET_BUS 18 /* reset bus */ #define GDT_RESET_BUS 18 /* reset bus */
#define GDT_SCAN_START 19 /* start device scan */ #define GDT_SCAN_START 19 /* start device scan */
#define GDT_SCAN_END 20 /* stop device scan */ #define GDT_SCAN_END 20 /* stop device scan */
#define GDT_X_INIT_RAW 21 /* ext. init: 64 bit support */
/* screen service commands */ /* screen service commands */
#define GDT_REALTIME 3 /* realtime clock to screens. */ #define GDT_REALTIME 3 /* realtime clock to screens. */
#define GDT_X_INIT_SCR 4 /* ext. init: 64 bit support */
/* IOCTL command defines */ /* IOCTL command defines */
#define SCSI_DR_INFO 0x00 /* SCSI drive info */ #define SCSI_DR_INFO 0x00 /* SCSI drive info */
...@@ -254,6 +262,8 @@ ...@@ -254,6 +262,8 @@
#define CACHE_DRV_INFO 0x07 /* cache drive info */ #define CACHE_DRV_INFO 0x07 /* cache drive info */
#define BOARD_FEATURES 0x15 /* controller features */ #define BOARD_FEATURES 0x15 /* controller features */
#define BOARD_INFO 0x28 /* controller info */ #define BOARD_INFO 0x28 /* controller info */
#define SET_PERF_MODES 0x82 /* set mode (coalescing,..) */
#define GET_PERF_MODES 0x83 /* get mode */
#define CACHE_READ_OEM_STRING_RECORD 0x84 /* read OEM string record */ #define CACHE_READ_OEM_STRING_RECORD 0x84 /* read OEM string record */
#define HOST_GET 0x10001L /* get host drive list */ #define HOST_GET 0x10001L /* get host drive list */
#define IO_CHANNEL 0x00020000L /* default IO channel */ #define IO_CHANNEL 0x00020000L /* default IO channel */
...@@ -266,6 +276,7 @@ ...@@ -266,6 +276,7 @@
#define S_CACHE_UNKNOWN 12 /* cache serv.: drive unknown */ #define S_CACHE_UNKNOWN 12 /* cache serv.: drive unknown */
#define S_RAW_SCSI 12 /* raw serv.: target error */ #define S_RAW_SCSI 12 /* raw serv.: target error */
#define S_RAW_ILL 0xff /* raw serv.: illegal */ #define S_RAW_ILL 0xff /* raw serv.: illegal */
#define S_NOFUNC -2 /* unknown function */
#define S_CACHE_RESERV -24 /* cache: reserv. conflict */ #define S_CACHE_RESERV -24 /* cache: reserv. conflict */
/* timeout values */ /* timeout values */
...@@ -307,7 +318,12 @@ ...@@ -307,7 +318,12 @@
#define LOCALBOARD 0 /* board node always 0 */ #define LOCALBOARD 0 /* board node always 0 */
#define ASYNCINDEX 0 /* cmd index async. event */ #define ASYNCINDEX 0 /* cmd index async. event */
#define SPEZINDEX 1 /* cmd index unknown service */ #define SPEZINDEX 1 /* cmd index unknown service */
#define COALINDEX (GDTH_MAXCMDS + 2)
/* features */
#define SCATTER_GATHER 1 /* s/g feature */
#define GDT_WR_THROUGH 0x100 /* WRITE_THROUGH supported */ #define GDT_WR_THROUGH 0x100 /* WRITE_THROUGH supported */
#define GDT_64BIT 0x200 /* 64bit / drv>2TB support */
#include "gdth_ioctl.h" #include "gdth_ioctl.h"
...@@ -322,7 +338,40 @@ typedef struct { ...@@ -322,7 +338,40 @@ typedef struct {
char msg_text[MSGLEN+2]; /* the message text */ char msg_text[MSGLEN+2]; /* the message text */
} PACKED gdth_msg_str; } PACKED gdth_msg_str;
/* IOCTL data structures */ /* IOCTL data structures */
/* Status coalescing buffer for returning multiple requests per interrupt */
typedef struct {
ulong32 status;
ulong32 ext_status;
ulong32 info0;
ulong32 info1;
} PACKED gdth_coal_status;
/* performance mode data structure */
typedef struct {
ulong32 version; /* The version of this IOCTL structure. */
ulong32 st_mode; /* 0=dis., 1=st_buf_addr1 valid, 2=both */
ulong32 st_buff_addr1; /* physical address of status buffer 1 */
ulong32 st_buff_u_addr1; /* reserved for 64 bit addressing */
ulong32 st_buff_indx1; /* reserved command idx. for this buffer */
ulong32 st_buff_addr2; /* physical address of status buffer 1 */
ulong32 st_buff_u_addr2; /* reserved for 64 bit addressing */
ulong32 st_buff_indx2; /* reserved command idx. for this buffer */
ulong32 st_buff_size; /* size of each buffer in bytes */
ulong32 cmd_mode; /* 0 = mode disabled, 1 = cmd_buff_addr1 */
ulong32 cmd_buff_addr1; /* physical address of cmd buffer 1 */
ulong32 cmd_buff_u_addr1; /* reserved for 64 bit addressing */
ulong32 cmd_buff_indx1; /* cmd buf addr1 unique identifier */
ulong32 cmd_buff_addr2; /* physical address of cmd buffer 1 */
ulong32 cmd_buff_u_addr2; /* reserved for 64 bit addressing */
ulong32 cmd_buff_indx2; /* cmd buf addr1 unique identifier */
ulong32 cmd_buff_size; /* size of each cmd bufer in bytes */
ulong32 reserved1;
ulong32 reserved2;
} PACKED gdth_perf_modes;
/* SCSI drive info */ /* SCSI drive info */
typedef struct { typedef struct {
unchar vendor[8]; /* vendor string */ unchar vendor[8]; /* vendor string */
...@@ -795,9 +844,7 @@ typedef struct { ...@@ -795,9 +844,7 @@ typedef struct {
/* PCI resources */ /* PCI resources */
typedef struct { typedef struct {
#if LINUX_VERSION_CODE >= 0x02015C
struct pci_dev *pdev; struct pci_dev *pdev;
#endif
ushort vendor_id; /* vendor (ICP, Intel, ..) */ ushort vendor_id; /* vendor (ICP, Intel, ..) */
ushort device_id; /* device ID (0,..,9) */ ushort device_id; /* device ID (0,..,9) */
ushort subdevice_id; /* sub device ID */ ushort subdevice_id; /* sub device ID */
...@@ -814,20 +861,28 @@ typedef struct { ...@@ -814,20 +861,28 @@ typedef struct {
typedef struct { typedef struct {
ushort oem_id; /* OEM */ ushort oem_id; /* OEM */
ushort type; /* controller class */ ushort type; /* controller class */
ushort raw_feat; /* feat. raw service (s/g,..) */
ulong32 stype; /* subtype (PCI: device ID) */ ulong32 stype; /* subtype (PCI: device ID) */
ushort subdevice_id; /* sub device ID (PCI) */ ushort subdevice_id; /* sub device ID (PCI) */
ushort fw_vers; /* firmware version */ ushort fw_vers; /* firmware version */
ushort cache_feat; /* feat. cache serv. (s/g,..) */ ushort cache_feat; /* feat. cache serv. (s/g,..)*/
ushort raw_feat; /* feat. raw service (s/g,..)*/
ushort screen_feat; /* feat. raw service (s/g,..)*/
ushort bmic; /* BMIC address (EISA) */ ushort bmic; /* BMIC address (EISA) */
void *brd; /* DPRAM address */ void *brd; /* DPRAM address */
ulong32 brd_phys; /* slot number/BIOS address */ ulong32 brd_phys; /* slot number/BIOS address */
gdt6c_plx_regs *plx; /* PLX regs (new PCI contr.) */ gdt6c_plx_regs *plx; /* PLX regs (new PCI contr.) */
gdth_cmd_str *pccb; /* address command structure */ gdth_cmd_str *pccb; /* address command structure */
ulong32 ccb_phys; /* phys. address */ ulong32 ccb_phys; /* phys. address */
#ifdef INT_COAL
gdth_coal_status *coal_stat; /* buffer for coalescing int.*/
ulong64 coal_stat_phys; /* phys. address */
#endif
char *pscratch; /* scratch (DMA) buffer */ char *pscratch; /* scratch (DMA) buffer */
ulong32 scratch_phys; /* phys. address */ ulong64 scratch_phys; /* phys. address */
unchar scratch_busy; /* in use? */ unchar scratch_busy; /* in use? */
unchar dma64_support; /* 64-bit DMA supported? */
gdth_msg_str *pmsg; /* message buffer */
ulong64 msg_phys; /* phys. address */
unchar scan_mode; /* current scan mode */ unchar scan_mode; /* current scan mode */
unchar irq; /* IRQ */ unchar irq; /* IRQ */
unchar drq; /* DRQ (ISA controllers) */ unchar drq; /* DRQ (ISA controllers) */
...@@ -848,11 +903,11 @@ typedef struct { ...@@ -848,11 +903,11 @@ typedef struct {
unchar heads; /* mapping */ unchar heads; /* mapping */
unchar secs; unchar secs;
ushort devtype; /* further information */ ushort devtype; /* further information */
ulong32 size; /* capacity */ ulong64 size; /* capacity */
unchar ldr_no; /* log. drive no. */ unchar ldr_no; /* log. drive no. */
unchar rw_attribs; /* r/w attributes */ unchar rw_attribs; /* r/w attributes */
unchar cluster_type; /* cluster properties */ unchar cluster_type; /* cluster properties */
unchar media_changed; /* Flag:MOUNT/UNMOUNT occurred*/ unchar media_changed; /* Flag:MOUNT/UNMOUNT occured */
ulong32 start_sec; /* start sector */ ulong32 start_sec; /* start sector */
} hdr[MAX_LDRIVES]; /* host drives */ } hdr[MAX_LDRIVES]; /* host drives */
struct { struct {
...@@ -880,13 +935,19 @@ typedef struct { ...@@ -880,13 +935,19 @@ typedef struct {
gdth_bfeat_str bfeat; /* controller features */ gdth_bfeat_str bfeat; /* controller features */
gdth_binfo_str binfo; /* controller info */ gdth_binfo_str binfo; /* controller info */
gdth_evt_data dvr; /* event structure */ gdth_evt_data dvr; /* event structure */
#if LINUX_VERSION_CODE >= 0x02015F
spinlock_t smp_lock; spinlock_t smp_lock;
#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
#if LINUX_VERSION_CODE >= 0x020400
struct pci_dev *pdev; struct pci_dev *pdev;
#endif #endif
char oem_name[8]; char oem_name[8];
#ifdef GDTH_DMA_STATISTICS
ulong dma32_cnt, dma64_cnt; /* statistics: DMA buffer */
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
Scsi_Device *sdev;
#else
Scsi_Device sdev;
#endif
} gdth_ha_str; } gdth_ha_str;
/* structure for scsi_register(), SCSI bus != 0 */ /* structure for scsi_register(), SCSI bus != 0 */
...@@ -924,6 +985,12 @@ typedef struct { ...@@ -924,6 +985,12 @@ typedef struct {
ulong32 block_length; ulong32 block_length;
} PACKED gdth_rdcap_data; } PACKED gdth_rdcap_data;
/* READ_CAPACITY (16) data format */
typedef struct {
ulong64 last_block_no;
ulong32 block_length;
} PACKED gdth_rdcap16_data;
/* REQUEST_SENSE data format */ /* REQUEST_SENSE data format */
typedef struct { typedef struct {
unchar errorcode; unchar errorcode;
...@@ -965,42 +1032,48 @@ typedef struct { ...@@ -965,42 +1032,48 @@ typedef struct {
int gdth_detect(Scsi_Host_Template *); int gdth_detect(Scsi_Host_Template *);
int gdth_release(struct Scsi_Host *); int gdth_release(struct Scsi_Host *);
int gdth_queuecommand(Scsi_Cmnd *,void (*done)(Scsi_Cmnd *)); int gdth_queuecommand(Scsi_Cmnd *,void (*done)(Scsi_Cmnd *));
int gdth_abort(Scsi_Cmnd *);
#if LINUX_VERSION_CODE >= 0x010346
int gdth_reset(Scsi_Cmnd *, unsigned int reset_flags);
#else
int gdth_reset(Scsi_Cmnd *);
#endif
const char *gdth_info(struct Scsi_Host *); const char *gdth_info(struct Scsi_Host *);
#if LINUX_VERSION_CODE >= 0x020501 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
int gdth_bios_param(struct scsi_device *,struct block_device *,sector_t,int *); int gdth_bios_param(struct scsi_device *,struct block_device *,sector_t,int *);
int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int); int gdth_proc_info(struct Scsi_Host *, char *,char **,off_t,int,int);
int gdth_eh_abort(Scsi_Cmnd *scp); #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
int gdth_eh_device_reset(Scsi_Cmnd *scp);
int gdth_eh_bus_reset(Scsi_Cmnd *scp);
int gdth_eh_host_reset(Scsi_Cmnd *scp);
#elif LINUX_VERSION_CODE >= 0x020322
int gdth_bios_param(Disk *,kdev_t,int *); int gdth_bios_param(Disk *,kdev_t,int *);
int gdth_proc_info(char *,char **,off_t,int,int,int); int gdth_proc_info(char *,char **,off_t,int,int,int);
int gdth_eh_abort(Scsi_Cmnd *scp); #else
int gdth_eh_device_reset(Scsi_Cmnd *scp);
int gdth_eh_bus_reset(Scsi_Cmnd *scp);
int gdth_eh_host_reset(Scsi_Cmnd *scp);
#elif LINUX_VERSION_CODE >= 0x02015F
int gdth_bios_param(Disk *,kdev_t,int *); int gdth_bios_param(Disk *,kdev_t,int *);
extern struct proc_dir_entry proc_scsi_gdth; extern struct proc_dir_entry proc_scsi_gdth;
int gdth_proc_info(char *,char **,off_t,int,int,int); int gdth_proc_info(char *,char **,off_t,int,int,int);
int gdth_abort(Scsi_Cmnd *);
int gdth_reset(Scsi_Cmnd *,unsigned int);
#define GDTH { proc_dir: &proc_scsi_gdth, \
proc_info: gdth_proc_info, \
name: "GDT SCSI Disk Array Controller",\
detect: gdth_detect, \
release: gdth_release, \
info: gdth_info, \
command: NULL, \
queuecommand: gdth_queuecommand, \
eh_abort_handler: gdth_eh_abort, \
eh_device_reset_handler: gdth_eh_device_reset, \
eh_bus_reset_handler: gdth_eh_bus_reset, \
eh_host_reset_handler: gdth_eh_host_reset, \
abort: gdth_abort, \
reset: gdth_reset, \
bios_param: gdth_bios_param, \
can_queue: GDTH_MAXCMDS, \
this_id: -1, \
sg_tablesize: GDTH_MAXSG, \
cmd_per_lun: GDTH_MAXC_P_L, \
present: 0, \
unchecked_isa_dma: 1, \
use_clustering: ENABLE_CLUSTERING, \
use_new_eh_code: 1 /* use new error code */ }
#endif
int gdth_eh_abort(Scsi_Cmnd *scp); int gdth_eh_abort(Scsi_Cmnd *scp);
int gdth_eh_device_reset(Scsi_Cmnd *scp); int gdth_eh_device_reset(Scsi_Cmnd *scp);
int gdth_eh_bus_reset(Scsi_Cmnd *scp); int gdth_eh_bus_reset(Scsi_Cmnd *scp);
int gdth_eh_host_reset(Scsi_Cmnd *scp); int gdth_eh_host_reset(Scsi_Cmnd *scp);
#elif LINUX_VERSION_CODE >= 0x010300
int gdth_bios_param(Disk *,kdev_t,int *);
extern struct proc_dir_entry proc_scsi_gdth;
int gdth_proc_info(char *,char **,off_t,int,int,int);
#else
int gdth_bios_param(Disk *,int,int *);
#endif
#endif
#endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define _GDTH_IOCTL_H #define _GDTH_IOCTL_H
/* gdth_ioctl.h /* gdth_ioctl.h
* $Id: gdth_ioctl.h,v 1.11 2003/02/27 14:59:03 achim Exp $ * $Id: gdth_ioctl.h,v 1.14 2004/02/19 15:43:15 achim Exp $
*/ */
/* IOCTLs */ /* IOCTLs */
...@@ -35,7 +35,9 @@ ...@@ -35,7 +35,9 @@
/* typedefs */ /* typedefs */
#ifdef __KERNEL__ #ifdef __KERNEL__
typedef u32 ulong32; typedef u32 ulong32;
typedef u64 ulong64;
#endif #endif
#define PACKED __attribute__((packed)) #define PACKED __attribute__((packed))
/* scatter/gather element */ /* scatter/gather element */
...@@ -44,6 +46,12 @@ typedef struct { ...@@ -44,6 +46,12 @@ typedef struct {
ulong32 sg_len; /* length */ ulong32 sg_len; /* length */
} PACKED gdth_sg_str; } PACKED gdth_sg_str;
/* scatter/gather element - 64bit addresses */
typedef struct {
ulong64 sg_ptr; /* address */
ulong32 sg_len; /* length */
} PACKED gdth_sg64_str;
/* command structure */ /* command structure */
typedef struct { typedef struct {
ulong32 BoardNode; /* board node (always 0) */ ulong32 BoardNode; /* board node (always 0) */
...@@ -58,18 +66,26 @@ typedef struct { ...@@ -58,18 +66,26 @@ typedef struct {
ulong32 sg_canz; /* s/g element count */ ulong32 sg_canz; /* s/g element count */
gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */
} PACKED cache; /* cache service cmd. str. */ } PACKED cache; /* cache service cmd. str. */
struct {
ushort DeviceNo; /* number of cache drive */
ulong64 BlockNo; /* block number */
ulong32 BlockCnt; /* block count */
ulong64 DestAddr; /* dest. addr. (if s/g: -1) */
ulong32 sg_canz; /* s/g element count */
gdth_sg64_str sg_lst[GDTH_MAXSG]; /* s/g list */
} PACKED cache64; /* cache service cmd. str. */
struct { struct {
ushort param_size; /* size of p_param buffer */ ushort param_size; /* size of p_param buffer */
ulong32 subfunc; /* IOCTL function */ ulong32 subfunc; /* IOCTL function */
ulong32 channel; /* device */ ulong32 channel; /* device */
ulong32 p_param; /* buffer */ ulong64 p_param; /* buffer */
} PACKED ioctl; /* IOCTL command structure */ } PACKED ioctl; /* IOCTL command structure */
struct { struct {
ushort reserved; ushort reserved;
union { union {
struct { struct {
ulong32 msg_handle; /* message handle */ ulong32 msg_handle; /* message handle */
ulong32 msg_addr; /* message buffer address */ ulong64 msg_addr; /* message buffer address */
} PACKED msg; } PACKED msg;
unchar data[12]; /* buffer for rtc data, ... */ unchar data[12]; /* buffer for rtc data, ... */
} su; } su;
...@@ -93,6 +109,24 @@ typedef struct { ...@@ -93,6 +109,24 @@ typedef struct {
ulong32 sg_ranz; /* s/g element count */ ulong32 sg_ranz; /* s/g element count */
gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */ gdth_sg_str sg_lst[GDTH_MAXSG]; /* s/g list */
} PACKED raw; /* raw service cmd. struct. */ } PACKED raw; /* raw service cmd. struct. */
struct {
ushort reserved;
ulong32 direction; /* data direction */
ulong32 mdisc_time; /* disc. time (0: no timeout)*/
ulong32 mcon_time; /* connect time(0: no to.) */
ulong64 sdata; /* dest. addr. (if s/g: -1) */
ulong32 sdlen; /* data length (bytes) */
ulong32 clen; /* SCSI cmd. length(6,..,16) */
unchar cmd[16]; /* SCSI command */
unchar target; /* target ID */
unchar lun; /* LUN */
unchar bus; /* SCSI bus number */
unchar priority; /* only 0 used */
ulong32 sense_len; /* sense data length */
ulong64 sense_data; /* sense data addr. */
ulong32 sg_ranz; /* s/g element count */
gdth_sg64_str sg_lst[GDTH_MAXSG]; /* s/g list */
} PACKED raw64; /* raw service cmd. struct. */
} u; } u;
/* additional variables */ /* additional variables */
unchar Service; /* controller service */ unchar Service; /* controller service */
...@@ -236,7 +270,6 @@ typedef struct { ...@@ -236,7 +270,6 @@ typedef struct {
} gdth_iord_str; } gdth_iord_str;
#endif #endif
#ifdef GDTH_IOCTL_CHRDEV
/* GDTIOCTL_GENERAL */ /* GDTIOCTL_GENERAL */
typedef struct { typedef struct {
ushort ionode; /* controller number */ ushort ionode; /* controller number */
...@@ -310,6 +343,5 @@ typedef struct { ...@@ -310,6 +343,5 @@ typedef struct {
ushort number; /* bus/host drive number */ ushort number; /* bus/host drive number */
ushort status; /* status */ ushort status; /* status */
} gdth_ioctl_reset; } gdth_ioctl_reset;
#endif
#endif #endif
/* gdth_proc.c /* gdth_proc.c
* $Id: gdth_proc.c,v 1.37 2003/09/17 08:31:53 achim Exp $ * $Id: gdth_proc.c,v 1.42 2004/03/05 15:50:20 achim Exp $
*/ */
#if LINUX_VERSION_CODE >= 0x020407 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
#include <linux/completion.h> #include <linux/completion.h>
#endif #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length, int gdth_proc_info(struct Scsi_Host *host, char *buffer,char **start,off_t offset,int length,
int inout) int inout)
{ {
int hanum,busnum; int hanum,busnum;
TRACE2(("gdth_proc_info() length %d ha %d offs %d inout %d\n", TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
length,hostno,(int)offset,inout)); length,(int)offset,inout));
hanum = NUMDATA(host)->hanum; hanum = NUMDATA(host)->hanum;
busnum= NUMDATA(host)->busnum; busnum= NUMDATA(host)->busnum;
if (inout) if (inout)
return(gdth_set_info(buffer,length,hanum,busnum)); return(gdth_set_info(buffer,length,host,hanum,busnum));
else else
return(gdth_get_info(buffer,start,offset,length,hanum,busnum)); return(gdth_get_info(buffer,start,offset,length,host,hanum,busnum));
} }
#else
int gdth_proc_info(char *buffer,char **start,off_t offset,int length,int hostno,
int inout)
{
int hanum,busnum,i;
TRACE2(("gdth_proc_info() length %d offs %d inout %d\n",
length,(int)offset,inout));
for (i = 0; i < gdth_ctr_vcount; ++i) {
if (gdth_ctr_vtab[i]->host_no == hostno)
break;
}
if (i == gdth_ctr_vcount)
return(-EINVAL);
static int gdth_set_info(char *buffer,int length,int hanum,int busnum) hanum = NUMDATA(gdth_ctr_vtab[i])->hanum;
busnum= NUMDATA(gdth_ctr_vtab[i])->busnum;
if (inout)
return(gdth_set_info(buffer,length,gdth_ctr_vtab[i],hanum,busnum));
else
return(gdth_get_info(buffer,start,offset,length,
gdth_ctr_vtab[i],hanum,busnum));
}
#endif
static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
int hanum,int busnum)
{ {
int ret_val = -EINVAL; int ret_val = -EINVAL;
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
Scsi_Request *scp; Scsi_Request *scp;
Scsi_Device *sdev; Scsi_Device *sdev;
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
Scsi_Cmnd *scp; Scsi_Cmnd *scp;
Scsi_Device *sdev; Scsi_Device *sdev;
#else #else
Scsi_Cmnd scp; Scsi_Cmnd scp;
Scsi_Device sdev; Scsi_Device sdev;
#endif
#ifdef GDTH_IOCTL_PROC
gdth_iowr_str *piowr;
piowr = (gdth_iowr_str *)buffer;
#endif #endif
TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum)); TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum));
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); sdev = scsi_get_host_dev(host);
scp = scsi_allocate_request(sdev, GFP_KERNEL); scp = scsi_allocate_request(sdev, GFP_KERNEL);
if (!scp) if (!scp)
return -ENOMEM; return -ENOMEM;
scp->sr_cmd_len = 12; scp->sr_cmd_len = 12;
scp->sr_use_sg = 0; scp->sr_use_sg = 0;
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); sdev = scsi_get_host_dev(host);
scp = scsi_allocate_device(sdev, 1, FALSE); scp = scsi_allocate_device(sdev, 1, FALSE);
if (!scp) if (!scp)
return -ENOMEM; return -ENOMEM;
...@@ -59,7 +83,7 @@ static int gdth_set_info(char *buffer,int length,int hanum,int busnum) ...@@ -59,7 +83,7 @@ static int gdth_set_info(char *buffer,int length,int hanum,int busnum)
#else #else
memset(&sdev,0,sizeof(Scsi_Device)); memset(&sdev,0,sizeof(Scsi_Device));
memset(&scp, 0,sizeof(Scsi_Cmnd)); memset(&scp, 0,sizeof(Scsi_Cmnd));
sdev.host = scp.host = gdth_ctr_tab[hanum]; sdev.host = scp.host = host;
sdev.id = scp.target = sdev.host->this_id; sdev.id = scp.target = sdev.host->this_id;
scp.device = &sdev; scp.device = &sdev;
#endif #endif
...@@ -69,32 +93,21 @@ static int gdth_set_info(char *buffer,int length,int hanum,int busnum) ...@@ -69,32 +93,21 @@ static int gdth_set_info(char *buffer,int length,int hanum,int busnum)
buffer += 5; buffer += 5;
length -= 5; length -= 5;
ret_val = gdth_set_asc_info( buffer, length, hanum, scp ); ret_val = gdth_set_asc_info( buffer, length, hanum, scp );
#ifdef GDTH_IOCTL_PROC
} else if (piowr->magic == GDTIOCTL_MAGIC) {
ret_val = gdth_set_bin_info( buffer, length, hanum, scp );
} else {
printk("GDT: Wrong signature %x (%x required)!\n",
piowr->magic, GDTIOCTL_MAGIC);
if (piowr->magic > GDTIOCTL_MAGIC)
printk("GDT: Please update your driver.\n");
else
printk("GDT: Please update your tool.\n");
#endif
} }
} }
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
scsi_release_request(scp); scsi_release_request(scp);
scsi_free_host_dev(sdev); scsi_free_host_dev(sdev);
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
scsi_release_command(scp); scsi_release_command(scp);
scsi_free_host_dev(sdev); scsi_free_host_dev(sdev);
#endif #endif
return ret_val; return ret_val;
} }
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp) static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp)
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp) static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp)
#else #else
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp) static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp)
...@@ -105,7 +118,7 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp) ...@@ -105,7 +118,7 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp)
gdth_ha_str *ha; gdth_ha_str *ha;
gdth_cmd_str gdtcmd; gdth_cmd_str gdtcmd;
gdth_cpar_str *pcpar; gdth_cpar_str *pcpar;
ulong32 paddr; ulong64 paddr;
char cmnd[MAX_COMMAND_SIZE]; char cmnd[MAX_COMMAND_SIZE];
memset(cmnd, 0xff, 12); memset(cmnd, 0xff, 12);
...@@ -139,11 +152,16 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp) ...@@ -139,11 +152,16 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp)
found = TRUE; found = TRUE;
gdtcmd.Service = CACHESERVICE; gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_FLUSH; gdtcmd.OpCode = GDT_FLUSH;
if (ha->cache_feat & GDT_64BIT) {
gdtcmd.u.cache64.DeviceNo = i;
gdtcmd.u.cache64.BlockNo = 1;
} else {
gdtcmd.u.cache.DeviceNo = i; gdtcmd.u.cache.DeviceNo = i;
gdtcmd.u.cache.BlockNo = 1; gdtcmd.u.cache.BlockNo = 1;
#if LINUX_VERSION_CODE >= 0x020503 }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
#else #else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
...@@ -199,9 +217,9 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp) ...@@ -199,9 +217,9 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp)
gdtcmd.u.ioctl.subfunc = CACHE_CONFIG; gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
gdtcmd.u.ioctl.channel = INVALID_CHANNEL; gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
pcpar->write_back = wb_mode==1 ? 0:1; pcpar->write_back = wb_mode==1 ? 0:1;
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
#else #else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30); gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
...@@ -215,562 +233,23 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp) ...@@ -215,562 +233,23 @@ static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp)
return(-EINVAL); return(-EINVAL);
} }
#ifdef GDTH_IOCTL_PROC static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
#if LINUX_VERSION_CODE >= 0x020503 struct Scsi_Host *host,int hanum,int busnum)
static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Request *scp)
#elif LINUX_VERSION_CODE >= 0x020322
static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp)
#else
static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd scp)
#endif
{
unchar i, j;
ushort k, hdr_cnt, status;
gdth_ha_str *ha;
gdth_iowr_str *piowr;
gdth_iord_str *piord;
gdth_cmd_str *pcmd;
gdth_evt_str *pevt;
ulong32 *ppadd, add_size, *ppadd2, add_size2, info, paddr;
ulong flags;
gdth_cmd_str gdtcmd;
int drv_cyls, drv_hds, drv_secs;
char cmnd[MAX_COMMAND_SIZE];
memset(cmnd, 0xff, 12);
memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
TRACE2(("gdth_set_bin_info() ha %d\n",hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
piowr = (gdth_iowr_str *)buffer;
piord = NULL;
pcmd = NULL;
ppadd = ppadd2 = NULL;
add_size = add_size2 = 0;
if (length < GDTOFFSOF(gdth_iowr_str,iu))
return(-EINVAL);
switch (piowr->ioctl) {
case GDTIOCTL_GENERAL:
if (length < GDTOFFSOF(gdth_iowr_str,iu.general.data[0]))
return(-EINVAL);
pcmd = (gdth_cmd_str *)piowr->iu.general.command;
pcmd->Service = piowr->service;
if (pcmd->OpCode == GDT_IOCTL) {
ppadd = &pcmd->u.ioctl.p_param;
add_size = pcmd->u.ioctl.param_size;
} else if (piowr->service == CACHESERVICE) {
add_size = pcmd->u.cache.BlockCnt * SECTOR_SIZE;
if (ha->cache_feat & SCATTER_GATHER) {
ppadd = &pcmd->u.cache.sg_lst[0].sg_ptr;
pcmd->u.cache.DestAddr = 0xffffffff;
pcmd->u.cache.sg_lst[0].sg_len = add_size;
pcmd->u.cache.sg_canz = 1;
} else {
ppadd = &pcmd->u.cache.DestAddr;
pcmd->u.cache.sg_canz = 0;
}
} else if (piowr->service == SCSIRAWSERVICE) {
add_size = pcmd->u.raw.sdlen;
add_size2 = pcmd->u.raw.sense_len;
if (ha->raw_feat & SCATTER_GATHER) {
ppadd = &pcmd->u.raw.sg_lst[0].sg_ptr;
pcmd->u.raw.sdata = 0xffffffff;
pcmd->u.raw.sg_lst[0].sg_len = add_size;
pcmd->u.raw.sg_ranz = 1;
} else {
ppadd = &pcmd->u.raw.sdata;
pcmd->u.raw.sg_ranz = 0;
}
ppadd2 = &pcmd->u.raw.sense_data;
} else {
return(-EINVAL);
}
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str)+add_size+add_size2,
TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str) + add_size + add_size2;
if (add_size > 0) {
memcpy(piord->iu.general.data, piowr->iu.general.data, add_size);
*ppadd = paddr + GDTOFFSOF(gdth_iord_str, iu.general.data[0]);
}
if (add_size2 > 0) {
memcpy(piord->iu.general.data+add_size, piowr->iu.general.data, add_size2);
*ppadd2 = paddr + GDTOFFSOF(gdth_iord_str, iu.general.data[0]) + add_size2;
}
/* do IOCTL */
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, pcmd, cmnd, piowr->timeout);
piord->status = (scp->sr_command->SCp.Message << 16) |
scp->sr_command->SCp.Status;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, pcmd, cmnd, piowr->timeout);
piord->status = (scp->SCp.Message<<16)|scp->SCp.Status;
#else
gdth_do_cmd(&scp, pcmd, cmnd, piowr->timeout);
piord->status = (scp.SCp.Message<<16)|scp.SCp.Status;
#endif
break;
case GDTIOCTL_DRVERS:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
piord->iu.drvers.version = (GDTH_VERSION<<8) | GDTH_SUBVERSION;
break;
case GDTIOCTL_CTRTYPE:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
if (ha->type == GDT_ISA || ha->type == GDT_EISA) {
piord->iu.ctrtype.type = (unchar)((ha->stype>>20) - 0x10);
} else {
if (ha->type != GDT_PCIMPR) {
piord->iu.ctrtype.type = (unchar)((ha->stype<<4) + 6);
} else {
piord->iu.ctrtype.type =
(ha->oem_id == OEM_ID_INTEL ? 0xfd : 0xfe);
if (ha->stype >= 0x300)
piord->iu.ctrtype.ext_type = 0x6000 | ha->subdevice_id;
else
piord->iu.ctrtype.ext_type = 0x6000 | ha->stype;
}
piord->iu.ctrtype.device_id = ha->stype;
piord->iu.ctrtype.sub_device_id = ha->subdevice_id;
}
piord->iu.ctrtype.info = ha->brd_phys;
piord->iu.ctrtype.oem_id = ha->oem_id;
break;
case GDTIOCTL_CTRCNT:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
piord->iu.ctrcnt.count = (ushort)gdth_ctr_count;
break;
case GDTIOCTL_OSVERS:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
piord->iu.osvers.version = (unchar)(LINUX_VERSION_CODE >> 16);
piord->iu.osvers.subversion = (unchar)(LINUX_VERSION_CODE >> 8);
piord->iu.osvers.revision = (ushort)(LINUX_VERSION_CODE & 0xff);
break;
case GDTIOCTL_LOCKDRV:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
for (i = 0; i < piowr->iu.lockdrv.drive_cnt; ++i) {
j = piowr->iu.lockdrv.drives[i];
if (j >= MAX_HDRIVES || !ha->hdr[j].present)
continue;
if (piowr->iu.lockdrv.lock) {
GDTH_LOCK_HA(ha, flags);
ha->hdr[j].lock = 1;
GDTH_UNLOCK_HA(ha, flags);
gdth_wait_completion( hanum, ha->bus_cnt, j );
gdth_stop_timeout( hanum, ha->bus_cnt, j );
} else {
GDTH_LOCK_HA(ha, flags);
ha->hdr[j].lock = 0;
GDTH_UNLOCK_HA(ha, flags);
gdth_start_timeout( hanum, ha->bus_cnt, j );
gdth_next( hanum );
}
}
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
break;
case GDTIOCTL_LOCKCHN:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
i = piowr->iu.lockchn.channel;
if (i < ha->bus_cnt) {
if (piowr->iu.lockchn.lock) {
GDTH_LOCK_HA(ha, flags);
ha->raw[i].lock = 1;
GDTH_UNLOCK_HA(ha, flags);
for (j = 0; j < ha->tid_cnt; ++j) {
gdth_wait_completion( hanum, i, j );
gdth_stop_timeout( hanum, i, j );
}
} else {
GDTH_LOCK_HA(ha, flags);
ha->raw[i].lock = 0;
GDTH_UNLOCK_HA(ha, flags);
for (j = 0; j < ha->tid_cnt; ++j) {
gdth_start_timeout( hanum, i, j );
gdth_next( hanum );
}
}
}
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
break;
case GDTIOCTL_EVENT:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
if (piowr->iu.event.erase == 0xff) {
pevt = (gdth_evt_str *)piowr->iu.event.evt;
if (pevt->event_source == ES_TEST)
pevt->event_data.size = sizeof(pevt->event_data.eu.test);
else if (pevt->event_source == ES_DRIVER)
pevt->event_data.size = sizeof(pevt->event_data.eu.driver);
else if (pevt->event_source == ES_SYNC)
pevt->event_data.size = sizeof(pevt->event_data.eu.sync);
else {
pevt->event_data.size = sizeof(pevt->event_data.eu.async);
gdth_log_event(&pevt->event_data, NULL);
}
GDTH_LOCK_HA(ha, flags);
gdth_store_event(ha, pevt->event_source, pevt->event_idx,
&pevt->event_data);
GDTH_UNLOCK_HA(ha, flags);
} else if (piowr->iu.event.erase == 0xfe) {
gdth_clear_events();
} else if (piowr->iu.event.erase == 0) {
piord->iu.event.handle =
gdth_read_event(ha,piowr->iu.event.handle,
(gdth_evt_str *)piord->iu.event.evt);
} else {
piord->iu.event.handle = piowr->iu.event.handle;
gdth_readapp_event(ha, (unchar)piowr->iu.event.erase,
(gdth_evt_str *)piord->iu.event.evt);
}
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
break;
case GDTIOCTL_SCSI:
#if LINUX_VERSION_CODE >= 0x020503
return(-EINVAL);
#else
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
memcpy(cmnd, piowr->iu.scsi.cmd, 12);
#if LINUX_VERSION_CODE >= 0x020322
scp->target = piowr->iu.scsi.target;
scp->channel = virt_ctr ? 0 : piowr->iu.scsi.bus;
scp->cmd_len = piowr->iu.scsi.cmd_len;
gdth_do_cmd(scp, pcmd, cmnd, piowr->timeout);
piord->status = (scp->SCp.Message<<16)|scp->SCp.Status;
#else
scp.target = piowr->iu.scsi.target;
scp.channel = virt_ctr ? 0 : piowr->iu.scsi.bus;
scp.cmd_len = piowr->iu.scsi.cmd_len;
gdth_do_cmd(&scp, pcmd, cmnd, piowr->timeout);
piord->status = (scp.SCp.Message<<16)|scp.SCp.Status;
#endif
#endif
break;
case GDTIOCTL_RESET_BUS:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
#if LINUX_VERSION_CODE >= 0x02053C
{
Scsi_Device *sdev;
Scsi_Cmnd *scmnd;
sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]);
scmnd= scsi_get_command(sdev, GFP_KERNEL);
if (!scmnd)
return(-ENOMEM);
scmnd->device->host = scp->sr_host;
scmnd->device->channel = virt_ctr ? 0 : piowr->iu.scsi.bus;
piord->status = (ulong32)gdth_eh_bus_reset( scmnd );
if (piord->status == SUCCESS)
piord->status = S_OK;
else
piord->status = S_GENERR;
scsi_put_command(scmnd);
scsi_free_host_dev(sdev);
}
#elif LINUX_VERSION_CODE >= 0x020503
{
Scsi_Cmnd scmnd;
scmnd.host = scp->sr_host;
scmnd.channel = virt_ctr ? 0 : piowr->iu.scsi.bus;
piord->status = (ulong32)gdth_eh_bus_reset( &scmnd );
if (piord->status == SUCCESS)
piord->status = S_OK;
else
piord->status = S_GENERR;
}
#elif LINUX_VERSION_CODE >= 0x020322
scp->channel = virt_ctr ? 0 : piowr->iu.scsi.bus;
piord->status = (ulong32)gdth_eh_bus_reset( scp );
if (piord->status == SUCCESS)
piord->status = S_OK;
else
piord->status = S_GENERR;
#elif LINUX_VERSION_CODE >= 0x02015F
scp.channel = virt_ctr ? 0 : piowr->iu.scsi.bus;
piord->status = (ulong32)gdth_eh_bus_reset( &scp );
if (piord->status == SUCCESS)
piord->status = S_OK;
else
piord->status = S_GENERR;
#else
piord->status = S_OK;
#endif
break;
case GDTIOCTL_HDRLIST:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
for (i = 0; i < MAX_HDRIVES; ++i) {
if (ha->hdr[i].present) {
piord->iu.hdr_list[i].bus = ha->virt_bus;
piord->iu.hdr_list[i].target = i;
piord->iu.hdr_list[i].lun = 0;
piord->iu.hdr_list[i].cluster_type = ha->hdr[i].cluster_type;
if (ha->hdr[i].cluster_type & CLUSTER_DRIVE) {
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_CLUST_INFO;
gdtcmd.u.cache.DeviceNo = i;
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, &gdtcmd, cmnd, 30);
if (scp->sr_command->SCp.Status == S_OK)
piord->iu.hdr_list[i].cluster_type =
(unchar)scp->sr_command->SCp.Message;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
if (scp->SCp.Status == S_OK)
piord->iu.hdr_list[i].cluster_type =
(unchar)scp->SCp.Message;
#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
if (scp.SCp.Status == S_OK)
piord->iu.hdr_list[i].cluster_type =
(unchar)scp.SCp.Message;
#endif
}
} else {
piord->iu.hdr_list[i].bus = 0xff;
}
}
break;
case GDTIOCTL_RESCAN:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
if (piowr->iu.rescan.flag == 0) {
/* old method: scan all host drives
re-initialize cache service to get host drive count
*/
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_INIT;
gdtcmd.u.cache.DeviceNo = LINUX_OS;
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->sr_command->SCp.Status;
info = (ulong32)scp->sr_command->SCp.Message;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->SCp.Status;
info = (ulong32)scp->SCp.Message;
#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
status = (ushort)scp.SCp.Status;
info = (ulong32)scp.SCp.Message;
#endif
if (status != S_OK)
break;
k = 0;
hdr_cnt = (ushort)info;
} else {
k = piowr->iu.rescan.hdr_no;
hdr_cnt = k + 1;
}
if (hdr_cnt > MAX_HDRIVES)
hdr_cnt = MAX_HDRIVES;
/* scanning for host drives */
for (; k < hdr_cnt; ++k) {
/* info about host drive */
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_INFO;
gdtcmd.u.cache.DeviceNo = k;
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->sr_command->SCp.Status;
info = (ulong32)scp->sr_command->SCp.Message;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->SCp.Status;
info = (ulong32)scp->SCp.Message;
#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
status = (ushort)scp.SCp.Status;
info = (ulong32)scp.SCp.Message;
#endif
GDTH_LOCK_HA(ha, flags);
piord->iu.hdr_list[k].bus = ha->virt_bus;
piord->iu.hdr_list[k].target = k;
piord->iu.hdr_list[k].lun = 0;
if (status != S_OK) {
ha->hdr[k].present = FALSE;
} else {
ha->hdr[k].present = TRUE;
ha->hdr[k].size = info;
/* evaluate mapping (sectors per head, heads per cylinder) */
ha->hdr[k].size &= ~SECS32;
gdth_eval_mapping(ha->hdr[k].size,&drv_cyls,&drv_hds,&drv_secs);
ha->hdr[k].heads = (unchar)drv_hds;
ha->hdr[k].secs = (unchar)drv_secs;
/* round size */
ha->hdr[k].size = drv_cyls * drv_hds * drv_secs;
}
GDTH_UNLOCK_HA(ha, flags);
if (status != S_OK)
continue; /* next host drive */
/* devtype, cluster info, R/W attributes */
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_DEVTYPE;
gdtcmd.u.cache.DeviceNo = k;
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->sr_command->SCp.Status;
info = (ulong32)scp->sr_command->SCp.Message;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->SCp.Status;
info = (ulong32)scp->SCp.Message;
#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
status = (ushort)scp.SCp.Status;
info = (ulong32)scp.SCp.Message;
#endif
GDTH_LOCK_HA(ha, flags);
ha->hdr[k].devtype = 0;
if (status == S_OK)
ha->hdr[k].devtype = (ushort)info;
GDTH_UNLOCK_HA(ha, flags);
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_CLUST_INFO;
gdtcmd.u.cache.DeviceNo = k;
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->sr_command->SCp.Status;
info = (ulong32)scp->sr_command->SCp.Message;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->SCp.Status;
info = (ulong32)scp->SCp.Message;
#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
status = (ushort)scp.SCp.Status;
info = (ulong32)scp.SCp.Message;
#endif
GDTH_LOCK_HA(ha, flags);
ha->hdr[k].cluster_type = 0;
if (status == S_OK && !shared_access)
ha->hdr[k].cluster_type = (ushort)info;
GDTH_UNLOCK_HA(ha, flags);
piord->iu.hdr_list[k].cluster_type = ha->hdr[k].cluster_type;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_RW_ATTRIBS;
gdtcmd.u.cache.DeviceNo = k;
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->sr_command->SCp.Status;
info = (ulong32)scp->sr_command->SCp.Message;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
status = (ushort)scp->SCp.Status;
info = (ulong32)scp->SCp.Message;
#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
status = (ushort)scp.SCp.Status;
info = (ulong32)scp.SCp.Message;
#endif
GDTH_LOCK_HA(ha, flags);
ha->hdr[k].rw_attribs = 0;
if (status == S_OK)
ha->hdr[k].rw_attribs = (ushort)info;
GDTH_UNLOCK_HA(ha, flags);
}
break;
case GDTIOCTL_RESET_DRV:
if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str), TRUE, &paddr ))
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
piord->status = S_OK;
i = piowr->iu.scsi.target;
if (ha->hdr[i].present) {
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_CLUST_RESET;
gdtcmd.u.cache.DeviceNo = i;
#if LINUX_VERSION_CODE >= 0x020503
gdth_do_req(scp, &gdtcmd, cmnd, 30);
piord->status = (ushort)scp->sr_command->SCp.Status;
#elif LINUX_VERSION_CODE >= 0x020322
gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
piord->status = (scp->SCp.Message<<16)|scp->SCp.Status;
#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
piord->status = (scp.SCp.Message<<16)|scp.SCp.Status;
#endif
}
break;
default:
return(-EINVAL);
}
return length;
}
#endif
static int gdth_get_info(char *buffer,char **start,off_t offset,
int length,int hanum,int busnum)
{ {
int size = 0,len = 0; int size = 0,len = 0;
off_t begin = 0,pos = 0; off_t begin = 0,pos = 0;
gdth_ha_str *ha; gdth_ha_str *ha;
int id, i, j, k, sec, flag; int id, i, j, k, sec, flag;
int no_mdrv = 0, drv_no, is_mirr; int no_mdrv = 0, drv_no, is_mirr;
ulong32 cnt, paddr; ulong32 cnt;
ulong64 paddr;
gdth_cmd_str gdtcmd; gdth_cmd_str gdtcmd;
gdth_evt_str estr; gdth_evt_str estr;
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
Scsi_Request *scp; Scsi_Request *scp;
Scsi_Device *sdev; Scsi_Device *sdev;
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
Scsi_Cmnd *scp; Scsi_Cmnd *scp;
Scsi_Device *sdev; Scsi_Device *sdev;
#else #else
...@@ -795,15 +274,15 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -795,15 +274,15 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum)); TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum));
ha = HADATA(gdth_ctr_tab[hanum]); ha = HADATA(gdth_ctr_tab[hanum]);
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); sdev = scsi_get_host_dev(host);
scp = scsi_allocate_request(sdev, GFP_KERNEL); scp = scsi_allocate_request(sdev, GFP_KERNEL);
if (!scp) if (!scp)
return -ENOMEM; return -ENOMEM;
scp->sr_cmd_len = 12; scp->sr_cmd_len = 12;
scp->sr_use_sg = 0; scp->sr_use_sg = 0;
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
sdev = scsi_get_host_dev(gdth_ctr_tab[hanum]); sdev = scsi_get_host_dev(host);
scp = scsi_allocate_device(sdev, 1, FALSE); scp = scsi_allocate_device(sdev, 1, FALSE);
if (!scp) if (!scp)
return -ENOMEM; return -ENOMEM;
...@@ -812,15 +291,12 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -812,15 +291,12 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
#else #else
memset(&sdev,0,sizeof(Scsi_Device)); memset(&sdev,0,sizeof(Scsi_Device));
memset(&scp, 0,sizeof(Scsi_Cmnd)); memset(&scp, 0,sizeof(Scsi_Cmnd));
sdev.host = scp.host = gdth_ctr_tab[hanum]; sdev.host = scp.host = host;
sdev.id = scp.target = sdev.host->this_id; sdev.id = scp.target = sdev.host->this_id;
scp.device = &sdev; scp.device = &sdev;
#endif #endif
#ifdef GDTH_IOCTL_PROC
/* ioctl from tool? */
if (!gdth_ioctl_check_bin(hanum, (ushort)length)) {
#endif
/* request is i.e. "cat /proc/scsi/gdth/0" */ /* request is i.e. "cat /proc/scsi/gdth/0" */
/* format: %-15s\t%-10s\t%-15s\t%s */ /* format: %-15s\t%-10s\t%-15s\t%s */
/* driver parameters */ /* driver parameters */
...@@ -873,6 +349,24 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -873,6 +349,24 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
GDTH_VERSION_STR, hrec); GDTH_VERSION_STR, hrec);
len += size; pos = begin + len; len += size; pos = begin + len;
if (ha->more_proc) {
/* more information: 1. about controller */
size = sprintf(buffer+len,
" Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n",
ha->binfo.ser_no, ha->binfo.memsize / 1024);
len += size; pos = begin + len;
}
#ifdef GDTH_DMA_STATISTICS
/* controller statistics */
size = sprintf(buffer+len,"\nController Statistics:\n");
len += size; pos = begin + len;
size = sprintf(buffer+len,
" 32-bit DMA buffer:\t%lu\t64-bit DMA buffer:\t%lu\n",
ha->dma32_cnt, ha->dma64_cnt);
len += size; pos = begin + len;
#endif
if (pos < offset) { if (pos < offset) {
len = 0; len = 0;
begin = pos; begin = pos;
...@@ -881,13 +375,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -881,13 +375,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
goto stop_output; goto stop_output;
if (ha->more_proc) { if (ha->more_proc) {
/* more information: 1. about controller */ /* more information: 2. about physical devices */
size = sprintf(buffer+len,
" Serial No.: \t0x%8X\tCache RAM size:\t%d KB\n",
ha->binfo.ser_no, ha->binfo.memsize / 1024);
len += size; pos = begin + len;
/* 2. about physical devices */
size = sprintf(buffer+len,"\nPhysical Devices:"); size = sprintf(buffer+len,"\nPhysical Devices:");
len += size; pos = begin + len; len += size; pos = begin + len;
flag = FALSE; flag = FALSE;
...@@ -912,10 +400,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -912,10 +400,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
sizeof(pds->list[0]); sizeof(pds->list[0]);
if (pds->entries > cnt) if (pds->entries > cnt)
pds->entries = cnt; pds->entries = cnt;
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
if (scp->sr_command->SCp.Status != S_OK) if (scp->sr_command->SCp.Status != S_OK)
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
if (scp->SCp.Status != S_OK) if (scp->SCp.Status != S_OK)
#else #else
...@@ -939,10 +427,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -939,10 +427,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
gdtcmd.u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN; gdtcmd.u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN;
gdtcmd.u.ioctl.channel = gdtcmd.u.ioctl.channel =
ha->raw[i].address | ha->raw[i].id_list[j]; ha->raw[i].address | ha->raw[i].id_list[j];
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
if (scp->sr_command->SCp.Status == S_OK) if (scp->sr_command->SCp.Status == S_OK)
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
if (scp->SCp.Status == S_OK) if (scp->SCp.Status == S_OK)
#else #else
...@@ -998,10 +486,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -998,10 +486,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
gdtcmd.u.ioctl.channel = gdtcmd.u.ioctl.channel =
ha->raw[i].address | ha->raw[i].id_list[j]; ha->raw[i].address | ha->raw[i].id_list[j];
pdef->sddc_type = 0x08; pdef->sddc_type = 0x08;
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
if (scp->sr_command->SCp.Status == S_OK) if (scp->sr_command->SCp.Status == S_OK)
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
if (scp->SCp.Status == S_OK) if (scp->SCp.Status == S_OK)
#else #else
...@@ -1054,10 +542,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -1054,10 +542,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
gdtcmd.u.ioctl.param_size = sizeof(gdth_cdrinfo_str); gdtcmd.u.ioctl.param_size = sizeof(gdth_cdrinfo_str);
gdtcmd.u.ioctl.subfunc = CACHE_DRV_INFO; gdtcmd.u.ioctl.subfunc = CACHE_DRV_INFO;
gdtcmd.u.ioctl.channel = drv_no; gdtcmd.u.ioctl.channel = drv_no;
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
if (scp->sr_command->SCp.Status != S_OK) if (scp->sr_command->SCp.Status != S_OK)
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
if (scp->SCp.Status != S_OK) if (scp->SCp.Status != S_OK)
#else #else
...@@ -1167,10 +655,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -1167,10 +655,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
gdtcmd.u.ioctl.param_size = sizeof(gdth_arrayinf_str); gdtcmd.u.ioctl.param_size = sizeof(gdth_arrayinf_str);
gdtcmd.u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN; gdtcmd.u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN;
gdtcmd.u.ioctl.channel = i; gdtcmd.u.ioctl.channel = i;
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
if (scp->sr_command->SCp.Status == S_OK) if (scp->sr_command->SCp.Status == S_OK)
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
if (scp->SCp.Status == S_OK) if (scp->SCp.Status == S_OK)
#else #else
...@@ -1251,10 +739,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -1251,10 +739,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
gdtcmd.u.ioctl.channel = i; gdtcmd.u.ioctl.channel = i;
phg->entries = MAX_HDRIVES; phg->entries = MAX_HDRIVES;
phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]); phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]);
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
gdth_do_req(scp, &gdtcmd, cmnd, 30); gdth_do_req(scp, &gdtcmd, cmnd, 30);
if (scp->sr_command->SCp.Status != S_OK) if (scp->sr_command->SCp.Status != S_OK)
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
gdth_do_cmd(scp, &gdtcmd, cmnd, 30); gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
if (scp->SCp.Status != S_OK) if (scp->SCp.Status != S_OK)
#else #else
...@@ -1290,7 +778,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -1290,7 +778,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
size = sprintf(buffer+len, size = sprintf(buffer+len,
" Capacity [MB]:\t%-6d \tStart Sector: \t%d\n", " Capacity [MB]:\t%-6d \tStart Sector: \t%d\n",
ha->hdr[i].size/2048, ha->hdr[i].start_sec); (ulong32)(ha->hdr[i].size/2048), ha->hdr[i].start_sec);
len += size; pos = begin + len; len += size; pos = begin + len;
if (pos < offset) { if (pos < offset) {
len = 0; len = 0;
...@@ -1333,26 +821,12 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -1333,26 +821,12 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
if (id == -1) if (id == -1)
break; break;
} }
#ifdef GDTH_IOCTL_PROC
} else {
gdth_iord_str *piord;
/* request from tool (GDTMON,..) */
piord = (gdth_iord_str *)ha->pscratch;
if (piord == NULL)
goto stop_output;
length = piord->size;
memcpy(buffer+len, (char *)piord, length);
gdth_ioctl_free(hanum, GDTH_SCRATCH, ha->pscratch, paddr);
len = length;
}
#endif
stop_output: stop_output:
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
scsi_release_request(scp); scsi_release_request(scp);
scsi_free_host_dev(sdev); scsi_free_host_dev(sdev);
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
scsi_release_command(scp); scsi_release_command(scp);
scsi_free_host_dev(sdev); scsi_free_host_dev(sdev);
#endif #endif
...@@ -1365,7 +839,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset, ...@@ -1365,7 +839,8 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,
return(len); return(len);
} }
#if LINUX_VERSION_CODE >= 0x020503
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
static void gdth_do_req(Scsi_Request *scp, gdth_cmd_str *gdtcmd, static void gdth_do_req(Scsi_Request *scp, gdth_cmd_str *gdtcmd,
char *cmnd, int timeout) char *cmnd, int timeout)
{ {
...@@ -1389,9 +864,9 @@ static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd, ...@@ -1389,9 +864,9 @@ static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd,
char *cmnd, int timeout) char *cmnd, int timeout)
{ {
unsigned bufflen; unsigned bufflen;
#if LINUX_VERSION_CODE >= 0x020407 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
DECLARE_COMPLETION(wait); DECLARE_COMPLETION(wait);
#elif LINUX_VERSION_CODE >= 0x020322 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
DECLARE_MUTEX_LOCKED(sem); DECLARE_MUTEX_LOCKED(sem);
#else #else
struct semaphore sem = MUTEX_LOCKED; struct semaphore sem = MUTEX_LOCKED;
...@@ -1405,19 +880,19 @@ static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd, ...@@ -1405,19 +880,19 @@ static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd,
scp->SCp.this_residual = DEFAULT_PRI; scp->SCp.this_residual = DEFAULT_PRI;
bufflen = 0; bufflen = 0;
} }
#if LINUX_VERSION_CODE >= 0x020407 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
scp->request.rq_status = RQ_SCSI_BUSY; scp->request.rq_status = RQ_SCSI_BUSY;
scp->request.waiting = &wait; scp->request.waiting = &wait;
scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1);
wait_for_completion(&wait); wait_for_completion(&wait);
#else #else
scp->request.sem = &sem; scp->request.sem = &sem;
#if LINUX_VERSION_CODE >= 0x020322 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1);
#else #else
GDTH_LOCK_SCSI_DOCMD(); spin_lock_irq(&io_request_lock);
scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1); scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1);
GDTH_UNLOCK_SCSI_DOCMD(); spin_unlock_irq(&io_request_lock);
#endif #endif
down(&sem); down(&sem);
#endif #endif
...@@ -1428,11 +903,11 @@ void gdth_scsi_done(Scsi_Cmnd *scp) ...@@ -1428,11 +903,11 @@ void gdth_scsi_done(Scsi_Cmnd *scp)
{ {
TRACE2(("gdth_scsi_done()\n")); TRACE2(("gdth_scsi_done()\n"));
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
scp->request->rq_status = RQ_SCSI_DONE; scp->request->rq_status = RQ_SCSI_DONE;
if (scp->request->waiting != NULL) if (scp->request->waiting != NULL)
complete(scp->request->waiting); complete(scp->request->waiting);
#elif LINUX_VERSION_CODE >= 0x020407 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,7)
scp->request.rq_status = RQ_SCSI_DONE; scp->request.rq_status = RQ_SCSI_DONE;
if (scp->request.waiting != NULL) if (scp->request.waiting != NULL)
complete(scp->request.waiting); complete(scp->request.waiting);
...@@ -1444,7 +919,7 @@ void gdth_scsi_done(Scsi_Cmnd *scp) ...@@ -1444,7 +919,7 @@ void gdth_scsi_done(Scsi_Cmnd *scp)
} }
static char *gdth_ioctl_alloc(int hanum, int size, int scratch, static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
ulong32 *paddr) ulong64 *paddr)
{ {
gdth_ha_str *ha; gdth_ha_str *ha;
ulong flags; ulong flags;
...@@ -1463,11 +938,11 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch, ...@@ -1463,11 +938,11 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
} else if (scratch) { } else if (scratch) {
ret_val = NULL; ret_val = NULL;
} else { } else {
#if LINUX_VERSION_CODE >= 0x020400 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
dma_addr_t dma_addr; dma_addr_t dma_addr;
ret_val = pci_alloc_consistent(ha->pdev, size, &dma_addr); ret_val = pci_alloc_consistent(ha->pdev, size, &dma_addr);
*paddr = (ulong32)dma_addr; *paddr = dma_addr;
#else #else
ret_val = scsi_init_malloc(size, GFP_ATOMIC | GFP_DMA); ret_val = scsi_init_malloc(size, GFP_ATOMIC | GFP_DMA);
if (ret_val) if (ret_val)
...@@ -1479,7 +954,7 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch, ...@@ -1479,7 +954,7 @@ static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
return ret_val; return ret_val;
} }
static void gdth_ioctl_free(int hanum, int size, char *buf, ulong32 paddr) static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr)
{ {
gdth_ha_str *ha; gdth_ha_str *ha;
ulong flags; ulong flags;
...@@ -1490,7 +965,7 @@ static void gdth_ioctl_free(int hanum, int size, char *buf, ulong32 paddr) ...@@ -1490,7 +965,7 @@ static void gdth_ioctl_free(int hanum, int size, char *buf, ulong32 paddr)
if (buf == ha->pscratch) { if (buf == ha->pscratch) {
ha->scratch_busy = FALSE; ha->scratch_busy = FALSE;
} else { } else {
#if LINUX_VERSION_CODE >= 0x020400 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
pci_free_consistent(ha->pdev, size, buf, paddr); pci_free_consistent(ha->pdev, size, buf, paddr);
#else #else
scsi_init_free((void *)buf, size); scsi_init_free((void *)buf, size);
...@@ -1533,7 +1008,7 @@ static void gdth_wait_completion(int hanum, int busnum, int id) ...@@ -1533,7 +1008,7 @@ static void gdth_wait_completion(int hanum, int busnum, int id)
for (i = 0; i < GDTH_MAXCMDS; ++i) { for (i = 0; i < GDTH_MAXCMDS; ++i) {
scp = ha->cmd_tab[i].cmnd; scp = ha->cmd_tab[i].cmnd;
#if LINUX_VERSION_CODE >= 0x02053C #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel;
t = scp->device->id; t = scp->device->id;
#else #else
...@@ -1546,14 +1021,10 @@ static void gdth_wait_completion(int hanum, int busnum, int id) ...@@ -1546,14 +1021,10 @@ static void gdth_wait_completion(int hanum, int busnum, int id)
GDTH_UNLOCK_HA(ha, flags); GDTH_UNLOCK_HA(ha, flags);
while (!scp->SCp.have_data_in) while (!scp->SCp.have_data_in)
barrier(); barrier();
#if LINUX_VERSION_CODE >= 0x02053C #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
GDTH_LOCK_SCSI_DONE(scp->device->host, flags); GDTH_LOCK_SCSI_DONE(scp->device->host, flags);
scp->scsi_done(scp); scp->scsi_done(scp);
GDTH_UNLOCK_SCSI_DONE(scp->device->host, flags); GDTH_UNLOCK_SCSI_DONE(scp->device->host, flags);
#elif LINUX_VERSION_CODE >= 0x020503
GDTH_LOCK_SCSI_DONE(scp->host, flags);
scp->scsi_done(scp);
GDTH_UNLOCK_SCSI_DONE(scp->host, flags);
#else #else
GDTH_LOCK_SCSI_DONE(flags); GDTH_LOCK_SCSI_DONE(flags);
scp->scsi_done(scp); scp->scsi_done(scp);
...@@ -1576,7 +1047,7 @@ static void gdth_stop_timeout(int hanum, int busnum, int id) ...@@ -1576,7 +1047,7 @@ static void gdth_stop_timeout(int hanum, int busnum, int id)
GDTH_LOCK_HA(ha, flags); GDTH_LOCK_HA(ha, flags);
for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
#if LINUX_VERSION_CODE >= 0x02053C #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel;
t = scp->device->id; t = scp->device->id;
#else #else
...@@ -1602,7 +1073,7 @@ static void gdth_start_timeout(int hanum, int busnum, int id) ...@@ -1602,7 +1073,7 @@ static void gdth_start_timeout(int hanum, int busnum, int id)
GDTH_LOCK_HA(ha, flags); GDTH_LOCK_HA(ha, flags);
for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
#if LINUX_VERSION_CODE >= 0x02053C #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel; b = virt_ctr ? NUMDATA(scp->device->host)->busnum : scp->device->channel;
t = scp->device->id; t = scp->device->id;
#else #else
...@@ -1624,7 +1095,6 @@ static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout) ...@@ -1624,7 +1095,6 @@ static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout)
oldto = scp->timeout_per_command; oldto = scp->timeout_per_command;
scp->timeout_per_command = timeout; scp->timeout_per_command = timeout;
#if LINUX_VERSION_CODE >= 0x02014B
if (timeout == 0) { if (timeout == 0) {
del_timer(&scp->eh_timeout); del_timer(&scp->eh_timeout);
scp->eh_timeout.data = (unsigned long) NULL; scp->eh_timeout.data = (unsigned long) NULL;
...@@ -1636,17 +1106,6 @@ static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout) ...@@ -1636,17 +1106,6 @@ static int gdth_update_timeout(int hanum, Scsi_Cmnd *scp, int timeout)
scp->eh_timeout.expires = jiffies + timeout; scp->eh_timeout.expires = jiffies + timeout;
add_timer(&scp->eh_timeout); add_timer(&scp->eh_timeout);
} }
#else
if (timeout > 0) {
if (timer_table[SCSI_TIMER].expires == 0) {
timer_table[SCSI_TIMER].expires = jiffies + timeout;
timer_active |= 1 << SCSI_TIMER;
} else {
if (jiffies + timeout < timer_table[SCSI_TIMER].expires)
timer_table[SCSI_TIMER].expires = jiffies + timeout;
}
}
#endif
return oldto; return oldto;
} }
...@@ -2,42 +2,31 @@ ...@@ -2,42 +2,31 @@
#define _GDTH_PROC_H #define _GDTH_PROC_H
/* gdth_proc.h /* gdth_proc.h
* $Id: gdth_proc.h,v 1.14 2003/08/27 11:37:35 achim Exp $ * $Id: gdth_proc.h,v 1.16 2004/01/14 13:09:01 achim Exp $
*/ */
static int gdth_set_info(char *buffer,int length,int hanum,int busnum); static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
static int gdth_get_info(char *buffer,char **start,off_t offset, int hanum,int busnum);
int length,int hanum,int busnum); static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
struct Scsi_Host *host,int hanum,int busnum);
#if LINUX_VERSION_CODE >= 0x020503 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
static void gdth_do_req(Scsi_Request *srp, gdth_cmd_str *cmd, static void gdth_do_req(Scsi_Request *srp, gdth_cmd_str *cmd,
char *cmnd, int timeout); char *cmnd, int timeout);
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp); static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Request *scp);
#ifdef GDTH_IOCTL_PROC #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Request *scp);
#endif
#elif LINUX_VERSION_CODE >= 0x020322
static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd, static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd,
char *cmnd, int timeout); char *cmnd, int timeout);
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp); static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp);
#ifdef GDTH_IOCTL_PROC
static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp);
#endif
#else #else
static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd, static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *cmd,
char *cmnd, int timeout); char *cmnd, int timeout);
static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp); static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp);
#ifdef GDTH_IOCTL_PROC
static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd scp);
#endif
#endif #endif
static char *gdth_ioctl_alloc(int hanum, int size, int scratch, static char *gdth_ioctl_alloc(int hanum, int size, int scratch,
ulong32 *paddr); ulong64 *paddr);
static void gdth_ioctl_free(int hanum, int size, char *buf, ulong32 paddr); static void gdth_ioctl_free(int hanum, int size, char *buf, ulong64 paddr);
#ifdef GDTH_IOCTL_PROC
static int gdth_ioctl_check_bin(int hanum, ushort size);
#endif
static void gdth_wait_completion(int hanum, int busnum, int id); static void gdth_wait_completion(int hanum, int busnum, int id);
static void gdth_stop_timeout(int hanum, int busnum, int id); static void gdth_stop_timeout(int hanum, int busnum, int id);
static void gdth_start_timeout(int hanum, int busnum, int id); static void gdth_start_timeout(int hanum, int busnum, int id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment