aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/ncr53c8xx.c
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2005-12-16 12:50:53 -0500
committerJames Bottomley <jejb@mulgrave.(none)>2005-12-16 13:53:47 -0500
commit19c65091c133a98b20d867c94b1b1380a79e4b81 (patch)
tree03076a960278b81e26437f2acb0f24cc4f7fe039 /drivers/scsi/ncr53c8xx.c
parentcd453c6353ea30171d966fd1dd87c37b05bccee1 (diff)
[SCSI] Merge sym53c8xx_comm.h and sym53c8xx_defs.h into ncr driver
When the sym1 driver was in the tree, it used to share various parts of its infrastructure with the ncr driver. Now it's gone, these files are just an annoyance, so merge sym53c8xx_comm.h into ncr53c8xx.c and merge sym53c8xx_defs.h into ncr53c8xx.h. Signed-off-by: Matthew Wilcox <matthew@wil.cx> Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/ncr53c8xx.c')
-rw-r--r--drivers/scsi/ncr53c8xx.c734
1 files changed, 733 insertions, 1 deletions
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 8e1c77c81f6c..32350707b940 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -131,7 +131,739 @@
131#define NAME53C "ncr53c" 131#define NAME53C "ncr53c"
132#define NAME53C8XX "ncr53c8xx" 132#define NAME53C8XX "ncr53c8xx"
133 133
134#include "sym53c8xx_comm.h" 134
135/*==========================================================
136**
137** Debugging tags
138**
139**==========================================================
140*/
141
142#define DEBUG_ALLOC (0x0001)
143#define DEBUG_PHASE (0x0002)
144#define DEBUG_QUEUE (0x0008)
145#define DEBUG_RESULT (0x0010)
146#define DEBUG_POINTER (0x0020)
147#define DEBUG_SCRIPT (0x0040)
148#define DEBUG_TINY (0x0080)
149#define DEBUG_TIMING (0x0100)
150#define DEBUG_NEGO (0x0200)
151#define DEBUG_TAGS (0x0400)
152#define DEBUG_SCATTER (0x0800)
153#define DEBUG_IC (0x1000)
154
155/*
156** Enable/Disable debug messages.
157** Can be changed at runtime too.
158*/
159
160#ifdef SCSI_NCR_DEBUG_INFO_SUPPORT
161static int ncr_debug = SCSI_NCR_DEBUG_FLAGS;
162 #define DEBUG_FLAGS ncr_debug
163#else
164 #define DEBUG_FLAGS SCSI_NCR_DEBUG_FLAGS
165#endif
166
167static inline struct list_head *ncr_list_pop(struct list_head *head)
168{
169 if (!list_empty(head)) {
170 struct list_head *elem = head->next;
171
172 list_del(elem);
173 return elem;
174 }
175
176 return NULL;
177}
178
179/*==========================================================
180**
181** Simple power of two buddy-like allocator.
182**
183** This simple code is not intended to be fast, but to
184** provide power of 2 aligned memory allocations.
185** Since the SCRIPTS processor only supplies 8 bit
186** arithmetic, this allocator allows simple and fast
187** address calculations from the SCRIPTS code.
188** In addition, cache line alignment is guaranteed for
189** power of 2 cache line size.
190** Enhanced in linux-2.3.44 to provide a memory pool
191** per pcidev to support dynamic dma mapping. (I would
192** have preferred a real bus astraction, btw).
193**
194**==========================================================
195*/
196
197#define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */
198#if PAGE_SIZE >= 8192
199#define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */
200#else
201#define MEMO_PAGE_ORDER 1 /* 2 PAGES maximum */
202#endif
203#define MEMO_FREE_UNUSED /* Free unused pages immediately */
204#define MEMO_WARN 1
205#define MEMO_GFP_FLAGS GFP_ATOMIC
206#define MEMO_CLUSTER_SHIFT (PAGE_SHIFT+MEMO_PAGE_ORDER)
207#define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT)
208#define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
209
210typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */
211typedef struct device *m_bush_t; /* Something that addresses DMAable */
212
213typedef struct m_link { /* Link between free memory chunks */
214 struct m_link *next;
215} m_link_s;
216
217typedef struct m_vtob { /* Virtual to Bus address translation */
218 struct m_vtob *next;
219 m_addr_t vaddr;
220 m_addr_t baddr;
221} m_vtob_s;
222#define VTOB_HASH_SHIFT 5
223#define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT)
224#define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
225#define VTOB_HASH_CODE(m) \
226 ((((m_addr_t) (m)) >> MEMO_CLUSTER_SHIFT) & VTOB_HASH_MASK)
227
228typedef struct m_pool { /* Memory pool of a given kind */
229 m_bush_t bush;
230 m_addr_t (*getp)(struct m_pool *);
231 void (*freep)(struct m_pool *, m_addr_t);
232 int nump;
233 m_vtob_s *(vtob[VTOB_HASH_SIZE]);
234 struct m_pool *next;
235 struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1];
236} m_pool_s;
237
238static void *___m_alloc(m_pool_s *mp, int size)
239{
240 int i = 0;
241 int s = (1 << MEMO_SHIFT);
242 int j;
243 m_addr_t a;
244 m_link_s *h = mp->h;
245
246 if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
247 return NULL;
248
249 while (size > s) {
250 s <<= 1;
251 ++i;
252 }
253
254 j = i;
255 while (!h[j].next) {
256 if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
257 h[j].next = (m_link_s *)mp->getp(mp);
258 if (h[j].next)
259 h[j].next->next = NULL;
260 break;
261 }
262 ++j;
263 s <<= 1;
264 }
265 a = (m_addr_t) h[j].next;
266 if (a) {
267 h[j].next = h[j].next->next;
268 while (j > i) {
269 j -= 1;
270 s >>= 1;
271 h[j].next = (m_link_s *) (a+s);
272 h[j].next->next = NULL;
273 }
274 }
275#ifdef DEBUG
276 printk("___m_alloc(%d) = %p\n", size, (void *) a);
277#endif
278 return (void *) a;
279}
280
281static void ___m_free(m_pool_s *mp, void *ptr, int size)
282{
283 int i = 0;
284 int s = (1 << MEMO_SHIFT);
285 m_link_s *q;
286 m_addr_t a, b;
287 m_link_s *h = mp->h;
288
289#ifdef DEBUG
290 printk("___m_free(%p, %d)\n", ptr, size);
291#endif
292
293 if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
294 return;
295
296 while (size > s) {
297 s <<= 1;
298 ++i;
299 }
300
301 a = (m_addr_t) ptr;
302
303 while (1) {
304#ifdef MEMO_FREE_UNUSED
305 if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
306 mp->freep(mp, a);
307 break;
308 }
309#endif
310 b = a ^ s;
311 q = &h[i];
312 while (q->next && q->next != (m_link_s *) b) {
313 q = q->next;
314 }
315 if (!q->next) {
316 ((m_link_s *) a)->next = h[i].next;
317 h[i].next = (m_link_s *) a;
318 break;
319 }
320 q->next = q->next->next;
321 a = a & b;
322 s <<= 1;
323 ++i;
324 }
325}
326
327static DEFINE_SPINLOCK(ncr53c8xx_lock);
328
329static void *__m_calloc2(m_pool_s *mp, int size, char *name, int uflags)
330{
331 void *p;
332
333 p = ___m_alloc(mp, size);
334
335 if (DEBUG_FLAGS & DEBUG_ALLOC)
336 printk ("new %-10s[%4d] @%p.\n", name, size, p);
337
338 if (p)
339 memset(p, 0, size);
340 else if (uflags & MEMO_WARN)
341 printk (NAME53C8XX ": failed to allocate %s[%d]\n", name, size);
342
343 return p;
344}
345
346#define __m_calloc(mp, s, n) __m_calloc2(mp, s, n, MEMO_WARN)
347
348static void __m_free(m_pool_s *mp, void *ptr, int size, char *name)
349{
350 if (DEBUG_FLAGS & DEBUG_ALLOC)
351 printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr);
352
353 ___m_free(mp, ptr, size);
354
355}
356
357/*
358 * With pci bus iommu support, we use a default pool of unmapped memory
359 * for memory we donnot need to DMA from/to and one pool per pcidev for
360 * memory accessed by the PCI chip. `mp0' is the default not DMAable pool.
361 */
362
363static m_addr_t ___mp0_getp(m_pool_s *mp)
364{
365 m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER);
366 if (m)
367 ++mp->nump;
368 return m;
369}
370
371static void ___mp0_freep(m_pool_s *mp, m_addr_t m)
372{
373 free_pages(m, MEMO_PAGE_ORDER);
374 --mp->nump;
375}
376
377static m_pool_s mp0 = {NULL, ___mp0_getp, ___mp0_freep};
378
379/*
380 * DMAable pools.
381 */
382
383/*
384 * With pci bus iommu support, we maintain one pool per pcidev and a
385 * hashed reverse table for virtual to bus physical address translations.
386 */
387static m_addr_t ___dma_getp(m_pool_s *mp)
388{
389 m_addr_t vp;
390 m_vtob_s *vbp;
391
392 vbp = __m_calloc(&mp0, sizeof(*vbp), "VTOB");
393 if (vbp) {
394 dma_addr_t daddr;
395 vp = (m_addr_t) dma_alloc_coherent(mp->bush,
396 PAGE_SIZE<<MEMO_PAGE_ORDER,
397 &daddr, GFP_ATOMIC);
398 if (vp) {
399 int hc = VTOB_HASH_CODE(vp);
400 vbp->vaddr = vp;
401 vbp->baddr = daddr;
402 vbp->next = mp->vtob[hc];
403 mp->vtob[hc] = vbp;
404 ++mp->nump;
405 return vp;
406 }
407 }
408 if (vbp)
409 __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
410 return 0;
411}
412
413static void ___dma_freep(m_pool_s *mp, m_addr_t m)
414{
415 m_vtob_s **vbpp, *vbp;
416 int hc = VTOB_HASH_CODE(m);
417
418 vbpp = &mp->vtob[hc];
419 while (*vbpp && (*vbpp)->vaddr != m)
420 vbpp = &(*vbpp)->next;
421 if (*vbpp) {
422 vbp = *vbpp;
423 *vbpp = (*vbpp)->next;
424 dma_free_coherent(mp->bush, PAGE_SIZE<<MEMO_PAGE_ORDER,
425 (void *)vbp->vaddr, (dma_addr_t)vbp->baddr);
426 __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
427 --mp->nump;
428 }
429}
430
431static inline m_pool_s *___get_dma_pool(m_bush_t bush)
432{
433 m_pool_s *mp;
434 for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next);
435 return mp;
436}
437
438static m_pool_s *___cre_dma_pool(m_bush_t bush)
439{
440 m_pool_s *mp;
441 mp = __m_calloc(&mp0, sizeof(*mp), "MPOOL");
442 if (mp) {
443 memset(mp, 0, sizeof(*mp));
444 mp->bush = bush;
445 mp->getp = ___dma_getp;
446 mp->freep = ___dma_freep;
447 mp->next = mp0.next;
448 mp0.next = mp;
449 }
450 return mp;
451}
452
453static void ___del_dma_pool(m_pool_s *p)
454{
455 struct m_pool **pp = &mp0.next;
456
457 while (*pp && *pp != p)
458 pp = &(*pp)->next;
459 if (*pp) {
460 *pp = (*pp)->next;
461 __m_free(&mp0, p, sizeof(*p), "MPOOL");
462 }
463}
464
465static void *__m_calloc_dma(m_bush_t bush, int size, char *name)
466{
467 u_long flags;
468 struct m_pool *mp;
469 void *m = NULL;
470
471 spin_lock_irqsave(&ncr53c8xx_lock, flags);
472 mp = ___get_dma_pool(bush);
473 if (!mp)
474 mp = ___cre_dma_pool(bush);
475 if (mp)
476 m = __m_calloc(mp, size, name);
477 if (mp && !mp->nump)
478 ___del_dma_pool(mp);
479 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
480
481 return m;
482}
483
484static void __m_free_dma(m_bush_t bush, void *m, int size, char *name)
485{
486 u_long flags;
487 struct m_pool *mp;
488
489 spin_lock_irqsave(&ncr53c8xx_lock, flags);
490 mp = ___get_dma_pool(bush);
491 if (mp)
492 __m_free(mp, m, size, name);
493 if (mp && !mp->nump)
494 ___del_dma_pool(mp);
495 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
496}
497
498static m_addr_t __vtobus(m_bush_t bush, void *m)
499{
500 u_long flags;
501 m_pool_s *mp;
502 int hc = VTOB_HASH_CODE(m);
503 m_vtob_s *vp = NULL;
504 m_addr_t a = ((m_addr_t) m) & ~MEMO_CLUSTER_MASK;
505
506 spin_lock_irqsave(&ncr53c8xx_lock, flags);
507 mp = ___get_dma_pool(bush);
508 if (mp) {
509 vp = mp->vtob[hc];
510 while (vp && (m_addr_t) vp->vaddr != a)
511 vp = vp->next;
512 }
513 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
514 return vp ? vp->baddr + (((m_addr_t) m) - a) : 0;
515}
516
517#define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
518#define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
519#define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
520#define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
521#define _vtobus(np, p) __vtobus(np->dev, p)
522#define vtobus(p) _vtobus(np, p)
523
524/*
525 * Deal with DMA mapping/unmapping.
526 */
527
528/* To keep track of the dma mapping (sg/single) that has been set */
529#define __data_mapped SCp.phase
530#define __data_mapping SCp.have_data_in
531
532static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd)
533{
534 switch(cmd->__data_mapped) {
535 case 2:
536 dma_unmap_sg(dev, cmd->buffer, cmd->use_sg,
537 cmd->sc_data_direction);
538 break;
539 case 1:
540 dma_unmap_single(dev, cmd->__data_mapping,
541 cmd->request_bufflen,
542 cmd->sc_data_direction);
543 break;
544 }
545 cmd->__data_mapped = 0;
546}
547
548static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd)
549{
550 dma_addr_t mapping;
551
552 if (cmd->request_bufflen == 0)
553 return 0;
554
555 mapping = dma_map_single(dev, cmd->request_buffer,
556 cmd->request_bufflen,
557 cmd->sc_data_direction);
558 cmd->__data_mapped = 1;
559 cmd->__data_mapping = mapping;
560
561 return mapping;
562}
563
564static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
565{
566 int use_sg;
567
568 if (cmd->use_sg == 0)
569 return 0;
570
571 use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg,
572 cmd->sc_data_direction);
573 cmd->__data_mapped = 2;
574 cmd->__data_mapping = use_sg;
575
576 return use_sg;
577}
578
579#define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
580#define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd)
581#define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
582
583/*==========================================================
584**
585** Driver setup.
586**
587** This structure is initialized from linux config
588** options. It can be overridden at boot-up by the boot
589** command line.
590**
591**==========================================================
592*/
593static struct ncr_driver_setup
594 driver_setup = SCSI_NCR_DRIVER_SETUP;
595
596#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
597static struct ncr_driver_setup
598 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP;
599#endif
600
601#define initverbose (driver_setup.verbose)
602#define bootverbose (np->verbose)
603
604
605/*===================================================================
606**
607** Driver setup from the boot command line
608**
609**===================================================================
610*/
611
612#ifdef MODULE
613#define ARG_SEP ' '
614#else
615#define ARG_SEP ','
616#endif
617
618#define OPT_TAGS 1
619#define OPT_MASTER_PARITY 2
620#define OPT_SCSI_PARITY 3
621#define OPT_DISCONNECTION 4
622#define OPT_SPECIAL_FEATURES 5
623#define OPT_UNUSED_1 6
624#define OPT_FORCE_SYNC_NEGO 7
625#define OPT_REVERSE_PROBE 8
626#define OPT_DEFAULT_SYNC 9
627#define OPT_VERBOSE 10
628#define OPT_DEBUG 11
629#define OPT_BURST_MAX 12
630#define OPT_LED_PIN 13
631#define OPT_MAX_WIDE 14
632#define OPT_SETTLE_DELAY 15
633#define OPT_DIFF_SUPPORT 16
634#define OPT_IRQM 17
635#define OPT_PCI_FIX_UP 18
636#define OPT_BUS_CHECK 19
637#define OPT_OPTIMIZE 20
638#define OPT_RECOVERY 21
639#define OPT_SAFE_SETUP 22
640#define OPT_USE_NVRAM 23
641#define OPT_EXCLUDE 24
642#define OPT_HOST_ID 25
643
644#ifdef SCSI_NCR_IARB_SUPPORT
645#define OPT_IARB 26
646#endif
647
648static char setup_token[] __initdata =
649 "tags:" "mpar:"
650 "spar:" "disc:"
651 "specf:" "ultra:"
652 "fsn:" "revprob:"
653 "sync:" "verb:"
654 "debug:" "burst:"
655 "led:" "wide:"
656 "settle:" "diff:"
657 "irqm:" "pcifix:"
658 "buschk:" "optim:"
659 "recovery:"
660 "safe:" "nvram:"
661 "excl:" "hostid:"
662#ifdef SCSI_NCR_IARB_SUPPORT
663 "iarb:"
664#endif
665 ; /* DONNOT REMOVE THIS ';' */
666
667#ifdef MODULE
668#define ARG_SEP ' '
669#else
670#define ARG_SEP ','
671#endif
672
673static int __init get_setup_token(char *p)
674{
675 char *cur = setup_token;
676 char *pc;
677 int i = 0;
678
679 while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
680 ++pc;
681 ++i;
682 if (!strncmp(p, cur, pc - cur))
683 return i;
684 cur = pc;
685 }
686 return 0;
687}
688
689
690static int __init sym53c8xx__setup(char *str)
691{
692#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
693 char *cur = str;
694 char *pc, *pv;
695 int i, val, c;
696 int xi = 0;
697
698 while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
699 char *pe;
700
701 val = 0;
702 pv = pc;
703 c = *++pv;
704
705 if (c == 'n')
706 val = 0;
707 else if (c == 'y')
708 val = 1;
709 else
710 val = (int) simple_strtoul(pv, &pe, 0);
711
712 switch (get_setup_token(cur)) {
713 case OPT_TAGS:
714 driver_setup.default_tags = val;
715 if (pe && *pe == '/') {
716 i = 0;
717 while (*pe && *pe != ARG_SEP &&
718 i < sizeof(driver_setup.tag_ctrl)-1) {
719 driver_setup.tag_ctrl[i++] = *pe++;
720 }
721 driver_setup.tag_ctrl[i] = '\0';
722 }
723 break;
724 case OPT_MASTER_PARITY:
725 driver_setup.master_parity = val;
726 break;
727 case OPT_SCSI_PARITY:
728 driver_setup.scsi_parity = val;
729 break;
730 case OPT_DISCONNECTION:
731 driver_setup.disconnection = val;
732 break;
733 case OPT_SPECIAL_FEATURES:
734 driver_setup.special_features = val;
735 break;
736 case OPT_FORCE_SYNC_NEGO:
737 driver_setup.force_sync_nego = val;
738 break;
739 case OPT_REVERSE_PROBE:
740 driver_setup.reverse_probe = val;
741 break;
742 case OPT_DEFAULT_SYNC:
743 driver_setup.default_sync = val;
744 break;
745 case OPT_VERBOSE:
746 driver_setup.verbose = val;
747 break;
748 case OPT_DEBUG:
749 driver_setup.debug = val;
750 break;
751 case OPT_BURST_MAX:
752 driver_setup.burst_max = val;
753 break;
754 case OPT_LED_PIN:
755 driver_setup.led_pin = val;
756 break;
757 case OPT_MAX_WIDE:
758 driver_setup.max_wide = val? 1:0;
759 break;
760 case OPT_SETTLE_DELAY:
761 driver_setup.settle_delay = val;
762 break;
763 case OPT_DIFF_SUPPORT:
764 driver_setup.diff_support = val;
765 break;
766 case OPT_IRQM:
767 driver_setup.irqm = val;
768 break;
769 case OPT_PCI_FIX_UP:
770 driver_setup.pci_fix_up = val;
771 break;
772 case OPT_BUS_CHECK:
773 driver_setup.bus_check = val;
774 break;
775 case OPT_OPTIMIZE:
776 driver_setup.optimize = val;
777 break;
778 case OPT_RECOVERY:
779 driver_setup.recovery = val;
780 break;
781 case OPT_USE_NVRAM:
782 driver_setup.use_nvram = val;
783 break;
784 case OPT_SAFE_SETUP:
785 memcpy(&driver_setup, &driver_safe_setup,
786 sizeof(driver_setup));
787 break;
788 case OPT_EXCLUDE:
789 if (xi < SCSI_NCR_MAX_EXCLUDES)
790 driver_setup.excludes[xi++] = val;
791 break;
792 case OPT_HOST_ID:
793 driver_setup.host_id = val;
794 break;
795#ifdef SCSI_NCR_IARB_SUPPORT
796 case OPT_IARB:
797 driver_setup.iarb = val;
798 break;
799#endif
800 default:
801 printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur);
802 break;
803 }
804
805 if ((cur = strchr(cur, ARG_SEP)) != NULL)
806 ++cur;
807 }
808#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */
809 return 1;
810}
811
812/*===================================================================
813**
814** Get device queue depth from boot command line.
815**
816**===================================================================
817*/
818#define DEF_DEPTH (driver_setup.default_tags)
819#define ALL_TARGETS -2
820#define NO_TARGET -1
821#define ALL_LUNS -2
822#define NO_LUN -1
823
824static int device_queue_depth(int unit, int target, int lun)
825{
826 int c, h, t, u, v;
827 char *p = driver_setup.tag_ctrl;
828 char *ep;
829
830 h = -1;
831 t = NO_TARGET;
832 u = NO_LUN;
833 while ((c = *p++) != 0) {
834 v = simple_strtoul(p, &ep, 0);
835 switch(c) {
836 case '/':
837 ++h;
838 t = ALL_TARGETS;
839 u = ALL_LUNS;
840 break;
841 case 't':
842 if (t != target)
843 t = (target == v) ? v : NO_TARGET;
844 u = ALL_LUNS;
845 break;
846 case 'u':
847 if (u != lun)
848 u = (lun == v) ? v : NO_LUN;
849 break;
850 case 'q':
851 if (h == unit &&
852 (t == ALL_TARGETS || t == target) &&
853 (u == ALL_LUNS || u == lun))
854 return v;
855 break;
856 case '-':
857 t = ALL_TARGETS;
858 u = ALL_LUNS;
859 break;
860 default:
861 break;
862 }
863 p = ep;
864 }
865 return DEF_DEPTH;
866}
135 867
136 868
137/*========================================================== 869/*==========================================================