2 * Disk Array driver for Compaq SA53xx Controllers, SCSI Tape module
3 * Copyright 2001 Compaq Computer Corporation
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
13 * NON INFRINGEMENT. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 * Questions/Comments/Bugfixes to iss_storagedev@hp.com
21 * Author: Stephen M. Cameron
23 #ifdef CONFIG_CISS_SCSI_TAPE
25 /* Here we have code to present the driver as a scsi driver
26 as it is simultaneously presented as a block driver. The
27 reason for doing this is to allow access to SCSI tape drives
28 through the array controller. Note in particular, neither
29 physical nor logical disks are presented through the scsi layer. */
31 #include <linux/timer.h>
32 #include <linux/completion.h>
33 #include <linux/slab.h>
34 #include <linux/string.h>
36 #include <asm/atomic.h>
38 #include <scsi/scsi.h>
39 #include <scsi/scsi_cmnd.h>
40 #include <scsi/scsi_device.h>
41 #include <scsi/scsi_host.h>
43 #include "cciss_scsi.h"
45 /* some prototypes... */
51 unsigned int use_unit_num, /* 0: address the controller,
52 1: address logical volume log_unit,
53 2: address is in scsi3addr */
54 unsigned int log_unit,
56 unsigned char *scsi3addr,
60 static int cciss_scsi_proc_info(
62 char *buffer, /* data buffer */
63 char **start, /* where data in buffer starts */
64 off_t offset, /* offset from start of imaginary file */
65 int length, /* length of data in buffer */
66 int func); /* 0 == read, 1 == write */
68 static int cciss_scsi_queue_command (struct scsi_cmnd *cmd,
69 void (* done)(struct scsi_cmnd *));
71 static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = {
72 { .name = "cciss0", .ndevices = 0 },
73 { .name = "cciss1", .ndevices = 0 },
74 { .name = "cciss2", .ndevices = 0 },
75 { .name = "cciss3", .ndevices = 0 },
76 { .name = "cciss4", .ndevices = 0 },
77 { .name = "cciss5", .ndevices = 0 },
78 { .name = "cciss6", .ndevices = 0 },
79 { .name = "cciss7", .ndevices = 0 },
82 static struct scsi_host_template cciss_driver_template = {
83 .module = THIS_MODULE,
86 .proc_info = cciss_scsi_proc_info,
87 .queuecommand = cciss_scsi_queue_command,
88 .can_queue = SCSI_CCISS_CAN_QUEUE,
90 .sg_tablesize = MAXSGENTRIES,
92 .use_clustering = DISABLE_CLUSTERING,
96 struct cciss_scsi_cmd_stack_elem_t {
97 CommandList_struct cmd;
105 #define CMD_STACK_SIZE (SCSI_CCISS_CAN_QUEUE * \
106 CCISS_MAX_SCSI_DEVS_PER_HBA + 2)
107 // plus two for init time usage
110 struct cciss_scsi_cmd_stack_t {
111 struct cciss_scsi_cmd_stack_elem_t *pool;
112 struct cciss_scsi_cmd_stack_elem_t *elem[CMD_STACK_SIZE];
113 dma_addr_t cmd_pool_handle;
118 struct cciss_scsi_adapter_data_t {
119 struct Scsi_Host *scsi_host;
120 struct cciss_scsi_cmd_stack_t cmd_stack;
122 spinlock_t lock; // to protect ccissscsi[ctlr];
125 #define CPQ_TAPE_LOCK(ctlr, flags) spin_lock_irqsave( \
126 &(((struct cciss_scsi_adapter_data_t *) \
127 hba[ctlr]->scsi_ctlr)->lock), flags);
128 #define CPQ_TAPE_UNLOCK(ctlr, flags) spin_unlock_irqrestore( \
129 &(((struct cciss_scsi_adapter_data_t *) \
130 hba[ctlr]->scsi_ctlr)->lock), flags);
132 static CommandList_struct *
133 scsi_cmd_alloc(ctlr_info_t *h)
135 /* assume only one process in here at a time, locking done by caller. */
136 /* use CCISS_LOCK(ctlr) */
137 /* might be better to rewrite how we allocate scsi commands in a way that */
138 /* needs no locking at all. */
140 /* take the top memory chunk off the stack and return it, if any. */
141 struct cciss_scsi_cmd_stack_elem_t *c;
142 struct cciss_scsi_adapter_data_t *sa;
143 struct cciss_scsi_cmd_stack_t *stk;
146 sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr;
147 stk = &sa->cmd_stack;
151 c = stk->elem[stk->top];
152 /* memset(c, 0, sizeof(*c)); */
153 memset(&c->cmd, 0, sizeof(c->cmd));
154 memset(&c->Err, 0, sizeof(c->Err));
155 /* set physical addr of cmd and addr of scsi parameters */
156 c->cmd.busaddr = c->busaddr;
157 /* (__u32) (stk->cmd_pool_handle +
158 (sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top)); */
160 temp64.val = (__u64) (c->busaddr + sizeof(CommandList_struct));
161 /* (__u64) (stk->cmd_pool_handle +
162 (sizeof(struct cciss_scsi_cmd_stack_elem_t)*stk->top) +
163 sizeof(CommandList_struct)); */
165 c->cmd.ErrDesc.Addr.lower = temp64.val32.lower;
166 c->cmd.ErrDesc.Addr.upper = temp64.val32.upper;
167 c->cmd.ErrDesc.Len = sizeof(ErrorInfo_struct);
169 c->cmd.ctlr = h->ctlr;
170 c->cmd.err_info = &c->Err;
172 return (CommandList_struct *) c;
176 scsi_cmd_free(ctlr_info_t *h, CommandList_struct *cmd)
178 /* assume only one process in here at a time, locking done by caller. */
179 /* use CCISS_LOCK(ctlr) */
180 /* drop the free memory chunk on top of the stack. */
182 struct cciss_scsi_adapter_data_t *sa;
183 struct cciss_scsi_cmd_stack_t *stk;
185 sa = (struct cciss_scsi_adapter_data_t *) h->scsi_ctlr;
186 stk = &sa->cmd_stack;
187 if (stk->top >= CMD_STACK_SIZE) {
188 printk("cciss: scsi_cmd_free called too many times.\n");
192 stk->elem[stk->top] = (struct cciss_scsi_cmd_stack_elem_t *) cmd;
196 scsi_cmd_stack_setup(int ctlr, struct cciss_scsi_adapter_data_t *sa)
199 struct cciss_scsi_cmd_stack_t *stk;
202 stk = &sa->cmd_stack;
203 size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE;
205 // pci_alloc_consistent guarantees 32-bit DMA address will
208 stk->pool = (struct cciss_scsi_cmd_stack_elem_t *)
209 pci_alloc_consistent(hba[ctlr]->pdev, size, &stk->cmd_pool_handle);
211 if (stk->pool == NULL) {
212 printk("stk->pool is null\n");
216 for (i=0; i<CMD_STACK_SIZE; i++) {
217 stk->elem[i] = &stk->pool[i];
218 stk->elem[i]->busaddr = (__u32) (stk->cmd_pool_handle +
219 (sizeof(struct cciss_scsi_cmd_stack_elem_t) * i));
221 stk->top = CMD_STACK_SIZE-1;
226 scsi_cmd_stack_free(int ctlr)
228 struct cciss_scsi_adapter_data_t *sa;
229 struct cciss_scsi_cmd_stack_t *stk;
232 sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr;
233 stk = &sa->cmd_stack;
234 if (stk->top != CMD_STACK_SIZE-1) {
235 printk( "cciss: %d scsi commands are still outstanding.\n",
236 CMD_STACK_SIZE - stk->top);
238 printk("WE HAVE A BUG HERE!!! stk=0x%p\n", stk);
240 size = sizeof(struct cciss_scsi_cmd_stack_elem_t) * CMD_STACK_SIZE;
242 pci_free_consistent(hba[ctlr]->pdev, size, stk->pool, stk->cmd_pool_handle);
246 /* scsi_device_types comes from scsi.h */
247 #define DEVICETYPE(n) (n<0 || n>MAX_SCSI_DEVICE_CODE) ? \
248 "Unknown" : scsi_device_types[n]
251 static int xmargin=8;
252 static int amargin=60;
255 print_bytes (unsigned char *c, int len, int hex, int ascii)
266 if ((i % xmargin) == 0 && i>0) printk("\n");
267 if ((i % xmargin) == 0) printk("0x%04x:", i);
278 if ((i % amargin) == 0 && i>0) printk("\n");
279 if ((i % amargin) == 0) printk("0x%04x:", i);
280 if (*x > 26 && *x < 128) printk("%c", *x);
289 print_cmd(CommandList_struct *cp)
291 printk("queue:%d\n", cp->Header.ReplyQueue);
292 printk("sglist:%d\n", cp->Header.SGList);
293 printk("sgtot:%d\n", cp->Header.SGTotal);
294 printk("Tag:0x%08x/0x%08x\n", cp->Header.Tag.upper,
295 cp->Header.Tag.lower);
296 printk("LUN:0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
297 cp->Header.LUN.LunAddrBytes[0],
298 cp->Header.LUN.LunAddrBytes[1],
299 cp->Header.LUN.LunAddrBytes[2],
300 cp->Header.LUN.LunAddrBytes[3],
301 cp->Header.LUN.LunAddrBytes[4],
302 cp->Header.LUN.LunAddrBytes[5],
303 cp->Header.LUN.LunAddrBytes[6],
304 cp->Header.LUN.LunAddrBytes[7]);
305 printk("CDBLen:%d\n", cp->Request.CDBLen);
306 printk("Type:%d\n",cp->Request.Type.Type);
307 printk("Attr:%d\n",cp->Request.Type.Attribute);
308 printk(" Dir:%d\n",cp->Request.Type.Direction);
309 printk("Timeout:%d\n",cp->Request.Timeout);
310 printk( "CDB: %02x %02x %02x %02x %02x %02x %02x %02x"
311 " %02x %02x %02x %02x %02x %02x %02x %02x\n",
312 cp->Request.CDB[0], cp->Request.CDB[1],
313 cp->Request.CDB[2], cp->Request.CDB[3],
314 cp->Request.CDB[4], cp->Request.CDB[5],
315 cp->Request.CDB[6], cp->Request.CDB[7],
316 cp->Request.CDB[8], cp->Request.CDB[9],
317 cp->Request.CDB[10], cp->Request.CDB[11],
318 cp->Request.CDB[12], cp->Request.CDB[13],
319 cp->Request.CDB[14], cp->Request.CDB[15]),
320 printk("edesc.Addr: 0x%08x/0%08x, Len = %d\n",
321 cp->ErrDesc.Addr.upper, cp->ErrDesc.Addr.lower,
323 printk("sgs..........Errorinfo:\n");
324 printk("scsistatus:%d\n", cp->err_info->ScsiStatus);
325 printk("senselen:%d\n", cp->err_info->SenseLen);
326 printk("cmd status:%d\n", cp->err_info->CommandStatus);
327 printk("resid cnt:%d\n", cp->err_info->ResidualCnt);
328 printk("offense size:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_size);
329 printk("offense byte:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_num);
330 printk("offense value:%d\n", cp->err_info->MoreErrInfo.Invalid_Cmd.offense_value);
337 find_bus_target_lun(int ctlr, int *bus, int *target, int *lun)
339 /* finds an unused bus, target, lun for a new device */
340 /* assumes hba[ctlr]->scsi_ctlr->lock is held */
342 unsigned char target_taken[CCISS_MAX_SCSI_DEVS_PER_HBA];
344 memset(&target_taken[0], 0, CCISS_MAX_SCSI_DEVS_PER_HBA);
346 target_taken[SELF_SCSI_ID] = 1;
347 for (i=0;i<ccissscsi[ctlr].ndevices;i++)
348 target_taken[ccissscsi[ctlr].dev[i].target] = 1;
350 for (i=0;i<CCISS_MAX_SCSI_DEVS_PER_HBA;i++) {
351 if (!target_taken[i]) {
352 *bus = 0; *target=i; *lun = 0; found=1;
360 cciss_scsi_add_entry(int ctlr, int hostno,
361 unsigned char *scsi3addr, int devtype)
363 /* assumes hba[ctlr]->scsi_ctlr->lock is held */
364 int n = ccissscsi[ctlr].ndevices;
365 struct cciss_scsi_dev_t *sd;
367 if (n >= CCISS_MAX_SCSI_DEVS_PER_HBA) {
368 printk("cciss%d: Too many devices, "
369 "some will be inaccessible.\n", ctlr);
372 sd = &ccissscsi[ctlr].dev[n];
373 if (find_bus_target_lun(ctlr, &sd->bus, &sd->target, &sd->lun) != 0)
375 memcpy(&sd->scsi3addr[0], scsi3addr, 8);
376 sd->devtype = devtype;
377 ccissscsi[ctlr].ndevices++;
379 /* initially, (before registering with scsi layer) we don't
380 know our hostno and we don't want to print anything first
381 time anyway (the scsi layer's inquiries will show that info) */
383 printk("cciss%d: %s device c%db%dt%dl%d added.\n",
384 ctlr, DEVICETYPE(sd->devtype), hostno,
385 sd->bus, sd->target, sd->lun);
390 cciss_scsi_remove_entry(int ctlr, int hostno, int entry)
392 /* assumes hba[ctlr]->scsi_ctlr->lock is held */
394 struct cciss_scsi_dev_t sd;
396 if (entry < 0 || entry >= CCISS_MAX_SCSI_DEVS_PER_HBA) return;
397 sd = ccissscsi[ctlr].dev[entry];
398 for (i=entry;i<ccissscsi[ctlr].ndevices-1;i++)
399 ccissscsi[ctlr].dev[i] = ccissscsi[ctlr].dev[i+1];
400 ccissscsi[ctlr].ndevices--;
401 printk("cciss%d: %s device c%db%dt%dl%d removed.\n",
402 ctlr, DEVICETYPE(sd.devtype), hostno,
403 sd.bus, sd.target, sd.lun);
407 #define SCSI3ADDR_EQ(a,b) ( \
408 (a)[7] == (b)[7] && \
409 (a)[6] == (b)[6] && \
410 (a)[5] == (b)[5] && \
411 (a)[4] == (b)[4] && \
412 (a)[3] == (b)[3] && \
413 (a)[2] == (b)[2] && \
414 (a)[1] == (b)[1] && \
418 adjust_cciss_scsi_table(int ctlr, int hostno,
419 struct cciss_scsi_dev_t sd[], int nsds)
421 /* sd contains scsi3 addresses and devtypes, but
422 bus target and lun are not filled in. This funciton
423 takes what's in sd to be the current and adjusts
424 ccissscsi[] to be in line with what's in sd. */
426 int i,j, found, changes=0;
427 struct cciss_scsi_dev_t *csd;
430 CPQ_TAPE_LOCK(ctlr, flags);
432 /* find any devices in ccissscsi[] that are not in
433 sd[] and remove them from ccissscsi[] */
436 while(i<ccissscsi[ctlr].ndevices) {
437 csd = &ccissscsi[ctlr].dev[i];
439 for (j=0;j<nsds;j++) {
440 if (SCSI3ADDR_EQ(sd[j].scsi3addr,
442 if (sd[j].devtype == csd->devtype)
450 if (found == 0) { /* device no longer present. */
452 /* printk("cciss%d: %s device c%db%dt%dl%d removed.\n",
453 ctlr, DEVICETYPE(csd->devtype), hostno,
454 csd->bus, csd->target, csd->lun); */
455 cciss_scsi_remove_entry(ctlr, hostno, i);
456 /* note, i not incremented */
458 else if (found == 1) { /* device is different kind */
460 printk("cciss%d: device c%db%dt%dl%d type changed "
461 "(device type now %s).\n",
462 ctlr, hostno, csd->bus, csd->target, csd->lun,
463 DEVICETYPE(csd->devtype));
464 csd->devtype = sd[j].devtype;
465 i++; /* so just move along. */
466 } else /* device is same as it ever was, */
467 i++; /* so just move along. */
470 /* Now, make sure every device listed in sd[] is also
471 listed in ccissscsi[], adding them if they aren't found */
473 for (i=0;i<nsds;i++) {
475 for (j=0;j<ccissscsi[ctlr].ndevices;j++) {
476 csd = &ccissscsi[ctlr].dev[j];
477 if (SCSI3ADDR_EQ(sd[i].scsi3addr,
479 if (sd[i].devtype == csd->devtype)
480 found=2; /* found device */
482 found=1; /* found a bug. */
488 if (cciss_scsi_add_entry(ctlr, hostno,
489 &sd[i].scsi3addr[0], sd[i].devtype) != 0)
491 } else if (found == 1) {
492 /* should never happen... */
494 printk("cciss%d: device unexpectedly changed type\n",
496 /* but if it does happen, we just ignore that device */
499 CPQ_TAPE_UNLOCK(ctlr, flags);
502 printk("cciss%d: No device changes detected.\n", ctlr);
508 lookup_scsi3addr(int ctlr, int bus, int target, int lun, char *scsi3addr)
511 struct cciss_scsi_dev_t *sd;
514 CPQ_TAPE_LOCK(ctlr, flags);
515 for (i=0;i<ccissscsi[ctlr].ndevices;i++) {
516 sd = &ccissscsi[ctlr].dev[i];
517 if (sd->bus == bus &&
518 sd->target == target &&
520 memcpy(scsi3addr, &sd->scsi3addr[0], 8);
521 CPQ_TAPE_UNLOCK(ctlr, flags);
525 CPQ_TAPE_UNLOCK(ctlr, flags);
530 cciss_scsi_setup(int cntl_num)
532 struct cciss_scsi_adapter_data_t * shba;
534 ccissscsi[cntl_num].ndevices = 0;
535 shba = (struct cciss_scsi_adapter_data_t *)
536 kmalloc(sizeof(*shba), GFP_KERNEL);
539 shba->scsi_host = NULL;
540 spin_lock_init(&shba->lock);
541 shba->registered = 0;
542 if (scsi_cmd_stack_setup(cntl_num, shba) != 0) {
546 hba[cntl_num]->scsi_ctlr = (void *) shba;
551 complete_scsi_command( CommandList_struct *cp, int timeout, __u32 tag)
553 struct scsi_cmnd *cmd;
556 ErrorInfo_struct *ei;
560 /* First, see if it was a message rather than a command */
561 if (cp->Request.Type.Type == TYPE_MSG) {
562 cp->cmd_type = CMD_MSG_DONE;
566 cmd = (struct scsi_cmnd *) cp->scsi_cmd;
567 ctlr = hba[cp->ctlr];
569 /* undo the DMA mappings */
572 pci_unmap_sg(ctlr->pdev,
573 cmd->buffer, cmd->use_sg,
574 cmd->sc_data_direction);
576 else if (cmd->request_bufflen) {
577 addr64.val32.lower = cp->SG[0].Addr.lower;
578 addr64.val32.upper = cp->SG[0].Addr.upper;
579 pci_unmap_single(ctlr->pdev, (dma_addr_t) addr64.val,
580 cmd->request_bufflen,
581 cmd->sc_data_direction);
584 cmd->result = (DID_OK << 16); /* host byte */
585 cmd->result |= (COMMAND_COMPLETE << 8); /* msg byte */
586 /* cmd->result |= (GOOD < 1); */ /* status byte */
588 cmd->result |= (ei->ScsiStatus);
589 /* printk("Scsistatus is 0x%02x\n", ei->ScsiStatus); */
591 /* copy the sense data whether we need to or not. */
593 memcpy(cmd->sense_buffer, ei->SenseInfo,
594 ei->SenseLen > SCSI_SENSE_BUFFERSIZE ?
595 SCSI_SENSE_BUFFERSIZE :
597 cmd->resid = ei->ResidualCnt;
599 if(ei->CommandStatus != 0)
600 { /* an error has occurred */
601 switch(ei->CommandStatus)
603 case CMD_TARGET_STATUS:
604 /* Pass it up to the upper layers... */
608 printk(KERN_WARNING "cciss: cmd %p "
609 "has SCSI Status = %x\n",
613 cmd->result |= (ei->ScsiStatus < 1);
615 else { /* scsi status is zero??? How??? */
617 /* Ordinarily, this case should never happen, but there is a bug
618 in some released firmware revisions that allows it to happen
619 if, for example, a 4100 backplane loses power and the tape
620 drive is in it. We assume that it's a fatal error of some
621 kind because we can't show that it wasn't. We will make it
622 look like selection timeout since that is the most common
623 reason for this to occur, and it's severe enough. */
625 cmd->result = DID_NO_CONNECT << 16;
628 case CMD_DATA_UNDERRUN: /* let mid layer handle it. */
630 case CMD_DATA_OVERRUN:
631 printk(KERN_WARNING "cciss: cp %p has"
632 " completed with data overrun "
636 /* print_bytes(cp, sizeof(*cp), 1, 0);
638 /* We get CMD_INVALID if you address a non-existent tape drive instead
639 of a selection timeout (no response). You will see this if you yank
640 out a tape drive, then try to access it. This is kind of a shame
641 because it means that any other CMD_INVALID (e.g. driver bug) will
642 get interpreted as a missing target. */
643 cmd->result = DID_NO_CONNECT << 16;
646 case CMD_PROTOCOL_ERR:
647 printk(KERN_WARNING "cciss: cp %p has "
648 "protocol error \n", cp);
650 case CMD_HARDWARE_ERR:
651 cmd->result = DID_ERROR << 16;
652 printk(KERN_WARNING "cciss: cp %p had "
653 " hardware error\n", cp);
655 case CMD_CONNECTION_LOST:
656 cmd->result = DID_ERROR << 16;
657 printk(KERN_WARNING "cciss: cp %p had "
658 "connection lost\n", cp);
661 cmd->result = DID_ABORT << 16;
662 printk(KERN_WARNING "cciss: cp %p was "
665 case CMD_ABORT_FAILED:
666 cmd->result = DID_ERROR << 16;
667 printk(KERN_WARNING "cciss: cp %p reports "
668 "abort failed\n", cp);
670 case CMD_UNSOLICITED_ABORT:
671 cmd->result = DID_ABORT << 16;
672 printk(KERN_WARNING "cciss: cp %p aborted "
673 "do to an unsolicited abort\n", cp);
676 cmd->result = DID_TIME_OUT << 16;
677 printk(KERN_WARNING "cciss: cp %p timedout\n",
681 cmd->result = DID_ERROR << 16;
682 printk(KERN_WARNING "cciss: cp %p returned "
683 "unknown status %x\n", cp,
687 // printk("c:%p:c%db%dt%dl%d ", cmd, ctlr->ctlr, cmd->channel,
688 // cmd->target, cmd->lun);
690 scsi_cmd_free(ctlr, cp);
694 cciss_scsi_detect(int ctlr)
696 struct Scsi_Host *sh;
699 sh = scsi_host_alloc(&cciss_driver_template, sizeof(struct ctlr_info *));
702 sh->io_port = 0; // good enough? FIXME,
703 sh->n_io_port = 0; // I don't think we use these two...
704 sh->this_id = SELF_SCSI_ID;
706 ((struct cciss_scsi_adapter_data_t *)
707 hba[ctlr]->scsi_ctlr)->scsi_host = (void *) sh;
708 sh->hostdata[0] = (unsigned long) hba[ctlr];
709 sh->irq = hba[ctlr]->intr;
710 sh->unique_id = sh->irq;
711 error = scsi_add_host(sh, &hba[ctlr]->pdev->dev);
724 cciss_unmap_one(struct pci_dev *pdev,
725 CommandList_struct *cp,
731 addr64.val32.lower = cp->SG[0].Addr.lower;
732 addr64.val32.upper = cp->SG[0].Addr.upper;
733 pci_unmap_single(pdev, (dma_addr_t) addr64.val, buflen, data_direction);
737 cciss_map_one(struct pci_dev *pdev,
738 CommandList_struct *cp,
745 addr64 = (__u64) pci_map_single(pdev, buf, buflen, data_direction);
746 cp->SG[0].Addr.lower =
747 (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF);
748 cp->SG[0].Addr.upper =
749 (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF);
750 cp->SG[0].Len = buflen;
751 cp->Header.SGList = (__u8) 1; /* no. SGs contig in this cmd */
752 cp->Header.SGTotal = (__u16) 1; /* total sgs in this cmd list */
756 cciss_scsi_do_simple_cmd(ctlr_info_t *c,
757 CommandList_struct *cp,
758 unsigned char *scsi3addr,
760 unsigned char cdblen,
761 unsigned char *buf, int bufsize,
765 DECLARE_COMPLETION(wait);
767 cp->cmd_type = CMD_IOCTL_PEND; // treat this like an ioctl
769 cp->Header.ReplyQueue = 0; // unused in simple mode
770 memcpy(&cp->Header.LUN, scsi3addr, sizeof(cp->Header.LUN));
771 cp->Header.Tag.lower = cp->busaddr; // Use k. address of cmd as tag
772 // Fill in the request block...
774 /* printk("Using scsi3addr 0x%02x%0x2%0x2%0x2%0x2%0x2%0x2%0x2\n",
775 scsi3addr[0], scsi3addr[1], scsi3addr[2], scsi3addr[3],
776 scsi3addr[4], scsi3addr[5], scsi3addr[6], scsi3addr[7]); */
778 memset(cp->Request.CDB, 0, sizeof(cp->Request.CDB));
779 memcpy(cp->Request.CDB, cdb, cdblen);
780 cp->Request.Timeout = 0;
781 cp->Request.CDBLen = cdblen;
782 cp->Request.Type.Type = TYPE_CMD;
783 cp->Request.Type.Attribute = ATTR_SIMPLE;
784 cp->Request.Type.Direction = direction;
786 /* Fill in the SG list and do dma mapping */
787 cciss_map_one(c->pdev, cp, (unsigned char *) buf,
788 bufsize, DMA_FROM_DEVICE);
792 /* Put the request on the tail of the request queue */
793 spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags);
797 spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags);
799 wait_for_completion(&wait);
801 /* undo the dma mapping */
802 cciss_unmap_one(c->pdev, cp, bufsize, DMA_FROM_DEVICE);
807 cciss_scsi_interpret_error(CommandList_struct *cp)
809 ErrorInfo_struct *ei;
812 switch(ei->CommandStatus)
814 case CMD_TARGET_STATUS:
815 printk(KERN_WARNING "cciss: cmd %p has "
816 "completed with errors\n", cp);
817 printk(KERN_WARNING "cciss: cmd %p "
818 "has SCSI Status = %x\n",
821 if (ei->ScsiStatus == 0)
823 "cciss:SCSI status is abnormally zero. "
824 "(probably indicates selection timeout "
825 "reported incorrectly due to a known "
826 "firmware bug, circa July, 2001.)\n");
828 case CMD_DATA_UNDERRUN: /* let mid layer handle it. */
829 printk("UNDERRUN\n");
831 case CMD_DATA_OVERRUN:
832 printk(KERN_WARNING "cciss: cp %p has"
833 " completed with data overrun "
837 /* controller unfortunately reports SCSI passthru's */
838 /* to non-existent targets as invalid commands. */
839 printk(KERN_WARNING "cciss: cp %p is "
840 "reported invalid (probably means "
841 "target device no longer present)\n",
843 /* print_bytes((unsigned char *) cp, sizeof(*cp), 1, 0);
847 case CMD_PROTOCOL_ERR:
848 printk(KERN_WARNING "cciss: cp %p has "
849 "protocol error \n", cp);
851 case CMD_HARDWARE_ERR:
852 /* cmd->result = DID_ERROR << 16; */
853 printk(KERN_WARNING "cciss: cp %p had "
854 " hardware error\n", cp);
856 case CMD_CONNECTION_LOST:
857 printk(KERN_WARNING "cciss: cp %p had "
858 "connection lost\n", cp);
861 printk(KERN_WARNING "cciss: cp %p was "
864 case CMD_ABORT_FAILED:
865 printk(KERN_WARNING "cciss: cp %p reports "
866 "abort failed\n", cp);
868 case CMD_UNSOLICITED_ABORT:
869 printk(KERN_WARNING "cciss: cp %p aborted "
870 "do to an unsolicited abort\n", cp);
873 printk(KERN_WARNING "cciss: cp %p timedout\n",
877 printk(KERN_WARNING "cciss: cp %p returned "
878 "unknown status %x\n", cp,
884 cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr,
885 unsigned char *buf, unsigned char bufsize)
888 CommandList_struct *cp;
890 ErrorInfo_struct *ei;
893 spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags);
894 cp = scsi_cmd_alloc(c);
895 spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags);
897 if (cp == NULL) { /* trouble... */
898 printk("cmd_alloc returned NULL!\n");
904 cdb[0] = CISS_INQUIRY;
910 rc = cciss_scsi_do_simple_cmd(c, cp, scsi3addr, cdb,
911 6, buf, bufsize, XFER_READ);
913 if (rc != 0) return rc; /* something went wrong */
915 if (ei->CommandStatus != 0 &&
916 ei->CommandStatus != CMD_DATA_UNDERRUN) {
917 cciss_scsi_interpret_error(cp);
920 spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags);
921 scsi_cmd_free(c, cp);
922 spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags);
927 cciss_scsi_do_report_phys_luns(ctlr_info_t *c,
928 ReportLunData_struct *buf, int bufsize)
931 CommandList_struct *cp;
932 unsigned char cdb[12];
933 unsigned char scsi3addr[8];
934 ErrorInfo_struct *ei;
937 spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags);
938 cp = scsi_cmd_alloc(c);
939 spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags);
940 if (cp == NULL) { /* trouble... */
941 printk("cmd_alloc returned NULL!\n");
945 memset(&scsi3addr[0], 0, 8); /* address the controller */
946 cdb[0] = CISS_REPORT_PHYS;
952 cdb[6] = (bufsize >> 24) & 0xFF; //MSB
953 cdb[7] = (bufsize >> 16) & 0xFF;
954 cdb[8] = (bufsize >> 8) & 0xFF;
955 cdb[9] = bufsize & 0xFF;
959 rc = cciss_scsi_do_simple_cmd(c, cp, scsi3addr,
961 (unsigned char *) buf,
964 if (rc != 0) return rc; /* something went wrong */
967 if (ei->CommandStatus != 0 &&
968 ei->CommandStatus != CMD_DATA_UNDERRUN) {
969 cciss_scsi_interpret_error(cp);
972 spin_lock_irqsave(CCISS_LOCK(c->ctlr), flags);
973 scsi_cmd_free(c, cp);
974 spin_unlock_irqrestore(CCISS_LOCK(c->ctlr), flags);
979 cciss_update_non_disk_devices(int cntl_num, int hostno)
981 /* the idea here is we could get notified from /proc
982 that some devices have changed, so we do a report
983 physical luns cmd, and adjust our list of devices
984 accordingly. (We can't rely on the scsi-mid layer just
985 doing inquiries, because the "busses" that the scsi
986 mid-layer probes are totally fabricated by this driver,
987 so new devices wouldn't show up.
989 the scsi3addr's of devices won't change so long as the
990 adapter is not reset. That means we can rescan and
991 tell which devices we already know about, vs. new
992 devices, vs. disappearing devices.
994 Also, if you yank out a tape drive, then put in a disk
995 in it's place, (say, a configured volume from another
996 array controller for instance) _don't_ poke this driver
997 (so it thinks it's still a tape, but _do_ poke the scsi
998 mid layer, so it does an inquiry... the scsi mid layer
999 will see the physical disk. This would be bad. Need to
1000 think about how to prevent that. One idea would be to
1001 snoop all scsi responses and if an inquiry repsonse comes
1002 back that reports a disk, chuck it an return selection
1003 timeout instead and adjust our table... Not sure i like
1007 #define OBDR_TAPE_INQ_SIZE 49
1008 #define OBDR_TAPE_SIG "$DR-10"
1009 ReportLunData_struct *ld_buff;
1010 unsigned char *inq_buff;
1011 unsigned char scsi3addr[8];
1015 /* unsigned char found[CCISS_MAX_SCSI_DEVS_PER_HBA]; */
1016 struct cciss_scsi_dev_t currentsd[CCISS_MAX_SCSI_DEVS_PER_HBA];
1018 int reportlunsize = sizeof(*ld_buff) + CISS_MAX_PHYS_LUN * 8;
1021 c = (ctlr_info_t *) hba[cntl_num];
1022 ld_buff = kmalloc(reportlunsize, GFP_KERNEL);
1023 if (ld_buff == NULL) {
1024 printk(KERN_ERR "cciss: out of memory\n");
1027 memset(ld_buff, 0, reportlunsize);
1028 inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL);
1029 if (inq_buff == NULL) {
1030 printk(KERN_ERR "cciss: out of memory\n");
1035 if (cciss_scsi_do_report_phys_luns(c, ld_buff, reportlunsize) == 0) {
1036 ch = &ld_buff->LUNListLength[0];
1037 num_luns = ((ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | ch[3]) / 8;
1038 if (num_luns > CISS_MAX_PHYS_LUN) {
1040 "cciss: Maximum physical LUNs (%d) exceeded. "
1041 "%d LUNs ignored.\n", CISS_MAX_PHYS_LUN,
1042 num_luns - CISS_MAX_PHYS_LUN);
1043 num_luns = CISS_MAX_PHYS_LUN;
1047 printk(KERN_ERR "cciss: Report physical LUNs failed.\n");
1052 /* adjust our table of devices */
1053 for(i=0; i<num_luns; i++)
1057 /* for each physical lun, do an inquiry */
1058 if (ld_buff->LUN[i][3] & 0xC0) continue;
1059 memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE);
1060 memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8);
1062 if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, inq_buff,
1063 (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) {
1064 /* Inquiry failed (msg printed already) */
1065 devtype = 0; /* so we will skip this device. */
1066 } else /* what kind of device is this? */
1067 devtype = (inq_buff[0] & 0x1f);
1071 case 0x05: /* CD-ROM */ {
1073 /* We don't *really* support actual CD-ROM devices,
1074 * just this "One Button Disaster Recovery" tape drive
1075 * which temporarily pretends to be a CD-ROM drive.
1076 * So we check that the device is really an OBDR tape
1077 * device by checking for "$DR-10" in bytes 43-48 of
1082 strncpy(obdr_sig, &inq_buff[43], 6);
1084 if (strncmp(obdr_sig, OBDR_TAPE_SIG, 6) != 0)
1085 /* Not OBDR device, ignore it. */
1088 /* fall through . . . */
1089 case 0x01: /* sequential access, (tape) */
1090 case 0x08: /* medium changer */
1091 if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) {
1092 printk(KERN_INFO "cciss%d: %s ignored, "
1093 "too many devices.\n", cntl_num,
1094 DEVICETYPE(devtype));
1097 memcpy(¤tsd[ncurrent].scsi3addr[0],
1099 currentsd[ncurrent].devtype = devtype;
1100 currentsd[ncurrent].bus = -1;
1101 currentsd[ncurrent].target = -1;
1102 currentsd[ncurrent].lun = -1;
1110 adjust_cciss_scsi_table(cntl_num, hostno, currentsd, ncurrent);
1118 is_keyword(char *ptr, int len, char *verb) // Thanks to ncr53c8xx.c
1120 int verb_len = strlen(verb);
1121 if (len >= verb_len && !memcmp(verb,ptr,verb_len))
1128 cciss_scsi_user_command(int ctlr, int hostno, char *buffer, int length)
1132 if ((arg_len = is_keyword(buffer, length, "rescan")) != 0)
1133 cciss_update_non_disk_devices(ctlr, hostno);
1141 cciss_scsi_proc_info(struct Scsi_Host *sh,
1142 char *buffer, /* data buffer */
1143 char **start, /* where data in buffer starts */
1144 off_t offset, /* offset from start of imaginary file */
1145 int length, /* length of data in buffer */
1146 int func) /* 0 == read, 1 == write */
1149 int buflen, datalen;
1155 ci = (ctlr_info_t *) sh->hostdata[0];
1156 if (ci == NULL) /* This really shouldn't ever happen. */
1159 cntl_num = ci->ctlr; /* Get our index into the hba[] array */
1161 if (func == 0) { /* User is reading from /proc/scsi/ciss*?/?* */
1162 buflen = sprintf(buffer, "cciss%d: SCSI host: %d\n",
1163 cntl_num, sh->host_no);
1165 /* this information is needed by apps to know which cciss
1166 device corresponds to which scsi host number without
1167 having to open a scsi target device node. The device
1168 information is not a duplicate of /proc/scsi/scsi because
1169 the two may be out of sync due to scsi hotplug, rather
1170 this info is for an app to be able to use to know how to
1171 get them back in sync. */
1173 for (i=0;i<ccissscsi[cntl_num].ndevices;i++) {
1174 struct cciss_scsi_dev_t *sd = &ccissscsi[cntl_num].dev[i];
1175 buflen += sprintf(&buffer[buflen], "c%db%dt%dl%d %02d "
1176 "0x%02x%02x%02x%02x%02x%02x%02x%02x\n",
1177 sh->host_no, sd->bus, sd->target, sd->lun,
1179 sd->scsi3addr[0], sd->scsi3addr[1],
1180 sd->scsi3addr[2], sd->scsi3addr[3],
1181 sd->scsi3addr[4], sd->scsi3addr[5],
1182 sd->scsi3addr[6], sd->scsi3addr[7]);
1184 datalen = buflen - offset;
1185 if (datalen < 0) { /* they're reading past EOF. */
1187 *start = buffer+buflen;
1189 *start = buffer + offset;
1191 } else /* User is writing to /proc/scsi/cciss*?/?* ... */
1192 return cciss_scsi_user_command(cntl_num, sh->host_no,
1196 /* cciss_scatter_gather takes a struct scsi_cmnd, (cmd), and does the pci
1197 dma mapping and fills in the scatter gather entries of the
1198 cciss command, cp. */
1201 cciss_scatter_gather(struct pci_dev *pdev,
1202 CommandList_struct *cp,
1203 struct scsi_cmnd *cmd)
1205 unsigned int use_sg, nsegs=0, len;
1206 struct scatterlist *scatter = (struct scatterlist *) cmd->buffer;
1209 /* is it just one virtual address? */
1211 if (cmd->request_bufflen) { /* anything to xfer? */
1213 addr64 = (__u64) pci_map_single(pdev,
1214 cmd->request_buffer,
1215 cmd->request_bufflen,
1216 cmd->sc_data_direction);
1218 cp->SG[0].Addr.lower =
1219 (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF);
1220 cp->SG[0].Addr.upper =
1221 (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF);
1222 cp->SG[0].Len = cmd->request_bufflen;
1225 } /* else, must be a list of virtual addresses.... */
1226 else if (cmd->use_sg <= MAXSGENTRIES) { /* not too many addrs? */
1228 use_sg = pci_map_sg(pdev, cmd->buffer, cmd->use_sg,
1229 cmd->sc_data_direction);
1231 for (nsegs=0; nsegs < use_sg; nsegs++) {
1232 addr64 = (__u64) sg_dma_address(&scatter[nsegs]);
1233 len = sg_dma_len(&scatter[nsegs]);
1234 cp->SG[nsegs].Addr.lower =
1235 (__u32) (addr64 & (__u64) 0x00000000FFFFFFFF);
1236 cp->SG[nsegs].Addr.upper =
1237 (__u32) ((addr64 >> 32) & (__u64) 0x00000000FFFFFFFF);
1238 cp->SG[nsegs].Len = len;
1239 cp->SG[nsegs].Ext = 0; // we are not chaining
1243 cp->Header.SGList = (__u8) nsegs; /* no. SGs contig in this cmd */
1244 cp->Header.SGTotal = (__u16) nsegs; /* total sgs in this cmd list */
1250 cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd *))
1254 unsigned char scsi3addr[8];
1255 CommandList_struct *cp;
1256 unsigned long flags;
1258 // Get the ptr to our adapter structure (hba[i]) out of cmd->host.
1259 // We violate cmd->host privacy here. (Is there another way?)
1260 c = (ctlr_info_t **) &cmd->device->host->hostdata[0];
1263 rc = lookup_scsi3addr(ctlr, cmd->device->channel, cmd->device->id,
1264 cmd->device->lun, scsi3addr);
1266 /* the scsi nexus does not match any that we presented... */
1267 /* pretend to mid layer that we got selection timeout */
1268 cmd->result = DID_NO_CONNECT << 16;
1270 /* we might want to think about registering controller itself
1271 as a processor device on the bus so sg binds to it. */
1275 /* printk("cciss_queue_command, p=%p, cmd=0x%02x, c%db%dt%dl%d\n",
1276 cmd, cmd->cmnd[0], ctlr, cmd->channel, cmd->target, cmd->lun);*/
1277 // printk("q:%p:c%db%dt%dl%d ", cmd, ctlr, cmd->channel,
1278 // cmd->target, cmd->lun);
1280 /* Ok, we have a reasonable scsi nexus, so send the cmd down, and
1281 see what the device thinks of it. */
1283 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1284 cp = scsi_cmd_alloc(*c);
1285 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1286 if (cp == NULL) { /* trouble... */
1287 printk("scsi_cmd_alloc returned NULL!\n");
1288 /* FIXME: next 3 lines are -> BAD! <- */
1289 cmd->result = DID_NO_CONNECT << 16;
1294 // Fill in the command list header
1296 cmd->scsi_done = done; // save this for use by completion code
1298 // save cp in case we have to abort it
1299 cmd->host_scribble = (unsigned char *) cp;
1301 cp->cmd_type = CMD_SCSI;
1303 cp->Header.ReplyQueue = 0; // unused in simple mode
1304 memcpy(&cp->Header.LUN.LunAddrBytes[0], &scsi3addr[0], 8);
1305 cp->Header.Tag.lower = cp->busaddr; // Use k. address of cmd as tag
1307 // Fill in the request block...
1309 cp->Request.Timeout = 0;
1310 memset(cp->Request.CDB, 0, sizeof(cp->Request.CDB));
1311 if (cmd->cmd_len > sizeof(cp->Request.CDB)) BUG();
1312 cp->Request.CDBLen = cmd->cmd_len;
1313 memcpy(cp->Request.CDB, cmd->cmnd, cmd->cmd_len);
1314 cp->Request.Type.Type = TYPE_CMD;
1315 cp->Request.Type.Attribute = ATTR_SIMPLE;
1316 switch(cmd->sc_data_direction)
1318 case DMA_TO_DEVICE: cp->Request.Type.Direction = XFER_WRITE; break;
1319 case DMA_FROM_DEVICE: cp->Request.Type.Direction = XFER_READ; break;
1320 case DMA_NONE: cp->Request.Type.Direction = XFER_NONE; break;
1321 case DMA_BIDIRECTIONAL:
1322 // This can happen if a buggy application does a scsi passthru
1323 // and sets both inlen and outlen to non-zero. ( see
1324 // ../scsi/scsi_ioctl.c:scsi_ioctl_send_command() )
1326 cp->Request.Type.Direction = XFER_RSVD;
1327 // This is technically wrong, and cciss controllers should
1328 // reject it with CMD_INVALID, which is the most correct
1329 // response, but non-fibre backends appear to let it
1330 // slide by, and give the same results as if this field
1331 // were set correctly. Either way is acceptable for
1332 // our purposes here.
1337 printk("cciss: unknown data direction: %d\n",
1338 cmd->sc_data_direction);
1343 cciss_scatter_gather((*c)->pdev, cp, cmd); // Fill the SG list
1345 /* Put the request on the tail of the request queue */
1347 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1348 addQ(&(*c)->reqQ, cp);
1351 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1353 /* the cmd'll come back via intr handler in complete_scsi_command() */
1358 cciss_unregister_scsi(int ctlr)
1360 struct cciss_scsi_adapter_data_t *sa;
1361 struct cciss_scsi_cmd_stack_t *stk;
1362 unsigned long flags;
1364 /* we are being forcibly unloaded, and may not refuse. */
1366 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1367 sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr;
1368 stk = &sa->cmd_stack;
1370 /* if we weren't ever actually registered, don't unregister */
1371 if (sa->registered) {
1372 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1373 scsi_remove_host(sa->scsi_host);
1374 scsi_host_put(sa->scsi_host);
1375 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1378 /* set scsi_host to NULL so our detect routine will
1379 find us on register */
1380 sa->scsi_host = NULL;
1381 scsi_cmd_stack_free(ctlr);
1383 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1387 cciss_register_scsi(int ctlr)
1389 unsigned long flags;
1391 CPQ_TAPE_LOCK(ctlr, flags);
1393 /* Since this is really a block driver, the SCSI core may not be
1394 initialized at init time, in which case, calling scsi_register_host
1395 would hang. Instead, we do it later, via /proc filesystem
1396 and rc scripts, when we know SCSI core is good to go. */
1398 /* Only register if SCSI devices are detected. */
1399 if (ccissscsi[ctlr].ndevices != 0) {
1400 ((struct cciss_scsi_adapter_data_t *)
1401 hba[ctlr]->scsi_ctlr)->registered = 1;
1402 CPQ_TAPE_UNLOCK(ctlr, flags);
1403 return cciss_scsi_detect(ctlr);
1405 CPQ_TAPE_UNLOCK(ctlr, flags);
1407 "cciss%d: No appropriate SCSI device detected, "
1408 "SCSI subsystem not engaged.\n", ctlr);
1413 cciss_engage_scsi(int ctlr)
1415 struct cciss_scsi_adapter_data_t *sa;
1416 struct cciss_scsi_cmd_stack_t *stk;
1417 unsigned long flags;
1419 spin_lock_irqsave(CCISS_LOCK(ctlr), flags);
1420 sa = (struct cciss_scsi_adapter_data_t *) hba[ctlr]->scsi_ctlr;
1421 stk = &sa->cmd_stack;
1423 if (((struct cciss_scsi_adapter_data_t *)
1424 hba[ctlr]->scsi_ctlr)->registered) {
1425 printk("cciss%d: SCSI subsystem already engaged.\n", ctlr);
1426 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1429 spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags);
1430 cciss_update_non_disk_devices(ctlr, -1);
1431 cciss_register_scsi(ctlr);
1436 cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len)
1438 unsigned long flags;
1441 *pos = *pos -1; *len = *len - 1; // cut off the last trailing newline
1443 CPQ_TAPE_LOCK(ctlr, flags);
1444 size = sprintf(buffer + *len,
1445 "Sequential access devices: %d\n\n",
1446 ccissscsi[ctlr].ndevices);
1447 CPQ_TAPE_UNLOCK(ctlr, flags);
1448 *pos += size; *len += size;
1451 #else /* no CONFIG_CISS_SCSI_TAPE */
1453 /* If no tape support, then these become defined out of existence */
1455 #define cciss_scsi_setup(cntl_num)
1456 #define cciss_unregister_scsi(ctlr)
1457 #define cciss_register_scsi(ctlr)
1458 #define cciss_proc_tape_report(ctlr, buffer, pos, len)
1460 #endif /* CONFIG_CISS_SCSI_TAPE */