patch-2.4.5 linux/drivers/scsi/gdth_proc.c
Next file: linux/drivers/scsi/gdth_proc.h
Previous file: linux/drivers/scsi/gdth_ioctl.h
Back to the patch index
Back to the overall index
- Lines: 1058
- Date:
Sat May 19 17:43:06 2001
- Orig file:
v2.4.4/linux/drivers/scsi/gdth_proc.c
- Orig date:
Sat Nov 11 19:01:11 2000
diff -u --recursive --new-file v2.4.4/linux/drivers/scsi/gdth_proc.c linux/drivers/scsi/gdth_proc.c
@@ -1,5 +1,5 @@
/* gdth_proc.c
- * $Id: gdth_proc.c,v 1.13 1999/03/22 16:12:53 achim Exp $
+ * $Id: gdth_proc.c,v 1.27 2001/03/14 10:47:00 achim Exp $
*/
#include "gdth_ioctl.h"
@@ -31,27 +31,30 @@
static int gdth_set_info(char *buffer,int length,int vh,int hanum,int busnum)
{
int ret_val;
- Scsi_Cmnd * scp;
- Scsi_Device * sdev;
+#if LINUX_VERSION_CODE >= 0x020322
+ Scsi_Cmnd *scp;
+ Scsi_Device *sdev;
+#else
+ Scsi_Cmnd scp;
+ Scsi_Device sdev;
+#endif
gdth_iowr_str *piowr;
TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum));
piowr = (gdth_iowr_str *)buffer;
+#if LINUX_VERSION_CODE >= 0x020322
sdev = scsi_get_host_dev(gdth_ctr_vtab[vh]);
-
- if(sdev==NULL)
- return -ENOMEM;
-
scp = scsi_allocate_device(sdev, 1, FALSE);
-
- if(scp==NULL)
- {
- scsi_free_host_dev(sdev);
- return -ENOMEM;
- }
scp->cmd_len = 12;
scp->use_sg = 0;
+#else
+ memset(&sdev,0,sizeof(Scsi_Device));
+ memset(&scp, 0,sizeof(Scsi_Cmnd));
+ sdev.host = scp.host = gdth_ctr_vtab[vh];
+ sdev.id = scp.target = sdev.host->this_id;
+ scp.device = &sdev;
+#endif
if (length >= 4) {
if (strncmp(buffer,"gdth",4) == 0) {
@@ -61,20 +64,29 @@
} else if (piowr->magic == GDTIOCTL_MAGIC) {
ret_val = gdth_set_bin_info( buffer, length, hanum, scp );
} else {
- printk("GDT: Wrong signature: %6s\n",buffer);
+ 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");
ret_val = -EINVAL;
}
} else {
ret_val = -EINVAL;
}
-
+#if LINUX_VERSION_CODE >= 0x020322
scsi_release_command(scp);
scsi_free_host_dev(sdev);
-
+#endif
return ret_val;
}
-static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd * scp)
+#if LINUX_VERSION_CODE >= 0x020322
+static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd *scp)
+#else
+static int gdth_set_asc_info(char *buffer,int length,int hanum,Scsi_Cmnd scp)
+#endif
{
int orig_length, drive, wb_mode;
int i, found;
@@ -82,6 +94,10 @@
gdth_cmd_str gdtcmd;
gdth_cpar_str *pcpar;
+ char cmnd[MAX_COMMAND_SIZE];
+ memset(cmnd, 0xff, 12);
+ memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
+
TRACE2(("gdth_set_asc_info() ha %d\n",hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
orig_length = length + 5;
@@ -108,13 +124,15 @@
if (drive != -1 && i != drive)
continue;
found = TRUE;
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_FLUSH;
gdtcmd.u.cache.DeviceNo = i;
gdtcmd.u.cache.BlockNo = 1;
- gdtcmd.u.cache.sg_canz = 0;
- gdth_do_cmd(scp, &gdtcmd, 30);
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+#endif
}
}
if (!found)
@@ -159,7 +177,6 @@
return(-EBUSY);
pcpar = (gdth_cpar_str *)ha->pscratch;
memcpy( pcpar, &ha->cpar, sizeof(gdth_cpar_str) );
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_IOCTL;
gdtcmd.u.ioctl.p_param = virt_to_bus(pcpar);
@@ -167,7 +184,11 @@
gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
pcpar->write_back = wb_mode==1 ? 0:1;
- gdth_do_cmd(scp, &gdtcmd, 30);
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+#endif
gdth_ioctl_free(hanum);
printk("Done.\n");
return(orig_length);
@@ -177,17 +198,27 @@
return(-EINVAL);
}
-static int gdth_set_bin_info(char *buffer,int length,int hanum,Scsi_Cmnd * scp)
+#if 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;
- ulong32 *ppadd2, add_size2;
+ ulong32 *ppadd, add_size, *ppadd2, add_size2, info;
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]);
@@ -250,8 +281,13 @@
*ppadd2 = virt_to_bus(piord->iu.general.data+add_size);
}
/* do IOCTL */
- gdth_do_cmd(scp, pcmd, piowr->timeout);
- piord->status = (ulong32)scp->SCp.Message;
+#if 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:
@@ -371,10 +407,10 @@
pevt->event_data.size = sizeof(pevt->event_data.eu.async);
gdth_log_event(&pevt->event_data, NULL);
}
- GDTH_LOCK_HA(ha, flags);
+ GDTH_LOCK_HA(ha, flags);
gdth_store_event(ha, pevt->event_source, pevt->event_idx,
&pevt->event_data);
- GDTH_UNLOCK_HA(ha, flags);
+ GDTH_UNLOCK_HA(ha, flags);
} else if (piowr->iu.event.erase == 0xfe) {
gdth_clear_events();
} else if (piowr->iu.event.erase == 0) {
@@ -390,11 +426,236 @@
piord->status = S_OK;
break;
+ case GDTIOCTL_SCSI:
+ if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str) ))
+ 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
+ break;
+
+ case GDTIOCTL_RESET_BUS:
+ if (!gdth_ioctl_alloc( hanum, sizeof(gdth_iord_str) ))
+ return(-EBUSY);
+ piord = (gdth_iord_str *)ha->pscratch;
+ piord->size = sizeof(gdth_iord_str);
+#if 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) ))
+ 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 >= 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) ))
+ 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 >= 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 >= 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 >= 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 >= 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 >= 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) ))
+ 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 >= 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);
}
- /* we return a buffer ID to detect the right buffer during READ-IOCTL */
- return 1;
+ return length;
}
static int gdth_get_info(char *buffer,char **start,off_t offset,
@@ -410,8 +671,13 @@
gdth_cmd_str gdtcmd;
gdth_evt_str estr;
- Scsi_Cmnd * scp;
+#if LINUX_VERSION_CODE >= 0x020322
+ Scsi_Cmnd *scp;
Scsi_Device *sdev;
+#else
+ Scsi_Cmnd scp;
+ Scsi_Device sdev;
+#endif
char hrec[161];
struct timeval tv;
@@ -422,17 +688,28 @@
gdth_cdrinfo_str *pcdi;
gdth_hget_str *phg;
+ char cmnd[MAX_COMMAND_SIZE];
+ memset(cmnd, 0xff, 12);
+ memset(&gdtcmd, 0, sizeof(gdth_cmd_str));
+
TRACE2(("gdth_get_info() ha %d bus %d\n",hanum,busnum));
ha = HADATA(gdth_ctr_tab[hanum]);
- id = length;
+#if LINUX_VERSION_CODE >= 0x020322
sdev = scsi_get_host_dev(gdth_ctr_vtab[vh]);
scp = scsi_allocate_device(sdev, 1, FALSE);
scp->cmd_len = 12;
scp->use_sg = 0;
+#else
+ memset(&sdev,0,sizeof(Scsi_Device));
+ memset(&scp, 0,sizeof(Scsi_Cmnd));
+ sdev.host = scp.host = gdth_ctr_vtab[vh];
+ sdev.id = scp.target = sdev.host->this_id;
+ scp.device = &sdev;
+#endif
- /* look for buffer ID in length */
- if (id > 1) {
+ /* ioctl from tool? */
+ if (!gdth_ioctl_check_bin(hanum, (ushort)length)) {
/* request is i.e. "cat /proc/scsi/gdth/0" */
/* format: %-15s\t%-10s\t%-15s\t%s */
/* driver parameters */
@@ -457,17 +734,13 @@
max_ids, hdr_channel);
len += size; pos = begin + len;
- if (pos < offset) {
- len = 0;
- begin = pos;
- }
- if (pos > offset + length)
- goto stop_output;
-
/* controller information */
size = sprintf(buffer+len,"\nDisk Array Controller Information:\n");
len += size; pos = begin + len;
- strcpy(hrec, ha->binfo.type_string);
+ if (virt_ctr)
+ sprintf(hrec, "%s (Bus %d)", ha->binfo.type_string, busnum);
+ else
+ strcpy(hrec, ha->binfo.type_string);
size = sprintf(buffer+len,
" Number: \t%d \tName: \t%s\n",
hanum, hrec);
@@ -503,17 +776,10 @@
ha->binfo.ser_no, ha->binfo.memsize / 1024);
len += size; pos = begin + len;
- if (pos < offset) {
- len = 0;
- begin = pos;
- }
- if (pos > offset + length)
- goto stop_output;
-
/* 2. about physical devices */
size = sprintf(buffer+len,"\nPhysical Devices:");
len += size; pos = begin + len;
- flag = FALSE;
+ flag = FALSE;
if (!gdth_ioctl_alloc(hanum, GDTH_SCRATCH))
goto stop_output;
@@ -521,7 +787,6 @@
/* 2.a statistics (and retries/reassigns) */
TRACE2(("pdr_statistics() chn %d\n",i));
pds = (gdth_dskstat_str *)(ha->pscratch + GDTH_SCRATCH/4);
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_IOCTL;
gdtcmd.u.ioctl.p_param = virt_to_bus(pds);
@@ -535,11 +800,16 @@
sizeof(pds->list[0]);
if (pds->entries > cnt)
pds->entries = cnt;
- gdth_do_cmd(scp, &gdtcmd, 30);
- if (scp->SCp.Message != S_OK)
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if (scp->SCp.Status != S_OK)
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+ if (scp.SCp.Status != S_OK)
+#endif
+ {
pds->count = 0;
- TRACE2(("pdr_statistics() entries %d status %d\n",
- pds->count, scp->SCp.Message));
+ }
/* other IOCTLs must fit into area GDTH_SCRATCH/4 */
for (j = 0; j < ha->raw[i].pdev_cnt; ++j) {
@@ -547,7 +817,6 @@
TRACE2(("scsi_drv_info() chn %d dev %d\n",
i, ha->raw[i].id_list[j]));
pdi = (gdth_diskinfo_str *)ha->pscratch;
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_IOCTL;
gdtcmd.u.ioctl.p_param = virt_to_bus(pdi);
@@ -555,8 +824,14 @@
gdtcmd.u.ioctl.subfunc = SCSI_DR_INFO | L_CTRL_PATTERN;
gdtcmd.u.ioctl.channel =
ha->raw[i].address | ha->raw[i].id_list[j];
- gdth_do_cmd(scp, &gdtcmd, 30);
- if (scp->SCp.Message == S_OK) {
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if (scp->SCp.Status == S_OK)
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+ if (scp.SCp.Status == S_OK)
+#endif
+ {
strncpy(hrec,pdi->vendor,8);
strncpy(hrec+8,pdi->product,16);
strncpy(hrec+24,pdi->revision,4);
@@ -565,7 +840,7 @@
"\n Chn/ID/LUN: \t%c/%02d/%d \tName: \t%s\n",
'A'+i,pdi->target_id,pdi->lun,hrec);
len += size; pos = begin + len;
- flag = TRUE;
+ flag = TRUE;
pdi->no_ldrive &= 0xffff;
if (pdi->no_ldrive == 0xffff)
strcpy(hrec,"--");
@@ -597,7 +872,6 @@
TRACE2(("scsi_drv_defcnt() chn %d dev %d\n",
i, ha->raw[i].id_list[j]));
pdef = (gdth_defcnt_str *)ha->pscratch;
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_IOCTL;
gdtcmd.u.ioctl.p_param = virt_to_bus(pdef);
@@ -606,37 +880,43 @@
gdtcmd.u.ioctl.channel =
ha->raw[i].address | ha->raw[i].id_list[j];
pdef->sddc_type = 0x08;
- gdth_do_cmd(scp, &gdtcmd, 30);
- if (scp->SCp.Message == S_OK) {
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if (scp->SCp.Status == S_OK)
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+ if (scp.SCp.Status == S_OK)
+#endif
+ {
size = sprintf(buffer+len,
" Grown Defects:\t%d\n",
pdef->sddc_cnt);
len += size; pos = begin + len;
}
}
+ if (pos < offset) {
+ len = 0;
+ begin = pos;
+ }
+ if (pos > offset + length)
+ goto stop_output;
}
}
gdth_ioctl_free(hanum);
- if (!flag) {
- size = sprintf(buffer+len, "\n --\n");
- len += size; pos = begin + len;
- }
- if (pos < offset) {
- len = 0;
- begin = pos;
+ if (!flag) {
+ size = sprintf(buffer+len, "\n --\n");
+ len += size; pos = begin + len;
}
- if (pos > offset + length)
- goto stop_output;
/* 3. about logical drives */
size = sprintf(buffer+len,"\nLogical Drives:");
len += size; pos = begin + len;
- flag = FALSE;
+ flag = FALSE;
if (!gdth_ioctl_alloc(hanum, GDTH_SCRATCH))
goto stop_output;
- for (i = 0; i < MAX_HDRIVES; ++i) {
+ for (i = 0; i < MAX_LDRIVES; ++i) {
if (!ha->hdr[i].is_logdrv)
continue;
drv_no = i;
@@ -646,16 +926,22 @@
/* 3.a log. drive info */
TRACE2(("cache_drv_info() drive no %d\n",drv_no));
pcdi = (gdth_cdrinfo_str *)ha->pscratch;
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_IOCTL;
gdtcmd.u.ioctl.p_param = virt_to_bus(pcdi);
gdtcmd.u.ioctl.param_size = sizeof(gdth_cdrinfo_str);
gdtcmd.u.ioctl.subfunc = CACHE_DRV_INFO;
gdtcmd.u.ioctl.channel = drv_no;
- gdth_do_cmd(scp, &gdtcmd, 30);
- if (scp->SCp.Message != S_OK)
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if (scp->SCp.Status != S_OK)
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+ if (scp.SCp.Status != S_OK)
+#endif
+ {
break;
+ }
pcdi->ld_dtype >>= 16;
j++;
if (pcdi->ld_dtype > 2) {
@@ -674,7 +960,7 @@
"\n Number: \t%-2d \tStatus: \t%s\n",
drv_no, hrec);
len += size; pos = begin + len;
- flag = TRUE;
+ flag = TRUE;
no_mdrv = pcdi->cd_ldcnt;
if (no_mdrv > 1 || pcdi->ld_slave != -1) {
is_mirr = TRUE;
@@ -700,6 +986,12 @@
len += size; pos = begin + len;
}
drv_no = pcdi->ld_slave;
+ if (pos < offset) {
+ len = 0;
+ begin = pos;
+ }
+ if (pos > offset + length)
+ goto stop_output;
} while (drv_no != -1);
if (is_mirr) {
@@ -716,42 +1008,47 @@
size = sprintf(buffer+len,
" To Array Drv.:\t%s\n", hrec);
len += size; pos = begin + len;
+ if (pos < offset) {
+ len = 0;
+ begin = pos;
+ }
+ if (pos > offset + length)
+ goto stop_output;
}
gdth_ioctl_free(hanum);
- if (!flag) {
- size = sprintf(buffer+len, "\n --\n");
- len += size; pos = begin + len;
- }
- if (pos < offset) {
- len = 0;
- begin = pos;
- }
- if (pos > offset + length)
- goto stop_output;
+ if (!flag) {
+ size = sprintf(buffer+len, "\n --\n");
+ len += size; pos = begin + len;
+ }
/* 4. about array drives */
size = sprintf(buffer+len,"\nArray Drives:");
len += size; pos = begin + len;
- flag = FALSE;
+ flag = FALSE;
if (!gdth_ioctl_alloc(hanum, GDTH_SCRATCH))
goto stop_output;
- for (i = 0; i < MAX_HDRIVES; ++i) {
+ for (i = 0; i < MAX_LDRIVES; ++i) {
if (!(ha->hdr[i].is_arraydrv && ha->hdr[i].is_master))
continue;
/* 4.a array drive info */
TRACE2(("array_info() drive no %d\n",i));
pai = (gdth_arrayinf_str *)ha->pscratch;
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_IOCTL;
gdtcmd.u.ioctl.p_param = virt_to_bus(pai);
gdtcmd.u.ioctl.param_size = sizeof(gdth_arrayinf_str);
gdtcmd.u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN;
gdtcmd.u.ioctl.channel = i;
- gdth_do_cmd(scp, &gdtcmd, 30);
- if (scp->SCp.Message == S_OK) {
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if (scp->SCp.Status == S_OK)
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+ if (scp.SCp.Status == S_OK)
+#endif
+ {
if (pai->ai_state == 0)
strcpy(hrec, "idle");
else if (pai->ai_state == 2)
@@ -787,36 +1084,35 @@
pai->ai_size/(1024*1024/pai->ai_secsize),
hrec);
len += size; pos = begin + len;
+ if (pos < offset) {
+ len = 0;
+ begin = pos;
+ }
+ if (pos > offset + length)
+ goto stop_output;
}
}
gdth_ioctl_free(hanum);
- if (!flag) {
- size = sprintf(buffer+len, "\n --\n");
- len += size; pos = begin + len;
- }
- if (pos < offset) {
- len = 0;
- begin = pos;
+ if (!flag) {
+ size = sprintf(buffer+len, "\n --\n");
+ len += size; pos = begin + len;
}
- if (pos > offset + length)
- goto stop_output;
/* 5. about host drives */
size = sprintf(buffer+len,"\nHost Drives:");
len += size; pos = begin + len;
- flag = FALSE;
+ flag = FALSE;
if (!gdth_ioctl_alloc(hanum, GDTH_SCRATCH))
goto stop_output;
- for (i = 0; i < MAX_HDRIVES; ++i) {
+ for (i = 0; i < MAX_LDRIVES; ++i) {
if (!ha->hdr[i].is_logdrv ||
(ha->hdr[i].is_arraydrv && !ha->hdr[i].is_master))
continue;
/* 5.a get host drive list */
TRACE2(("host_get() drv_no %d\n",i));
phg = (gdth_hget_str *)ha->pscratch;
- gdtcmd.BoardNode = LOCALBOARD;
gdtcmd.Service = CACHESERVICE;
gdtcmd.OpCode = GDT_IOCTL;
gdtcmd.u.ioctl.p_param = virt_to_bus(phg);
@@ -825,23 +1121,27 @@
gdtcmd.u.ioctl.channel = i;
phg->entries = MAX_HDRIVES;
phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]);
- gdth_do_cmd(scp, &gdtcmd, 30);
- if (scp->SCp.Message != S_OK) {
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if (scp->SCp.Status != S_OK)
+#else
+ gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+ if (scp.SCp.Status != S_OK)
+#endif
+ {
ha->hdr[i].ldr_no = i;
ha->hdr[i].rw_attribs = 0;
ha->hdr[i].start_sec = 0;
} else {
for (j = 0; j < phg->entries; ++j) {
k = phg->entry[j].host_drive;
- if (k >= MAX_HDRIVES)
+ if (k >= MAX_LDRIVES)
continue;
ha->hdr[k].ldr_no = phg->entry[j].log_drive;
ha->hdr[k].rw_attribs = phg->entry[j].rw_attribs;
ha->hdr[k].start_sec = phg->entry[j].start_sec;
}
}
- TRACE2(("host_get entries %d status %d\n",
- phg->entries, scp->SCp.Message));
}
gdth_ioctl_free(hanum);
@@ -853,24 +1153,24 @@
"\n Number: \t%-2d \tArr/Log. Drive:\t%d\n",
i, ha->hdr[i].ldr_no);
len += size; pos = begin + len;
- flag = TRUE;
+ flag = TRUE;
size = sprintf(buffer+len,
" Capacity [MB]:\t%-6d \tStart Sector: \t%d\n",
ha->hdr[i].size/2048, ha->hdr[i].start_sec);
len += size; pos = begin + len;
+ if (pos < offset) {
+ len = 0;
+ begin = pos;
+ }
+ if (pos > offset + length)
+ goto stop_output;
}
- if (!flag) {
- size = sprintf(buffer+len, "\n --\n");
- len += size; pos = begin + len;
- }
- if (pos < offset) {
- len = 0;
- begin = pos;
+ if (!flag) {
+ size = sprintf(buffer+len, "\n --\n");
+ len += size; pos = begin + len;
}
- if (pos > offset + length)
- goto stop_output;
}
/* controller events */
@@ -886,7 +1186,7 @@
gdth_log_event(&estr.event_data, hrec);
do_gettimeofday(&tv);
sec = (int)(tv.tv_sec - estr.first_stamp);
- if (sec < 0) sec = 0;
+ if (sec < 0) sec = 0;
size = sprintf(buffer+len," date- %02d:%02d:%02d\t%s\n",
sec/3600, sec%3600/60, sec%60, hrec);
len += size; pos = begin + len;
@@ -908,21 +1208,14 @@
length = piord->size;
memcpy(buffer+len, (char *)piord, length);
gdth_ioctl_free(hanum);
- len += length; pos = begin + len;
-
- if (pos < offset) {
- len = 0;
- begin = pos;
- }
- if (pos > offset + length)
- goto stop_output;
+ len = length;
}
stop_output:
-
+#if LINUX_VERSION_CODE >= 0x020322
scsi_release_command(scp);
scsi_free_host_dev(sdev);
-
+#endif
*start = buffer +(offset-begin);
len -= (offset-begin);
if (len > length)
@@ -932,18 +1225,33 @@
return(len);
}
-static void gdth_do_cmd(Scsi_Cmnd *scp,gdth_cmd_str *gdtcmd,int timeout)
+static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd,
+ char *cmnd, int timeout)
{
- char cmnd[MAX_COMMAND_SIZE];
+ unsigned bufflen;
+#if LINUX_VERSION_CODE >= 0x020322
DECLARE_MUTEX_LOCKED(sem);
+#else
+ struct semaphore sem = MUTEX_LOCKED;
+#endif
TRACE2(("gdth_do_cmd()\n"));
- memset(cmnd, 0, MAX_COMMAND_SIZE);
+ if (gdtcmd != NULL) {
+ scp->SCp.this_residual = IOCTL_PRI;
+ bufflen = sizeof(gdth_cmd_str);
+ } else {
+ scp->SCp.this_residual = DEFAULT_PRI;
+ bufflen = 0;
+ }
scp->request.rq_status = RQ_SCSI_BUSY;
scp->request.sem = &sem;
- scp->SCp.this_residual = IOCTL_PRI;
- scsi_do_cmd(scp, cmnd, gdtcmd, sizeof(gdth_cmd_str),
- gdth_scsi_done, timeout*HZ, 1);
+#if LINUX_VERSION_CODE >= 0x020322
+ scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1);
+#else
+ GDTH_LOCK_SCSI_DOCMD();
+ scsi_do_cmd(scp, cmnd, gdtcmd, bufflen, gdth_scsi_done, timeout*HZ, 1);
+ GDTH_UNLOCK_SCSI_DOCMD();
+#endif
down(&sem);
}
@@ -992,21 +1300,41 @@
GDTH_UNLOCK_HA(ha, flags);
}
+static int gdth_ioctl_check_bin(int hanum, ushort size)
+{
+ gdth_ha_str *ha;
+ ulong flags;
+ int ret_val;
+
+ ha = HADATA(gdth_ctr_tab[hanum]);
+ GDTH_LOCK_HA(ha, flags);
+
+ ret_val = FALSE;
+ if (ha->scratch_busy) {
+ if (((gdth_iord_str *)ha->pscratch)->size == (ulong32)size)
+ ret_val = TRUE;
+ }
+ GDTH_UNLOCK_HA(ha, flags);
+ return ret_val;
+}
+
+
static void gdth_wait_completion(int hanum, int busnum, int id)
{
gdth_ha_str *ha;
ulong flags;
int i;
Scsi_Cmnd *scp;
+ unchar b;
ha = HADATA(gdth_ctr_tab[hanum]);
GDTH_LOCK_HA(ha, flags);
for (i = 0; i < GDTH_MAXCMDS; ++i) {
scp = ha->cmd_tab[i].cmnd;
- if (!SPECIAL_SCP(scp) && scp->target == (unchar)id &&
- scp->channel == (unchar)busnum)
- {
+ b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel;
+ if (!SPECIAL_SCP(scp) && scp->target == (unchar)id &&
+ b == (unchar)busnum) {
scp->SCp.have_data_in = 0;
GDTH_UNLOCK_HA(ha, flags);
while (!scp->SCp.have_data_in)
@@ -1025,14 +1353,14 @@
gdth_ha_str *ha;
ulong flags;
Scsi_Cmnd *scp;
+ unchar b;
ha = HADATA(gdth_ctr_tab[hanum]);
GDTH_LOCK_HA(ha, flags);
for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
- if (scp->target == (unchar)id &&
- scp->channel == (unchar)busnum)
- {
+ b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel;
+ if (scp->target == (unchar)id && b == (unchar)busnum) {
TRACE2(("gdth_stop_timeout(): update_timeout()\n"));
scp->SCp.buffers_residual = gdth_update_timeout(hanum, scp, 0);
}
@@ -1045,14 +1373,14 @@
gdth_ha_str *ha;
ulong flags;
Scsi_Cmnd *scp;
+ unchar b;
ha = HADATA(gdth_ctr_tab[hanum]);
GDTH_LOCK_HA(ha, flags);
for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
- if (scp->target == (unchar)id &&
- scp->channel == (unchar)busnum)
- {
+ b = virt_ctr ? NUMDATA(scp->host)->busnum : scp->channel;
+ if (scp->target == (unchar)id && b == (unchar)busnum) {
TRACE2(("gdth_start_timeout(): update_timeout()\n"));
gdth_update_timeout(hanum, scp, scp->SCp.buffers_residual);
}
@@ -1067,6 +1395,7 @@
oldto = scp->timeout_per_command;
scp->timeout_per_command = timeout;
+#if LINUX_VERSION_CODE >= 0x02014B
if (timeout == 0) {
del_timer(&scp->eh_timeout);
scp->eh_timeout.data = (unsigned long) NULL;
@@ -1078,5 +1407,17 @@
scp->eh_timeout.expires = jiffies + 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;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)