patch-2.2.18 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: 578
- Date:
Mon Jul 24 10:32:20 2000
- Orig file:
v2.2.17/drivers/scsi/gdth_proc.c
- Orig date:
Fri Apr 21 12:46:28 2000
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.17/drivers/scsi/gdth_proc.c linux/drivers/scsi/gdth_proc.c
@@ -1,5 +1,5 @@
/* gdth_proc.c
- * $Id: gdth_proc.c,v 1.16 1999/11/02 13:44:11 achim Exp $
+ * $Id: gdth_proc.c,v 1.22 2000/07/24 09:30:28 achim Exp $
*/
#include "gdth_ioctl.h"
@@ -31,18 +31,30 @@
static int gdth_set_info(char *buffer,int length,int vh,int hanum,int busnum)
{
int ret_val;
+#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]);
+ 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
if (length >= 4) {
if (strncmp(buffer,"gdth",4) == 0) {
@@ -52,23 +64,33 @@
} 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\n",piowr->magic);
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;
}
+#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;
gdth_ha_str *ha;
gdth_cmd_str gdtcmd;
gdth_cpar_str *pcpar;
- char cmnd[12];
+
+ char cmnd[MAX_COMMAND_SIZE];
+ memset(cmnd, 0xff, 12);
TRACE2(("gdth_set_asc_info() ha %d\n",hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
@@ -76,7 +98,6 @@
drive = -1;
wb_mode = 0;
found = FALSE;
- memset(cmnd, 0xff, 12);
if (length >= 5 && strncmp(buffer,"flush",5)==0) {
buffer += 6;
@@ -103,7 +124,11 @@
gdtcmd.u.cache.DeviceNo = i;
gdtcmd.u.cache.BlockNo = 1;
gdtcmd.u.cache.sg_canz = 0;
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
+#endif
}
}
if (!found)
@@ -156,7 +181,11 @@
gdtcmd.u.ioctl.subfunc = CACHE_CONFIG;
gdtcmd.u.ioctl.channel = INVALID_CHANNEL;
pcpar->write_back = wb_mode==1 ? 0:1;
+#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);
@@ -166,9 +195,14 @@
return(-EINVAL);
}
+#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;
gdth_ha_str *ha;
gdth_iowr_str *piowr;
gdth_iord_str *piord;
@@ -177,9 +211,11 @@
ulong32 *ppadd, add_size;
ulong32 *ppadd2, add_size2;
ulong flags;
- char cmnd[12];
gdth_cmd_str gdtcmd;
+ char cmnd[MAX_COMMAND_SIZE];
+ memset(cmnd, 0xff, 12);
+
TRACE2(("gdth_set_bin_info() ha %d\n",hanum));
ha = HADATA(gdth_ctr_tab[hanum]);
piowr = (gdth_iowr_str *)buffer;
@@ -187,7 +223,6 @@
pcmd = NULL;
ppadd = ppadd2 = NULL;
add_size = add_size2 = 0;
- memset(cmnd, 0xff, 12);
if (length < GDTOFFSOF(gdth_iowr_str,iu))
return(-EINVAL);
@@ -242,8 +277,13 @@
*ppadd2 = virt_to_bus(piord->iu.general.data+add_size);
}
/* do IOCTL */
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, pcmd, cmnd, piowr->timeout);
+ piord->status = (ulong32)scp->SCp.Message;
+#else
gdth_do_cmd(&scp, pcmd, cmnd, piowr->timeout);
piord->status = (ulong32)scp.SCp.Message;
+#endif
break;
case GDTIOCTL_DRVERS:
@@ -387,12 +427,20 @@
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
- scp.target = scp.device->id = piowr->iu.scsi.target;
- scp.channel = scp.device->channel = piowr->iu.scsi.bus;
memcpy(cmnd, piowr->iu.scsi.cmd, 12);
+#if LINUX_VERSION_CODE >= 0x020322
+ scp->target = scp->device->id = piowr->iu.scsi.target;
+ scp->channel = scp->device->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 = (ulong32)scp->SCp.Message;
+#else
+ scp.target = scp.device->id = piowr->iu.scsi.target;
+ scp.channel = scp.device->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 = (ulong32)scp.result;
+ piord->status = (ulong32)scp.SCp.Message;
+#endif
break;
case GDTIOCTL_RESET_BUS:
@@ -400,8 +448,23 @@
return(-EBUSY);
piord = (gdth_iord_str *)ha->pscratch;
piord->size = sizeof(gdth_iord_str);
- scp.channel = scp.device->channel = piowr->iu.scsi.bus;
+#if LINUX_VERSION_CODE >= 0x020322
+ scp->channel = scp->device->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 = scp.device->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:
@@ -423,22 +486,50 @@
gdtcmd.u.cache.DeviceNo = i;
gdtcmd.u.cache.BlockNo = 0;
gdtcmd.u.cache.sg_canz = 0;
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if ((scp->SCp.Message & 0xffff) == S_OK)
+ piord->iu.hdr_list[i].cluster_type =
+ (unchar)(scp->SCp.Message>>16);
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
if ((scp.SCp.Message & 0xffff) == S_OK)
piord->iu.hdr_list[i].cluster_type =
(unchar)(scp.SCp.Message>>16);
- }
+#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;
+ GDTH_LOCK_HA(ha, flags);
+ gdth_polling = TRUE;
+ while (gdth_test_busy(hanum))
+ gdth_delay(0);
+ /* initialize cache service */
+ gdth_internal_cmd(hanum,CACHESERVICE,GDT_INIT,LINUX_OS,0,0);
+ hdr_cnt = (ushort)ha->info;
+ /* scanning for host drives */
+ for (k = 0; k < MAX_HDRIVES; ++k)
+ ha->hdr[k].present = FALSE;
+ for (k = 0; k < hdr_cnt; ++k)
+ gdth_analyse_hdrive(hanum, k);
+ gdth_polling = FALSE;
+ GDTH_UNLOCK_HA(ha, flags);
+ 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,
@@ -454,9 +545,13 @@
gdth_cmd_str gdtcmd;
gdth_evt_str estr;
+#if LINUX_VERSION_CODE >= 0x020322
+ Scsi_Cmnd *scp;
+ Scsi_Device *sdev;
+#else
Scsi_Cmnd scp;
Scsi_Device sdev;
- char cmnd[12];
+#endif
char hrec[161];
struct timeval tv;
@@ -467,19 +562,27 @@
gdth_cdrinfo_str *pcdi;
gdth_hget_str *phg;
+ char cmnd[MAX_COMMAND_SIZE];
+ memset(cmnd, 0xff, 12);
+
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));
- memset(cmnd, 0xff, 12);
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 */
@@ -514,11 +617,10 @@
/* controller information */
size = sprintf(buffer+len,"\nDisk Array Controller Information:\n");
len += size; pos = begin + len;
-#if LINUX_VERSION_CODE >= 0x020000
- strcpy(hrec, ha->binfo.type_string);
-#else
- sprintf(hrec, "%s (Bus %d)", ha->binfo.type_string, busnum);
-#endif
+ 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);
@@ -586,11 +688,16 @@
sizeof(pds->list[0]);
if (pds->entries > cnt)
pds->entries = cnt;
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if ((scp->SCp.Message & 0xffff) != S_OK)
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
if ((scp.SCp.Message & 0xffff) != 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) {
@@ -606,8 +713,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];
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if ((scp->SCp.Message & 0xffff) == S_OK)
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
- if ((scp.SCp.Message & 0xffff) == S_OK) {
+ if ((scp.SCp.Message & 0xffff) == S_OK)
+#endif
+ {
strncpy(hrec,pdi->vendor,8);
strncpy(hrec+8,pdi->product,16);
strncpy(hrec+24,pdi->revision,4);
@@ -657,8 +770,14 @@
gdtcmd.u.ioctl.channel =
ha->raw[i].address | ha->raw[i].id_list[j];
pdef->sddc_type = 0x08;
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if ((scp->SCp.Message & 0xffff) == S_OK)
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
- if ((scp.SCp.Message & 0xffff) == S_OK) {
+ if ((scp.SCp.Message & 0xffff) == S_OK)
+#endif
+ {
size = sprintf(buffer+len,
" Grown Defects:\t%d\n",
pdef->sddc_cnt);
@@ -704,9 +823,16 @@
gdtcmd.u.ioctl.param_size = sizeof(gdth_cdrinfo_str);
gdtcmd.u.ioctl.subfunc = CACHE_DRV_INFO;
gdtcmd.u.ioctl.channel = drv_no;
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if ((scp->SCp.Message & 0xffff) != S_OK)
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
if ((scp.SCp.Message & 0xffff) != S_OK)
+#endif
+ {
break;
+ }
pcdi->ld_dtype >>= 16;
j++;
if (pcdi->ld_dtype > 2) {
@@ -801,8 +927,14 @@
gdtcmd.u.ioctl.param_size = sizeof(gdth_arrayinf_str);
gdtcmd.u.ioctl.subfunc = ARRAY_INFO | LA_CTRL_PATTERN;
gdtcmd.u.ioctl.channel = i;
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if ((scp->SCp.Message & 0xffff) == S_OK)
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
- if ((scp.SCp.Message & 0xffff) == S_OK) {
+ if ((scp.SCp.Message & 0xffff) == S_OK)
+#endif
+ {
if (pai->ai_state == 0)
strcpy(hrec, "idle");
else if (pai->ai_state == 2)
@@ -876,8 +1008,14 @@
gdtcmd.u.ioctl.channel = i;
phg->entries = MAX_HDRIVES;
phg->offset = GDTOFFSOF(gdth_hget_str, entry[0]);
+#if LINUX_VERSION_CODE >= 0x020322
+ gdth_do_cmd(scp, &gdtcmd, cmnd, 30);
+ if ((scp->SCp.Message & 0xffff) != S_OK)
+#else
gdth_do_cmd(&scp, &gdtcmd, cmnd, 30);
- if ((scp.SCp.Message & 0xffff) != S_OK) {
+ if ((scp.SCp.Message & 0xffff) != S_OK)
+#endif
+ {
ha->hdr[i].ldr_no = i;
ha->hdr[i].rw_attribs = 0;
ha->hdr[i].start_sec = 0;
@@ -891,8 +1029,6 @@
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);
@@ -959,17 +1095,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)
@@ -982,8 +1115,12 @@
static void gdth_do_cmd(Scsi_Cmnd *scp, gdth_cmd_str *gdtcmd,
char *cmnd, int timeout)
{
- struct semaphore sem = MUTEX_LOCKED;
unsigned bufflen;
+#if LINUX_VERSION_CODE >= 0x020322
+ DECLARE_MUTEX_LOCKED(sem);
+#else
+ struct semaphore sem = MUTEX_LOCKED;
+#endif
TRACE2(("gdth_do_cmd()\n"));
if (gdtcmd != NULL) {
@@ -995,9 +1132,13 @@
}
scp->request.rq_status = RQ_SCSI_BUSY;
scp->request.sem = &sem;
+#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);
}
@@ -1046,26 +1187,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 LINUX_VERSION_CODE >= 0x020000
- if (!SPECIAL_SCP(scp) && scp->target == (unchar)id &&
- scp->channel == (unchar)busnum)
-#else
- if (!SPECIAL_SCP(scp) && scp->target == (unchar)id &&
- NUMDATA(scp->host)->busnum == (unchar)busnum)
-#endif
- {
+ 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)
@@ -1084,19 +1240,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 LINUX_VERSION_CODE >= 0x020000
- if (scp->target == (unchar)id &&
- scp->channel == (unchar)busnum)
-#else
- if (scp->target == (unchar)id &&
- NUMDATA(scp->host)->busnum == (unchar)busnum)
-#endif
- {
+ 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);
}
@@ -1109,19 +1260,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 LINUX_VERSION_CODE >= 0x020000
- if (scp->target == (unchar)id &&
- scp->channel == (unchar)busnum)
-#else
- if (scp->target == (unchar)id &&
- NUMDATA(scp->host)->busnum == (unchar)busnum)
-#endif
- {
+ 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);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)