2 * Copyright (c) 1997-2006 by Matthew Jacob
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice immediately at the beginning of the file, without modification,
10 * this list of conditions, and the following disclaimer.
11 * 2. The name of the author may not be used to endorse or promote products
12 * derived from this software without specific prior written permission.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * PCI specific probe and attach routines for Qlogic ISP SCSI adapters.
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
37 #if __FreeBSD_version >= 700000
38 #include <sys/linker.h>
39 #include <sys/firmware.h>
42 #if __FreeBSD_version < 500000
43 #include <pci/pcireg.h>
44 #include <pci/pcivar.h>
45 #include <machine/bus_memio.h>
46 #include <machine/bus_pio.h>
48 #include <sys/stdint.h>
49 #include <dev/pci/pcireg.h>
50 #include <dev/pci/pcivar.h>
52 #include <machine/bus.h>
53 #include <machine/resource.h>
55 #include <sys/malloc.h>
57 #include <dev/isp/isp_freebsd.h>
59 #if __FreeBSD_version < 500000
60 #define BUS_PROBE_DEFAULT 0
63 static uint32_t isp_pci_rd_reg(ispsoftc_t *, int);
64 static void isp_pci_wr_reg(ispsoftc_t *, int, uint32_t);
65 static uint32_t isp_pci_rd_reg_1080(ispsoftc_t *, int);
66 static void isp_pci_wr_reg_1080(ispsoftc_t *, int, uint32_t);
67 static uint32_t isp_pci_rd_reg_2400(ispsoftc_t *, int);
68 static void isp_pci_wr_reg_2400(ispsoftc_t *, int, uint32_t);
70 isp_pci_rd_isr(ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *);
72 isp_pci_rd_isr_2300(ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *);
74 isp_pci_rd_isr_2400(ispsoftc_t *, uint32_t *, uint16_t *, uint16_t *);
75 static int isp_pci_mbxdma(ispsoftc_t *);
77 isp_pci_dmasetup(ispsoftc_t *, XS_T *, ispreq_t *, uint32_t *, uint32_t);
79 isp_pci_dmateardown(ispsoftc_t *, XS_T *, uint32_t);
82 static void isp_pci_reset0(ispsoftc_t *);
83 static void isp_pci_reset1(ispsoftc_t *);
84 static void isp_pci_dumpregs(ispsoftc_t *, const char *);
86 static struct ispmdvec mdvec = {
97 BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
100 static struct ispmdvec mdvec_1080 = {
111 BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
114 static struct ispmdvec mdvec_12160 = {
125 BIU_BURST_ENABLE|BIU_PCI_CONF1_FIFO_64
128 static struct ispmdvec mdvec_2100 = {
140 static struct ispmdvec mdvec_2200 = {
152 static struct ispmdvec mdvec_2300 = {
164 static struct ispmdvec mdvec_2400 = {
176 #ifndef PCIM_CMD_INVEN
177 #define PCIM_CMD_INVEN 0x10
179 #ifndef PCIM_CMD_BUSMASTEREN
180 #define PCIM_CMD_BUSMASTEREN 0x0004
182 #ifndef PCIM_CMD_PERRESPEN
183 #define PCIM_CMD_PERRESPEN 0x0040
185 #ifndef PCIM_CMD_SEREN
186 #define PCIM_CMD_SEREN 0x0100
188 #ifndef PCIM_CMD_INTX_DISABLE
189 #define PCIM_CMD_INTX_DISABLE 0x0400
193 #define PCIR_COMMAND 0x04
196 #ifndef PCIR_CACHELNSZ
197 #define PCIR_CACHELNSZ 0x0c
200 #ifndef PCIR_LATTIMER
201 #define PCIR_LATTIMER 0x0d
205 #define PCIR_ROMADDR 0x30
208 #ifndef PCI_VENDOR_QLOGIC
209 #define PCI_VENDOR_QLOGIC 0x1077
212 #ifndef PCI_PRODUCT_QLOGIC_ISP1020
213 #define PCI_PRODUCT_QLOGIC_ISP1020 0x1020
216 #ifndef PCI_PRODUCT_QLOGIC_ISP1080
217 #define PCI_PRODUCT_QLOGIC_ISP1080 0x1080
220 #ifndef PCI_PRODUCT_QLOGIC_ISP10160
221 #define PCI_PRODUCT_QLOGIC_ISP10160 0x1016
224 #ifndef PCI_PRODUCT_QLOGIC_ISP12160
225 #define PCI_PRODUCT_QLOGIC_ISP12160 0x1216
228 #ifndef PCI_PRODUCT_QLOGIC_ISP1240
229 #define PCI_PRODUCT_QLOGIC_ISP1240 0x1240
232 #ifndef PCI_PRODUCT_QLOGIC_ISP1280
233 #define PCI_PRODUCT_QLOGIC_ISP1280 0x1280
236 #ifndef PCI_PRODUCT_QLOGIC_ISP2100
237 #define PCI_PRODUCT_QLOGIC_ISP2100 0x2100
240 #ifndef PCI_PRODUCT_QLOGIC_ISP2200
241 #define PCI_PRODUCT_QLOGIC_ISP2200 0x2200
244 #ifndef PCI_PRODUCT_QLOGIC_ISP2300
245 #define PCI_PRODUCT_QLOGIC_ISP2300 0x2300
248 #ifndef PCI_PRODUCT_QLOGIC_ISP2312
249 #define PCI_PRODUCT_QLOGIC_ISP2312 0x2312
252 #ifndef PCI_PRODUCT_QLOGIC_ISP2322
253 #define PCI_PRODUCT_QLOGIC_ISP2322 0x2322
256 #ifndef PCI_PRODUCT_QLOGIC_ISP2422
257 #define PCI_PRODUCT_QLOGIC_ISP2422 0x2422
260 #ifndef PCI_PRODUCT_QLOGIC_ISP2432
261 #define PCI_PRODUCT_QLOGIC_ISP2432 0x2432
264 #ifndef PCI_PRODUCT_QLOGIC_ISP6312
265 #define PCI_PRODUCT_QLOGIC_ISP6312 0x6312
268 #ifndef PCI_PRODUCT_QLOGIC_ISP6322
269 #define PCI_PRODUCT_QLOGIC_ISP6322 0x6322
273 #define PCI_QLOGIC_ISP1020 \
274 ((PCI_PRODUCT_QLOGIC_ISP1020 << 16) | PCI_VENDOR_QLOGIC)
276 #define PCI_QLOGIC_ISP1080 \
277 ((PCI_PRODUCT_QLOGIC_ISP1080 << 16) | PCI_VENDOR_QLOGIC)
279 #define PCI_QLOGIC_ISP10160 \
280 ((PCI_PRODUCT_QLOGIC_ISP10160 << 16) | PCI_VENDOR_QLOGIC)
282 #define PCI_QLOGIC_ISP12160 \
283 ((PCI_PRODUCT_QLOGIC_ISP12160 << 16) | PCI_VENDOR_QLOGIC)
285 #define PCI_QLOGIC_ISP1240 \
286 ((PCI_PRODUCT_QLOGIC_ISP1240 << 16) | PCI_VENDOR_QLOGIC)
288 #define PCI_QLOGIC_ISP1280 \
289 ((PCI_PRODUCT_QLOGIC_ISP1280 << 16) | PCI_VENDOR_QLOGIC)
291 #define PCI_QLOGIC_ISP2100 \
292 ((PCI_PRODUCT_QLOGIC_ISP2100 << 16) | PCI_VENDOR_QLOGIC)
294 #define PCI_QLOGIC_ISP2200 \
295 ((PCI_PRODUCT_QLOGIC_ISP2200 << 16) | PCI_VENDOR_QLOGIC)
297 #define PCI_QLOGIC_ISP2300 \
298 ((PCI_PRODUCT_QLOGIC_ISP2300 << 16) | PCI_VENDOR_QLOGIC)
300 #define PCI_QLOGIC_ISP2312 \
301 ((PCI_PRODUCT_QLOGIC_ISP2312 << 16) | PCI_VENDOR_QLOGIC)
303 #define PCI_QLOGIC_ISP2322 \
304 ((PCI_PRODUCT_QLOGIC_ISP2322 << 16) | PCI_VENDOR_QLOGIC)
306 #define PCI_QLOGIC_ISP2422 \
307 ((PCI_PRODUCT_QLOGIC_ISP2422 << 16) | PCI_VENDOR_QLOGIC)
309 #define PCI_QLOGIC_ISP2432 \
310 ((PCI_PRODUCT_QLOGIC_ISP2432 << 16) | PCI_VENDOR_QLOGIC)
312 #define PCI_QLOGIC_ISP6312 \
313 ((PCI_PRODUCT_QLOGIC_ISP6312 << 16) | PCI_VENDOR_QLOGIC)
315 #define PCI_QLOGIC_ISP6322 \
316 ((PCI_PRODUCT_QLOGIC_ISP6322 << 16) | PCI_VENDOR_QLOGIC)
319 * Odd case for some AMI raid cards... We need to *not* attach to this.
321 #define AMI_RAID_SUBVENDOR_ID 0x101e
323 #define IO_MAP_REG 0x10
324 #define MEM_MAP_REG 0x14
326 #define PCI_DFLT_LTNCY 0x40
327 #define PCI_DFLT_LNSZ 0x10
329 static int isp_pci_probe (device_t);
330 static int isp_pci_attach (device_t);
331 static int isp_pci_detach (device_t);
334 struct isp_pcisoftc {
337 struct resource * pci_reg;
339 int16_t pci_poff[_NREG_BLKS];
345 static device_method_t isp_pci_methods[] = {
346 /* Device interface */
347 DEVMETHOD(device_probe, isp_pci_probe),
348 DEVMETHOD(device_attach, isp_pci_attach),
349 DEVMETHOD(device_detach, isp_pci_detach),
352 static void isp_pci_intr(void *);
354 static driver_t isp_pci_driver = {
355 "isp", isp_pci_methods, sizeof (struct isp_pcisoftc)
357 static devclass_t isp_devclass;
358 DRIVER_MODULE(isp, pci, isp_pci_driver, isp_devclass, 0, 0);
359 #if __FreeBSD_version < 700000
360 extern ispfwfunc *isp_get_firmware_p;
364 isp_pci_probe(device_t dev)
366 switch ((pci_get_device(dev) << 16) | (pci_get_vendor(dev))) {
367 case PCI_QLOGIC_ISP1020:
368 device_set_desc(dev, "Qlogic ISP 1020/1040 PCI SCSI Adapter");
370 case PCI_QLOGIC_ISP1080:
371 device_set_desc(dev, "Qlogic ISP 1080 PCI SCSI Adapter");
373 case PCI_QLOGIC_ISP1240:
374 device_set_desc(dev, "Qlogic ISP 1240 PCI SCSI Adapter");
376 case PCI_QLOGIC_ISP1280:
377 device_set_desc(dev, "Qlogic ISP 1280 PCI SCSI Adapter");
379 case PCI_QLOGIC_ISP10160:
380 device_set_desc(dev, "Qlogic ISP 10160 PCI SCSI Adapter");
382 case PCI_QLOGIC_ISP12160:
383 if (pci_get_subvendor(dev) == AMI_RAID_SUBVENDOR_ID) {
386 device_set_desc(dev, "Qlogic ISP 12160 PCI SCSI Adapter");
388 case PCI_QLOGIC_ISP2100:
389 device_set_desc(dev, "Qlogic ISP 2100 PCI FC-AL Adapter");
391 case PCI_QLOGIC_ISP2200:
392 device_set_desc(dev, "Qlogic ISP 2200 PCI FC-AL Adapter");
394 case PCI_QLOGIC_ISP2300:
395 device_set_desc(dev, "Qlogic ISP 2300 PCI FC-AL Adapter");
397 case PCI_QLOGIC_ISP2312:
398 device_set_desc(dev, "Qlogic ISP 2312 PCI FC-AL Adapter");
400 case PCI_QLOGIC_ISP2322:
401 device_set_desc(dev, "Qlogic ISP 2322 PCI FC-AL Adapter");
403 case PCI_QLOGIC_ISP2422:
404 device_set_desc(dev, "Qlogic ISP 2422 PCI FC-AL Adapter");
406 case PCI_QLOGIC_ISP2432:
407 device_set_desc(dev, "Qlogic ISP 2432 PCI FC-AL Adapter");
409 case PCI_QLOGIC_ISP6312:
410 device_set_desc(dev, "Qlogic ISP 6312 PCI FC-AL Adapter");
412 case PCI_QLOGIC_ISP6322:
413 device_set_desc(dev, "Qlogic ISP 6322 PCI FC-AL Adapter");
418 if (isp_announced == 0 && bootverbose) {
419 printf("Qlogic ISP Driver, FreeBSD Version %d.%d, "
420 "Core Version %d.%d\n",
421 ISP_PLATFORM_VERSION_MAJOR, ISP_PLATFORM_VERSION_MINOR,
422 ISP_CORE_VERSION_MAJOR, ISP_CORE_VERSION_MINOR);
426 * XXXX: Here is where we might load the f/w module
427 * XXXX: (or increase a reference count to it).
429 return (BUS_PROBE_DEFAULT);
432 #if __FreeBSD_version < 500000
434 isp_get_generic_options(device_t dev, ispsoftc_t *isp)
438 unit = device_get_unit(dev);
439 if (getenv_int("isp_disable", &bitmap)) {
440 if (bitmap & (1 << unit)) {
441 isp->isp_osinfo.disabled = 1;
445 if (getenv_int("isp_no_fwload", &bitmap)) {
446 if (bitmap & (1 << unit))
447 isp->isp_confopts |= ISP_CFG_NORELOAD;
449 if (getenv_int("isp_fwload", &bitmap)) {
450 if (bitmap & (1 << unit))
451 isp->isp_confopts &= ~ISP_CFG_NORELOAD;
453 if (getenv_int("isp_no_nvram", &bitmap)) {
454 if (bitmap & (1 << unit))
455 isp->isp_confopts |= ISP_CFG_NONVRAM;
457 if (getenv_int("isp_nvram", &bitmap)) {
458 if (bitmap & (1 << unit))
459 isp->isp_confopts &= ~ISP_CFG_NONVRAM;
463 (void) getenv_int("isp_debug", &bitmap);
465 isp->isp_dblev = bitmap;
467 isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR;
470 isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO;
474 if (getenv_int("role", &bitmap)) {
475 isp->isp_role = bitmap;
477 isp->isp_role = ISP_DEFAULT_ROLES;
483 isp_get_pci_options(device_t dev, int *m1, int *m2)
486 int unit = device_get_unit(dev);
488 *m1 = PCIM_CMD_MEMEN;
489 *m2 = PCIM_CMD_PORTEN;
490 if (getenv_int("isp_mem_map", &bitmap)) {
491 if (bitmap & (1 << unit)) {
492 *m1 = PCIM_CMD_MEMEN;
493 *m2 = PCIM_CMD_PORTEN;
497 if (getenv_int("isp_io_map", &bitmap)) {
498 if (bitmap & (1 << unit)) {
499 *m1 = PCIM_CMD_PORTEN;
500 *m2 = PCIM_CMD_MEMEN;
506 isp_get_specific_options(device_t dev, ispsoftc_t *isp)
510 int unit = device_get_unit(dev);
512 callout_handle_init(&isp->isp_osinfo.ldt);
513 callout_handle_init(&isp->isp_osinfo.gdt);
519 if (getenv_int("isp_fcduplex", &bitmap)) {
520 if (bitmap & (1 << unit))
521 isp->isp_confopts |= ISP_CFG_FULL_DUPLEX;
523 if (getenv_int("isp_no_fcduplex", &bitmap)) {
524 if (bitmap & (1 << unit))
525 isp->isp_confopts &= ~ISP_CFG_FULL_DUPLEX;
527 if (getenv_int("isp_nport", &bitmap)) {
528 if (bitmap & (1 << unit))
529 isp->isp_confopts |= ISP_CFG_NPORT;
533 * Because the resource_*_value functions can neither return
534 * 64 bit integer values, nor can they be directly coerced
535 * to interpret the right hand side of the assignment as
536 * you want them to interpret it, we have to force WWN
537 * hint replacement to specify WWN strings with a leading
538 * 'w' (e..g w50000000aaaa0001). Sigh.
540 if (getenv_quad("isp_portwwn", &wwn)) {
541 isp->isp_osinfo.default_port_wwn = wwn;
542 isp->isp_confopts |= ISP_CFG_OWNWWPN;
544 if (isp->isp_osinfo.default_port_wwn == 0) {
545 isp->isp_osinfo.default_port_wwn = 0x400000007F000009ull;
548 if (getenv_quad("isp_nodewwn", &wwn)) {
549 isp->isp_osinfo.default_node_wwn = wwn;
550 isp->isp_confopts |= ISP_CFG_OWNWWNN;
552 if (isp->isp_osinfo.default_node_wwn == 0) {
553 isp->isp_osinfo.default_node_wwn = 0x400000007F000009ull;
557 (void) getenv_int("isp_fabric_hysteresis", &bitmap);
558 if (bitmap >= 0 && bitmap < 256) {
559 isp->isp_osinfo.hysteresis = bitmap;
561 isp->isp_osinfo.hysteresis = isp_fabric_hysteresis;
565 (void) getenv_int("isp_loop_down_limit", &bitmap);
566 if (bitmap >= 0 && bitmap < 0xffff) {
567 isp->isp_osinfo.loop_down_limit = bitmap;
569 isp->isp_osinfo.loop_down_limit = isp_loop_down_limit;
573 (void) getenv_int("isp_gone_device_time", &bitmap);
574 if (bitmap >= 0 && bitmap < 0xffff) {
575 isp->isp_osinfo.gone_device_time = bitmap;
577 isp->isp_osinfo.gone_device_time = isp_gone_device_time;
579 #ifdef ISP_FW_CRASH_DUMP
581 if (getenv_int("isp_fw_dump_enable", &bitmap)) {
582 if (bitmap & (1 << unit) {
585 amt = QLA2200_RISC_IMAGE_DUMP_SIZE;
586 } else if (IS_23XX(isp)) {
587 amt = QLA2300_RISC_IMAGE_DUMP_SIZE;
590 FCPARAM(isp)->isp_dump_data =
591 malloc(amt, M_DEVBUF, M_WAITOK);
592 memset(FCPARAM(isp)->isp_dump_data, 0, amt);
595 "f/w crash dumps not supported for card\n");
603 isp_get_generic_options(device_t dev, ispsoftc_t *isp)
608 * Figure out if we're supposed to skip this one.
611 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
612 "disable", &tval) == 0 && tval) {
613 device_printf(dev, "disabled at user request\n");
614 isp->isp_osinfo.disabled = 1;
619 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
620 "role", &tval) == 0 && tval != -1) {
621 tval &= (ISP_ROLE_INITIATOR|ISP_ROLE_TARGET);
622 isp->isp_role = tval;
623 device_printf(dev, "setting role to 0x%x\n", isp->isp_role);
625 #ifdef ISP_TARGET_MODE
626 isp->isp_role = ISP_ROLE_TARGET;
628 isp->isp_role = ISP_DEFAULT_ROLES;
633 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
634 "fwload_disable", &tval) == 0 && tval != 0) {
635 isp->isp_confopts |= ISP_CFG_NORELOAD;
638 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
639 "ignore_nvram", &tval) == 0 && tval != 0) {
640 isp->isp_confopts |= ISP_CFG_NONVRAM;
644 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
647 isp->isp_dblev = tval;
649 isp->isp_dblev = ISP_LOGWARN|ISP_LOGERR;
652 isp->isp_dblev |= ISP_LOGCONFIG|ISP_LOGINFO;
658 isp_get_pci_options(device_t dev, int *m1, int *m2)
662 * Which we should try first - memory mapping or i/o mapping?
664 * We used to try memory first followed by i/o on alpha, otherwise
665 * the reverse, but we should just try memory first all the time now.
667 *m1 = PCIM_CMD_MEMEN;
668 *m2 = PCIM_CMD_PORTEN;
671 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
672 "prefer_iomap", &tval) == 0 && tval != 0) {
673 *m1 = PCIM_CMD_PORTEN;
674 *m2 = PCIM_CMD_MEMEN;
677 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
678 "prefer_memmap", &tval) == 0 && tval != 0) {
679 *m1 = PCIM_CMD_MEMEN;
680 *m2 = PCIM_CMD_PORTEN;
685 isp_get_specific_options(device_t dev, ispsoftc_t *isp)
690 isp->isp_osinfo.default_id = -1;
691 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
692 "iid", &tval) == 0) {
693 isp->isp_osinfo.default_id = tval;
694 isp->isp_confopts |= ISP_CFG_OWNLOOPID;
696 if (isp->isp_osinfo.default_id == -1) {
698 isp->isp_osinfo.default_id = 109;
700 isp->isp_osinfo.default_id = 7;
704 callout_handle_init(&isp->isp_osinfo.ldt);
705 callout_handle_init(&isp->isp_osinfo.gdt);
712 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
713 "fullduplex", &tval) == 0 && tval != 0) {
714 isp->isp_confopts |= ISP_CFG_FULL_DUPLEX;
716 #ifdef ISP_FW_CRASH_DUMP
718 if (resource_int_value(device_get_name(dev), device_get_unit(dev),
719 "fw_dump_enable", &tval) == 0 && tval != 0) {
722 amt = QLA2200_RISC_IMAGE_DUMP_SIZE;
723 } else if (IS_23XX(isp)) {
724 amt = QLA2300_RISC_IMAGE_DUMP_SIZE;
727 FCPARAM(isp)->isp_dump_data =
728 malloc(amt, M_DEVBUF, M_WAITOK | M_ZERO);
731 "f/w crash dumps not supported for this model\n");
736 if (resource_string_value(device_get_name(dev), device_get_unit(dev),
737 "topology", (const char **) &sptr) == 0 && sptr != 0) {
738 if (strcmp(sptr, "lport") == 0) {
739 isp->isp_confopts |= ISP_CFG_LPORT;
740 } else if (strcmp(sptr, "nport") == 0) {
741 isp->isp_confopts |= ISP_CFG_NPORT;
742 } else if (strcmp(sptr, "lport-only") == 0) {
743 isp->isp_confopts |= ISP_CFG_LPORT_ONLY;
744 } else if (strcmp(sptr, "nport-only") == 0) {
745 isp->isp_confopts |= ISP_CFG_NPORT_ONLY;
750 * Because the resource_*_value functions can neither return
751 * 64 bit integer values, nor can they be directly coerced
752 * to interpret the right hand side of the assignment as
753 * you want them to interpret it, we have to force WWN
754 * hint replacement to specify WWN strings with a leading
755 * 'w' (e..g w50000000aaaa0001). Sigh.
758 tval = resource_string_value(device_get_name(dev), device_get_unit(dev),
759 "portwwn", (const char **) &sptr);
760 if (tval == 0 && sptr != 0 && *sptr++ == 'w') {
762 isp->isp_osinfo.default_port_wwn = strtouq(sptr, &eptr, 16);
763 if (eptr < sptr + 16 || isp->isp_osinfo.default_port_wwn == 0) {
764 device_printf(dev, "mangled portwwn hint '%s'\n", sptr);
765 isp->isp_osinfo.default_port_wwn = 0;
767 isp->isp_confopts |= ISP_CFG_OWNWWPN;
770 if (isp->isp_osinfo.default_port_wwn == 0) {
771 isp->isp_osinfo.default_port_wwn = 0x400000007F000009ull;
775 tval = resource_string_value(device_get_name(dev), device_get_unit(dev),
776 "nodewwn", (const char **) &sptr);
777 if (tval == 0 && sptr != 0 && *sptr++ == 'w') {
779 isp->isp_osinfo.default_node_wwn = strtouq(sptr, &eptr, 16);
780 if (eptr < sptr + 16 || isp->isp_osinfo.default_node_wwn == 0) {
781 device_printf(dev, "mangled nodewwn hint '%s'\n", sptr);
782 isp->isp_osinfo.default_node_wwn = 0;
784 isp->isp_confopts |= ISP_CFG_OWNWWNN;
787 if (isp->isp_osinfo.default_node_wwn == 0) {
788 isp->isp_osinfo.default_node_wwn = 0x400000007F000009ull;
793 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
794 "hysteresis", &tval);
795 if (tval >= 0 && tval < 256) {
796 isp->isp_osinfo.hysteresis = tval;
798 isp->isp_osinfo.hysteresis = isp_fabric_hysteresis;
802 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
803 "loop_down_limit", &tval);
804 if (tval >= 0 && tval < 0xffff) {
805 isp->isp_osinfo.loop_down_limit = tval;
807 isp->isp_osinfo.loop_down_limit = isp_loop_down_limit;
811 (void) resource_int_value(device_get_name(dev), device_get_unit(dev),
812 "gone_device_time", &tval);
813 if (tval >= 0 && tval < 0xffff) {
814 isp->isp_osinfo.gone_device_time = tval;
816 isp->isp_osinfo.gone_device_time = isp_gone_device_time;
822 isp_pci_attach(device_t dev)
824 struct resource *regs, *irq;
825 int rtp, rgd, iqd, m1, m2;
826 uint32_t data, cmd, linesz, psize, basetype;
827 struct isp_pcisoftc *pcs;
828 ispsoftc_t *isp = NULL;
829 struct ispmdvec *mdvp;
830 #if __FreeBSD_version >= 500000
834 pcs = device_get_softc(dev);
836 device_printf(dev, "cannot get softc\n");
839 memset(pcs, 0, sizeof (*pcs));
844 * Get Generic Options
846 isp_get_generic_options(dev, isp);
849 * Check to see if options have us disabled
851 if (isp->isp_osinfo.disabled) {
853 * But return zero to preserve unit numbering
859 * Get PCI options- which in this case are just mapping preferences.
861 isp_get_pci_options(dev, &m1, &m2);
863 linesz = PCI_DFLT_LNSZ;
867 cmd = pci_read_config(dev, PCIR_COMMAND, 2);
869 rtp = (m1 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT;
870 rgd = (m1 == PCIM_CMD_MEMEN)? MEM_MAP_REG : IO_MAP_REG;
871 regs = bus_alloc_resource_any(dev, rtp, &rgd, RF_ACTIVE);
873 if (regs == NULL && (cmd & m2)) {
874 rtp = (m2 == PCIM_CMD_MEMEN)? SYS_RES_MEMORY : SYS_RES_IOPORT;
875 rgd = (m2 == PCIM_CMD_MEMEN)? MEM_MAP_REG : IO_MAP_REG;
876 regs = bus_alloc_resource_any(dev, rtp, &rgd, RF_ACTIVE);
879 device_printf(dev, "unable to map any ports\n");
883 device_printf(dev, "using %s space register mapping\n",
884 (rgd == IO_MAP_REG)? "I/O" : "Memory");
888 isp->isp_bus_tag = rman_get_bustag(regs);
889 isp->isp_bus_handle = rman_get_bushandle(regs);
891 pcs->pci_poff[BIU_BLOCK >> _BLK_REG_SHFT] = BIU_REGS_OFF;
892 pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] = PCI_MBOX_REGS_OFF;
893 pcs->pci_poff[SXP_BLOCK >> _BLK_REG_SHFT] = PCI_SXP_REGS_OFF;
894 pcs->pci_poff[RISC_BLOCK >> _BLK_REG_SHFT] = PCI_RISC_REGS_OFF;
895 pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] = DMA_REGS_OFF;
897 basetype = ISP_HA_SCSI_UNKNOWN;
898 psize = sizeof (sdparam);
899 if (pci_get_devid(dev) == PCI_QLOGIC_ISP1020) {
901 basetype = ISP_HA_SCSI_UNKNOWN;
902 psize = sizeof (sdparam);
904 if (pci_get_devid(dev) == PCI_QLOGIC_ISP1080) {
906 basetype = ISP_HA_SCSI_1080;
907 psize = sizeof (sdparam);
908 pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
909 ISP1080_DMA_REGS_OFF;
911 if (pci_get_devid(dev) == PCI_QLOGIC_ISP1240) {
913 basetype = ISP_HA_SCSI_1240;
914 psize = 2 * sizeof (sdparam);
915 pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
916 ISP1080_DMA_REGS_OFF;
918 if (pci_get_devid(dev) == PCI_QLOGIC_ISP1280) {
920 basetype = ISP_HA_SCSI_1280;
921 psize = 2 * sizeof (sdparam);
922 pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
923 ISP1080_DMA_REGS_OFF;
925 if (pci_get_devid(dev) == PCI_QLOGIC_ISP10160) {
927 basetype = ISP_HA_SCSI_10160;
928 psize = sizeof (sdparam);
929 pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
930 ISP1080_DMA_REGS_OFF;
932 if (pci_get_devid(dev) == PCI_QLOGIC_ISP12160) {
934 basetype = ISP_HA_SCSI_12160;
935 psize = 2 * sizeof (sdparam);
936 pcs->pci_poff[DMA_BLOCK >> _BLK_REG_SHFT] =
937 ISP1080_DMA_REGS_OFF;
939 if (pci_get_devid(dev) == PCI_QLOGIC_ISP2100) {
941 basetype = ISP_HA_FC_2100;
942 psize = sizeof (fcparam);
943 pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
944 PCI_MBOX_REGS2100_OFF;
945 if (pci_get_revid(dev) < 3) {
947 * XXX: Need to get the actual revision
948 * XXX: number of the 2100 FB. At any rate,
949 * XXX: lower cache line size for early revision
955 if (pci_get_devid(dev) == PCI_QLOGIC_ISP2200) {
957 basetype = ISP_HA_FC_2200;
958 psize = sizeof (fcparam);
959 pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
960 PCI_MBOX_REGS2100_OFF;
962 if (pci_get_devid(dev) == PCI_QLOGIC_ISP2300) {
964 basetype = ISP_HA_FC_2300;
965 psize = sizeof (fcparam);
966 pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
967 PCI_MBOX_REGS2300_OFF;
969 if (pci_get_devid(dev) == PCI_QLOGIC_ISP2312 ||
970 pci_get_devid(dev) == PCI_QLOGIC_ISP6312) {
972 basetype = ISP_HA_FC_2312;
973 psize = sizeof (fcparam);
974 pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
975 PCI_MBOX_REGS2300_OFF;
977 if (pci_get_devid(dev) == PCI_QLOGIC_ISP2322 ||
978 pci_get_devid(dev) == PCI_QLOGIC_ISP6322) {
980 basetype = ISP_HA_FC_2322;
981 psize = sizeof (fcparam);
982 pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
983 PCI_MBOX_REGS2300_OFF;
985 if (pci_get_devid(dev) == PCI_QLOGIC_ISP2422 ||
986 pci_get_devid(dev) == PCI_QLOGIC_ISP2432) {
988 basetype = ISP_HA_FC_2400;
989 psize = sizeof (fcparam);
990 pcs->pci_poff[MBOX_BLOCK >> _BLK_REG_SHFT] =
991 PCI_MBOX_REGS2400_OFF;
994 isp->isp_param = malloc(psize, M_DEVBUF, M_NOWAIT | M_ZERO);
995 if (isp->isp_param == NULL) {
996 device_printf(dev, "cannot allocate parameter data\n");
999 isp->isp_mdvec = mdvp;
1000 isp->isp_type = basetype;
1001 isp->isp_revision = pci_get_revid(dev);
1005 * Now that we know who we are (roughly) get/set specific options
1007 isp_get_specific_options(dev, isp);
1009 #if __FreeBSD_version >= 700000
1011 * Try and find firmware for this device.
1015 unsigned int did = pci_get_device(dev);
1018 * Map a few pci ids to fw names
1021 case PCI_PRODUCT_QLOGIC_ISP1020:
1024 case PCI_PRODUCT_QLOGIC_ISP1240:
1027 case PCI_PRODUCT_QLOGIC_ISP10160:
1028 case PCI_PRODUCT_QLOGIC_ISP12160:
1031 case PCI_PRODUCT_QLOGIC_ISP6312:
1032 case PCI_PRODUCT_QLOGIC_ISP2312:
1035 case PCI_PRODUCT_QLOGIC_ISP6322:
1038 case PCI_PRODUCT_QLOGIC_ISP2422:
1039 case PCI_PRODUCT_QLOGIC_ISP2432:
1046 isp->isp_osinfo.fw = NULL;
1047 if (isp->isp_role & ISP_ROLE_TARGET) {
1048 snprintf(fwname, sizeof (fwname), "isp_%04x_it", did);
1049 isp->isp_osinfo.fw = firmware_get(fwname);
1051 if (isp->isp_osinfo.fw == NULL) {
1052 snprintf(fwname, sizeof (fwname), "isp_%04x", did);
1053 isp->isp_osinfo.fw = firmware_get(fwname);
1055 if (isp->isp_osinfo.fw != NULL) {
1056 isp->isp_mdvec->dv_ispfw = isp->isp_osinfo.fw->data;
1060 if (isp_get_firmware_p) {
1061 int device = (int) pci_get_device(dev);
1062 #ifdef ISP_TARGET_MODE
1063 (*isp_get_firmware_p)(0, 1, device, &mdvp->dv_ispfw);
1065 (*isp_get_firmware_p)(0, 0, device, &mdvp->dv_ispfw);
1071 * Make sure that SERR, PERR, WRITE INVALIDATE and BUSMASTER
1074 cmd |= PCIM_CMD_SEREN | PCIM_CMD_PERRESPEN |
1075 PCIM_CMD_BUSMASTEREN | PCIM_CMD_INVEN;
1077 if (IS_2300(isp)) { /* per QLogic errata */
1078 cmd &= ~PCIM_CMD_INVEN;
1081 if (IS_2322(isp) || pci_get_devid(dev) == PCI_QLOGIC_ISP6312) {
1082 cmd &= ~PCIM_CMD_INTX_DISABLE;
1085 #ifdef WE_KNEW_WHAT_WE_WERE_DOING
1089 cmd &= ~PCIM_CMD_INTX_DISABLE;
1092 * Is this a PCI-X card? If so, set max read byte count.
1094 if (pci_find_extcap(dev, PCIY_PCIX, ®) == 0) {
1098 pxcmd = pci_read_config(dev, reg, 2);
1101 pci_write_config(dev, reg, 2, pxcmd);
1105 * Is this a PCI Express card? If so, set max read byte count.
1107 if (pci_find_extcap(dev, PCIY_EXPRESS, ®) == 0) {
1111 pectl = pci_read_config(dev, reg, 2);
1114 pci_write_config(dev, reg, 2, pectl);
1119 cmd &= ~PCIM_CMD_INTX_DISABLE;
1123 pci_write_config(dev, PCIR_COMMAND, cmd, 2);
1126 * Make sure the Cache Line Size register is set sensibly.
1128 data = pci_read_config(dev, PCIR_CACHELNSZ, 1);
1129 if (data == 0 || (linesz != PCI_DFLT_LNSZ && data != linesz)) {
1130 isp_prt(isp, ISP_LOGCONFIG, "set PCI line size to %d from %d",
1133 pci_write_config(dev, PCIR_CACHELNSZ, data, 1);
1137 * Make sure the Latency Timer is sane.
1139 data = pci_read_config(dev, PCIR_LATTIMER, 1);
1140 if (data < PCI_DFLT_LTNCY) {
1141 data = PCI_DFLT_LTNCY;
1142 isp_prt(isp, ISP_LOGCONFIG, "set PCI latency to %d", data);
1143 pci_write_config(dev, PCIR_LATTIMER, data, 1);
1147 * Make sure we've disabled the ROM.
1149 data = pci_read_config(dev, PCIR_ROMADDR, 4);
1151 pci_write_config(dev, PCIR_ROMADDR, data, 4);
1154 irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &iqd,
1155 RF_ACTIVE | RF_SHAREABLE);
1157 device_printf(dev, "could not allocate interrupt\n");
1161 #if __FreeBSD_version >= 500000
1162 /* Make sure the lock is set up. */
1163 mtx_init(&isp->isp_osinfo.lock, "isp", NULL, MTX_DEF);
1167 if (isp_setup_intr(dev, irq, ISP_IFLAGS, NULL, isp_pci_intr, isp,
1169 device_printf(dev, "could not setup interrupt\n");
1174 * Last minute checks...
1176 if (IS_23XX(isp) || IS_24XX(isp)) {
1177 isp->isp_port = pci_get_function(dev);
1182 * Can't tell if ROM will hang on 'ABOUT FIRMWARE' command.
1184 isp->isp_touched = 1;
1188 * Make sure we're in reset state.
1192 if (isp->isp_state != ISP_RESETSTATE) {
1197 if (isp->isp_role != ISP_ROLE_NONE && isp->isp_state != ISP_INITSTATE) {
1203 if (isp->isp_role != ISP_ROLE_NONE && isp->isp_state != ISP_RUNSTATE) {
1209 * XXXX: Here is where we might unload the f/w module
1210 * XXXX: (or decrease the reference count to it).
1218 if (pcs && pcs->ih) {
1219 (void) bus_teardown_intr(dev, irq, pcs->ih);
1222 #if __FreeBSD_version >= 500000
1223 if (locksetup && isp) {
1224 mtx_destroy(&isp->isp_osinfo.lock);
1229 (void) bus_release_resource(dev, SYS_RES_IRQ, iqd, irq);
1234 (void) bus_release_resource(dev, rtp, rgd, regs);
1238 if (pcs->pci_isp.isp_param) {
1239 #ifdef ISP_FW_CRASH_DUMP
1240 if (IS_FC(isp) && FCPARAM(isp)->isp_dump_data) {
1241 free(FCPARAM(isp)->isp_dump_data, M_DEVBUF);
1244 free(pcs->pci_isp.isp_param, M_DEVBUF);
1249 * XXXX: Here is where we might unload the f/w module
1250 * XXXX: (or decrease the reference count to it).
1256 isp_pci_detach(device_t dev)
1258 struct isp_pcisoftc *pcs;
1261 pcs = device_get_softc(dev);
1265 isp = (ispsoftc_t *) pcs;
1266 ISP_DISABLE_INTS(isp);
1271 isp_pci_intr(void *arg)
1273 ispsoftc_t *isp = arg;
1275 uint16_t sema, mbox;
1279 if (ISP_READ_ISR(isp, &isr, &sema, &mbox) == 0) {
1280 isp->isp_intbogus++;
1282 isp_intr(isp, isr, sema, mbox);
1288 #define IspVirt2Off(a, x) \
1289 (((struct isp_pcisoftc *)a)->pci_poff[((x) & _BLK_REG_MASK) >> \
1290 _BLK_REG_SHFT] + ((x) & 0xfff))
1292 #define BXR2(isp, off) \
1293 bus_space_read_2(isp->isp_bus_tag, isp->isp_bus_handle, off)
1294 #define BXW2(isp, off, v) \
1295 bus_space_write_2(isp->isp_bus_tag, isp->isp_bus_handle, off, v)
1296 #define BXR4(isp, off) \
1297 bus_space_read_4(isp->isp_bus_tag, isp->isp_bus_handle, off)
1298 #define BXW4(isp, off, v) \
1299 bus_space_write_4(isp->isp_bus_tag, isp->isp_bus_handle, off, v)
1303 isp_pci_rd_debounced(ispsoftc_t *isp, int off, uint16_t *rp)
1305 uint32_t val0, val1;
1309 val0 = BXR2(isp, IspVirt2Off(isp, off));
1310 val1 = BXR2(isp, IspVirt2Off(isp, off));
1311 } while (val0 != val1 && ++i < 1000);
1320 isp_pci_rd_isr(ispsoftc_t *isp, uint32_t *isrp,
1321 uint16_t *semap, uint16_t *mbp)
1326 if (isp_pci_rd_debounced(isp, BIU_ISR, &isr)) {
1329 if (isp_pci_rd_debounced(isp, BIU_SEMA, &sema)) {
1333 isr = BXR2(isp, IspVirt2Off(isp, BIU_ISR));
1334 sema = BXR2(isp, IspVirt2Off(isp, BIU_SEMA));
1336 isp_prt(isp, ISP_LOGDEBUG3, "ISR 0x%x SEMA 0x%x", isr, sema);
1337 isr &= INT_PENDING_MASK(isp);
1338 sema &= BIU_SEMA_LOCK;
1339 if (isr == 0 && sema == 0) {
1343 if ((*semap = sema) != 0) {
1345 if (isp_pci_rd_debounced(isp, OUTMAILBOX0, mbp)) {
1349 *mbp = BXR2(isp, IspVirt2Off(isp, OUTMAILBOX0));
1356 isp_pci_rd_isr_2300(ispsoftc_t *isp, uint32_t *isrp,
1357 uint16_t *semap, uint16_t *mbox0p)
1362 if (!(BXR2(isp, IspVirt2Off(isp, BIU_ISR) & BIU2100_ISR_RISC_INT))) {
1366 r2hisr = BXR4(isp, IspVirt2Off(isp, BIU_R2HSTSLO));
1367 isp_prt(isp, ISP_LOGDEBUG3, "RISC2HOST ISR 0x%x", r2hisr);
1368 if ((r2hisr & BIU_R2HST_INTR) == 0) {
1372 switch (r2hisr & BIU_R2HST_ISTAT_MASK) {
1373 case ISPR2HST_ROM_MBX_OK:
1374 case ISPR2HST_ROM_MBX_FAIL:
1375 case ISPR2HST_MBX_OK:
1376 case ISPR2HST_MBX_FAIL:
1377 case ISPR2HST_ASYNC_EVENT:
1378 *isrp = r2hisr & 0xffff;
1379 *mbox0p = (r2hisr >> 16);
1382 case ISPR2HST_RIO_16:
1383 *isrp = r2hisr & 0xffff;
1384 *mbox0p = ASYNC_RIO1;
1387 case ISPR2HST_FPOST:
1388 *isrp = r2hisr & 0xffff;
1389 *mbox0p = ASYNC_CMD_CMPLT;
1392 case ISPR2HST_FPOST_CTIO:
1393 *isrp = r2hisr & 0xffff;
1394 *mbox0p = ASYNC_CTIO_DONE;
1397 case ISPR2HST_RSPQ_UPDATE:
1398 *isrp = r2hisr & 0xffff;
1403 hccr = ISP_READ(isp, HCCR);
1404 if (hccr & HCCR_PAUSE) {
1405 ISP_WRITE(isp, HCCR, HCCR_RESET);
1406 isp_prt(isp, ISP_LOGERR,
1407 "RISC paused at interrupt (%x->%x)", hccr,
1408 ISP_READ(isp, HCCR));
1409 ISP_WRITE(isp, BIU_ICR, 0);
1411 isp_prt(isp, ISP_LOGERR, "unknown interrupt 0x%x\n",
1419 isp_pci_rd_isr_2400(ispsoftc_t *isp, uint32_t *isrp,
1420 uint16_t *semap, uint16_t *mbox0p)
1424 r2hisr = BXR4(isp, IspVirt2Off(isp, BIU2400_R2HSTSLO));
1425 isp_prt(isp, ISP_LOGDEBUG3, "RISC2HOST ISR 0x%x", r2hisr);
1426 if ((r2hisr & BIU2400_R2HST_INTR) == 0) {
1430 switch (r2hisr & BIU2400_R2HST_ISTAT_MASK) {
1431 case ISP2400R2HST_ROM_MBX_OK:
1432 case ISP2400R2HST_ROM_MBX_FAIL:
1433 case ISP2400R2HST_MBX_OK:
1434 case ISP2400R2HST_MBX_FAIL:
1435 case ISP2400R2HST_ASYNC_EVENT:
1436 *isrp = r2hisr & 0xffff;
1437 *mbox0p = (r2hisr >> 16);
1440 case ISP2400R2HST_RSPQ_UPDATE:
1441 case ISP2400R2HST_ATIO_RSPQ_UPDATE:
1442 case ISP2400R2HST_ATIO_RQST_UPDATE:
1443 *isrp = r2hisr & 0xffff;
1448 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
1449 isp_prt(isp, ISP_LOGERR, "unknown interrupt 0x%x\n", r2hisr);
1455 isp_pci_rd_reg(ispsoftc_t *isp, int regoff)
1460 if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
1462 * We will assume that someone has paused the RISC processor.
1464 oldconf = BXR2(isp, IspVirt2Off(isp, BIU_CONF1));
1465 BXW2(isp, IspVirt2Off(isp, BIU_CONF1),
1466 oldconf | BIU_PCI_CONF1_SXP);
1467 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1469 rv = BXR2(isp, IspVirt2Off(isp, regoff));
1470 if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
1471 BXW2(isp, IspVirt2Off(isp, BIU_CONF1), oldconf);
1472 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1478 isp_pci_wr_reg(ispsoftc_t *isp, int regoff, uint32_t val)
1482 if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
1484 * We will assume that someone has paused the RISC processor.
1486 oldconf = BXR2(isp, IspVirt2Off(isp, BIU_CONF1));
1487 BXW2(isp, IspVirt2Off(isp, BIU_CONF1),
1488 oldconf | BIU_PCI_CONF1_SXP);
1489 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1491 BXW2(isp, IspVirt2Off(isp, regoff), val);
1492 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, regoff), 2);
1493 if ((regoff & _BLK_REG_MASK) == SXP_BLOCK) {
1494 BXW2(isp, IspVirt2Off(isp, BIU_CONF1), oldconf);
1495 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1501 isp_pci_rd_reg_1080(ispsoftc_t *isp, int regoff)
1503 uint32_t rv, oc = 0;
1505 if ((regoff & _BLK_REG_MASK) == SXP_BLOCK ||
1506 (regoff & _BLK_REG_MASK) == (SXP_BLOCK|SXP_BANK1_SELECT)) {
1509 * We will assume that someone has paused the RISC processor.
1511 oc = BXR2(isp, IspVirt2Off(isp, BIU_CONF1));
1512 tc = oc & ~BIU_PCI1080_CONF1_DMA;
1513 if (regoff & SXP_BANK1_SELECT)
1514 tc |= BIU_PCI1080_CONF1_SXP1;
1516 tc |= BIU_PCI1080_CONF1_SXP0;
1517 BXW2(isp, IspVirt2Off(isp, BIU_CONF1), tc);
1518 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1519 } else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
1520 oc = BXR2(isp, IspVirt2Off(isp, BIU_CONF1));
1521 BXW2(isp, IspVirt2Off(isp, BIU_CONF1),
1522 oc | BIU_PCI1080_CONF1_DMA);
1523 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1525 rv = BXR2(isp, IspVirt2Off(isp, regoff));
1527 BXW2(isp, IspVirt2Off(isp, BIU_CONF1), oc);
1528 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1534 isp_pci_wr_reg_1080(ispsoftc_t *isp, int regoff, uint32_t val)
1538 if ((regoff & _BLK_REG_MASK) == SXP_BLOCK ||
1539 (regoff & _BLK_REG_MASK) == (SXP_BLOCK|SXP_BANK1_SELECT)) {
1542 * We will assume that someone has paused the RISC processor.
1544 oc = BXR2(isp, IspVirt2Off(isp, BIU_CONF1));
1545 tc = oc & ~BIU_PCI1080_CONF1_DMA;
1546 if (regoff & SXP_BANK1_SELECT)
1547 tc |= BIU_PCI1080_CONF1_SXP1;
1549 tc |= BIU_PCI1080_CONF1_SXP0;
1550 BXW2(isp, IspVirt2Off(isp, BIU_CONF1), tc);
1551 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1552 } else if ((regoff & _BLK_REG_MASK) == DMA_BLOCK) {
1553 oc = BXR2(isp, IspVirt2Off(isp, BIU_CONF1));
1554 BXW2(isp, IspVirt2Off(isp, BIU_CONF1),
1555 oc | BIU_PCI1080_CONF1_DMA);
1556 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1558 BXW2(isp, IspVirt2Off(isp, regoff), val);
1559 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, regoff), 2);
1561 BXW2(isp, IspVirt2Off(isp, BIU_CONF1), oc);
1562 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, BIU_CONF1), 2);
1567 isp_pci_rd_reg_2400(ispsoftc_t *isp, int regoff)
1570 int block = regoff & _BLK_REG_MASK;
1576 return (BXR2(isp, IspVirt2Off(isp, regoff)));
1578 isp_prt(isp, ISP_LOGWARN, "SXP_BLOCK read at 0x%x", regoff);
1579 return (0xffffffff);
1581 isp_prt(isp, ISP_LOGWARN, "RISC_BLOCK read at 0x%x", regoff);
1582 return (0xffffffff);
1584 isp_prt(isp, ISP_LOGWARN, "DMA_BLOCK read at 0x%x", regoff);
1585 return (0xffffffff);
1587 isp_prt(isp, ISP_LOGWARN, "unknown block read at 0x%x", regoff);
1588 return (0xffffffff);
1593 case BIU2400_FLASH_ADDR:
1594 case BIU2400_FLASH_DATA:
1598 case BIU2400_REQINP:
1599 case BIU2400_REQOUTP:
1600 case BIU2400_RSPINP:
1601 case BIU2400_RSPOUTP:
1602 case BIU2400_PRI_RQINP:
1603 case BIU2400_PRI_RSPINP:
1604 case BIU2400_ATIO_RSPINP:
1605 case BIU2400_ATIO_REQINP:
1610 rv = BXR4(isp, IspVirt2Off(isp, regoff));
1612 case BIU2400_R2HSTSLO:
1613 rv = BXR4(isp, IspVirt2Off(isp, regoff));
1615 case BIU2400_R2HSTSHI:
1616 rv = BXR4(isp, IspVirt2Off(isp, regoff)) >> 16;
1619 isp_prt(isp, ISP_LOGERR,
1620 "isp_pci_rd_reg_2400: unknown offset %x", regoff);
1628 isp_pci_wr_reg_2400(ispsoftc_t *isp, int regoff, uint32_t val)
1630 int block = regoff & _BLK_REG_MASK;
1636 BXW2(isp, IspVirt2Off(isp, regoff), val);
1637 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, regoff), 2);
1640 isp_prt(isp, ISP_LOGWARN, "SXP_BLOCK write at 0x%x", regoff);
1643 isp_prt(isp, ISP_LOGWARN, "RISC_BLOCK write at 0x%x", regoff);
1646 isp_prt(isp, ISP_LOGWARN, "DMA_BLOCK write at 0x%x", regoff);
1649 isp_prt(isp, ISP_LOGWARN, "unknown block write at 0x%x",
1655 case BIU2400_FLASH_ADDR:
1656 case BIU2400_FLASH_DATA:
1660 case BIU2400_REQINP:
1661 case BIU2400_REQOUTP:
1662 case BIU2400_RSPINP:
1663 case BIU2400_RSPOUTP:
1664 case BIU2400_PRI_RQINP:
1665 case BIU2400_PRI_RSPINP:
1666 case BIU2400_ATIO_RSPINP:
1667 case BIU2400_ATIO_REQINP:
1672 BXW4(isp, IspVirt2Off(isp, regoff), val);
1673 MEMORYBARRIER(isp, SYNC_REG, IspVirt2Off(isp, regoff), 4);
1676 isp_prt(isp, ISP_LOGERR,
1677 "isp_pci_wr_reg_2400: bad offset 0x%x", regoff);
1688 static void imc(void *, bus_dma_segment_t *, int, int);
1691 imc(void *arg, bus_dma_segment_t *segs, int nseg, int error)
1693 struct imush *imushp = (struct imush *) arg;
1695 imushp->error = error;
1697 ispsoftc_t *isp =imushp->isp;
1698 bus_addr_t addr = segs->ds_addr;
1700 isp->isp_rquest_dma = addr;
1701 addr += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
1702 isp->isp_result_dma = addr;
1704 addr += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp));
1705 FCPARAM(isp)->isp_scdma = addr;
1711 isp_pci_mbxdma(ispsoftc_t *isp)
1713 struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
1717 bus_size_t slim; /* segment size */
1718 bus_addr_t llim; /* low limit of unavailable dma */
1719 bus_addr_t hlim; /* high limit of unavailable dma */
1723 * Already been here? If so, leave...
1725 if (isp->isp_rquest) {
1729 if (isp->isp_maxcmds == 0) {
1730 isp_prt(isp, ISP_LOGERR, "maxcmds not set");
1734 hlim = BUS_SPACE_MAXADDR;
1735 if (IS_ULTRA2(isp) || IS_FC(isp) || IS_1240(isp)) {
1736 slim = (bus_size_t) (1ULL << 32);
1737 llim = BUS_SPACE_MAXADDR;
1739 llim = BUS_SPACE_MAXADDR_32BIT;
1744 * XXX: We don't really support 64 bit target mode for parallel scsi yet
1746 #ifdef ISP_TARGET_MODE
1747 if (IS_SCSI(isp) && sizeof (bus_addr_t) > 4) {
1748 isp_prt(isp, ISP_LOGERR, "we cannot do DAC for SPI cards yet");
1754 if (isp_dma_tag_create(BUS_DMA_ROOTARG(pcs->pci_dev), 1, slim, llim,
1755 hlim, NULL, NULL, BUS_SPACE_MAXSIZE, ISP_NSEGS, slim, 0,
1757 isp_prt(isp, ISP_LOGERR, "could not create master dma tag");
1763 len = sizeof (XS_T **) * isp->isp_maxcmds;
1764 isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
1765 if (isp->isp_xflist == NULL) {
1766 isp_prt(isp, ISP_LOGERR, "cannot alloc xflist array");
1770 #ifdef ISP_TARGET_MODE
1771 len = sizeof (void **) * isp->isp_maxcmds;
1772 isp->isp_tgtlist = (void **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO);
1773 if (isp->isp_tgtlist == NULL) {
1774 isp_prt(isp, ISP_LOGERR, "cannot alloc tgtlist array");
1779 len = sizeof (bus_dmamap_t) * isp->isp_maxcmds;
1780 pcs->dmaps = (bus_dmamap_t *) malloc(len, M_DEVBUF, M_WAITOK);
1781 if (pcs->dmaps == NULL) {
1782 isp_prt(isp, ISP_LOGERR, "can't alloc dma map storage");
1783 free(isp->isp_xflist, M_DEVBUF);
1784 #ifdef ISP_TARGET_MODE
1785 free(isp->isp_tgtlist, M_DEVBUF);
1792 * Allocate and map the request, result queues, plus FC scratch area.
1794 len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
1795 len += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp));
1797 len += ISP2100_SCRLEN;
1800 ns = (len / PAGE_SIZE) + 1;
1802 * Create a tag for the control spaces- force it to within 32 bits.
1804 if (isp_dma_tag_create(pcs->dmat, QENTRY_LEN, slim,
1805 BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
1806 NULL, NULL, len, ns, slim, 0, &isp->isp_cdmat)) {
1807 isp_prt(isp, ISP_LOGERR,
1808 "cannot create a dma tag for control spaces");
1809 free(pcs->dmaps, M_DEVBUF);
1810 free(isp->isp_xflist, M_DEVBUF);
1811 #ifdef ISP_TARGET_MODE
1812 free(isp->isp_tgtlist, M_DEVBUF);
1818 if (bus_dmamem_alloc(isp->isp_cdmat, (void **)&base, BUS_DMA_NOWAIT,
1819 &isp->isp_cdmap) != 0) {
1820 isp_prt(isp, ISP_LOGERR,
1821 "cannot allocate %d bytes of CCB memory", len);
1822 bus_dma_tag_destroy(isp->isp_cdmat);
1823 free(isp->isp_xflist, M_DEVBUF);
1824 #ifdef ISP_TARGET_MODE
1825 free(isp->isp_tgtlist, M_DEVBUF);
1827 free(pcs->dmaps, M_DEVBUF);
1832 for (i = 0; i < isp->isp_maxcmds; i++) {
1833 error = bus_dmamap_create(pcs->dmat, 0, &pcs->dmaps[i]);
1835 isp_prt(isp, ISP_LOGERR,
1836 "error %d creating per-cmd DMA maps", error);
1838 bus_dmamap_destroy(pcs->dmat, pcs->dmaps[i]);
1846 bus_dmamap_load(isp->isp_cdmat, isp->isp_cdmap, base, len, imc, &im, 0);
1848 isp_prt(isp, ISP_LOGERR,
1849 "error %d loading dma map for control areas", im.error);
1853 isp->isp_rquest = base;
1854 base += ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp));
1855 isp->isp_result = base;
1857 base += ISP_QUEUE_SIZE(RESULT_QUEUE_LEN(isp));
1858 FCPARAM(isp)->isp_scratch = base;
1864 bus_dmamem_free(isp->isp_cdmat, base, isp->isp_cdmap);
1865 bus_dma_tag_destroy(isp->isp_cdmat);
1866 free(isp->isp_xflist, M_DEVBUF);
1867 #ifdef ISP_TARGET_MODE
1868 free(isp->isp_tgtlist, M_DEVBUF);
1870 free(pcs->dmaps, M_DEVBUF);
1872 isp->isp_rquest = NULL;
1885 #define MUSHERR_NOQENTRIES -2
1887 #ifdef ISP_TARGET_MODE
1889 * We need to handle DMA for target mode differently from initiator mode.
1891 * DMA mapping and construction and submission of CTIO Request Entries
1892 * and rendevous for completion are very tightly coupled because we start
1893 * out by knowing (per platform) how much data we have to move, but we
1894 * don't know, up front, how many DMA mapping segments will have to be used
1895 * cover that data, so we don't know how many CTIO Request Entries we
1896 * will end up using. Further, for performance reasons we may want to
1897 * (on the last CTIO for Fibre Channel), send status too (if all went well).
1899 * The standard vector still goes through isp_pci_dmasetup, but the callback
1900 * for the DMA mapping routines comes here instead with the whole transfer
1901 * mapped and a pointer to a partially filled in already allocated request
1902 * queue entry. We finish the job.
1904 static void tdma_mk(void *, bus_dma_segment_t *, int, int);
1905 static void tdma_mkfc(void *, bus_dma_segment_t *, int, int);
1907 #define STATUS_WITH_DATA 1
1910 tdma_mk(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
1913 struct ccb_scsiio *csio;
1915 struct isp_pcisoftc *pcs;
1917 ct_entry_t *cto, *qe;
1918 uint8_t scsi_status;
1919 uint32_t curi, nxti, handle;
1922 int nth_ctio, nctios, send_status;
1924 mp = (mush_t *) arg;
1931 csio = mp->cmd_token;
1933 curi = isp->isp_reqidx;
1934 qe = (ct_entry_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, curi);
1937 cto->ct_seg_count = 0;
1938 cto->ct_header.rqs_entry_count = 1;
1939 MEMZERO(cto->ct_dataseg, sizeof(cto->ct_dataseg));
1942 cto->ct_header.rqs_seqno = 1;
1943 isp_prt(isp, ISP_LOGTDEBUG1,
1944 "CTIO[%x] lun%d iid%d tag %x flgs %x sts %x ssts %x res %d",
1945 cto->ct_fwhandle, csio->ccb_h.target_lun, cto->ct_iid,
1946 cto->ct_tag_val, cto->ct_flags, cto->ct_status,
1947 cto->ct_scsi_status, cto->ct_resid);
1948 ISP_TDQE(isp, "tdma_mk[no data]", curi, cto);
1949 isp_put_ctio(isp, cto, qe);
1953 nctios = nseg / ISP_RQDSEG;
1954 if (nseg % ISP_RQDSEG) {
1959 * Save syshandle, and potentially any SCSI status, which we'll
1960 * reinsert on the last CTIO we're going to send.
1963 handle = cto->ct_syshandle;
1964 cto->ct_syshandle = 0;
1965 cto->ct_header.rqs_seqno = 0;
1966 send_status = (cto->ct_flags & CT_SENDSTATUS) != 0;
1969 sflags = cto->ct_flags & (CT_SENDSTATUS | CT_CCINCR);
1970 cto->ct_flags &= ~(CT_SENDSTATUS | CT_CCINCR);
1972 * Preserve residual.
1974 resid = cto->ct_resid;
1977 * Save actual SCSI status.
1979 scsi_status = cto->ct_scsi_status;
1981 #ifndef STATUS_WITH_DATA
1982 sflags |= CT_NO_DATA;
1984 * We can't do a status at the same time as a data CTIO, so
1985 * we need to synthesize an extra CTIO at this level.
1990 sflags = scsi_status = resid = 0;
1994 cto->ct_scsi_status = 0;
1996 pcs = (struct isp_pcisoftc *)isp;
1997 dp = &pcs->dmaps[isp_handle_index(handle)];
1998 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
1999 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREREAD);
2001 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREWRITE);
2006 for (nth_ctio = 0; nth_ctio < nctios; nth_ctio++) {
2013 if (seglim > ISP_RQDSEG)
2014 seglim = ISP_RQDSEG;
2016 for (seg = 0; seg < seglim; seg++, nseg--) {
2018 * Unlike normal initiator commands, we don't
2019 * do any swizzling here.
2021 cto->ct_dataseg[seg].ds_count = dm_segs->ds_len;
2022 cto->ct_dataseg[seg].ds_base = dm_segs->ds_addr;
2023 cto->ct_xfrlen += dm_segs->ds_len;
2026 cto->ct_seg_count = seg;
2029 * This case should only happen when we're sending an
2030 * extra CTIO with final status.
2032 if (send_status == 0) {
2033 isp_prt(isp, ISP_LOGWARN,
2034 "tdma_mk ran out of segments");
2041 * At this point, the fields ct_lun, ct_iid, ct_tagval,
2042 * ct_tagtype, and ct_timeout have been carried over
2043 * unchanged from what our caller had set.
2045 * The dataseg fields and the seg_count fields we just got
2046 * through setting. The data direction we've preserved all
2047 * along and only clear it if we're now sending status.
2050 if (nth_ctio == nctios - 1) {
2052 * We're the last in a sequence of CTIOs, so mark
2053 * this CTIO and save the handle to the CCB such that
2054 * when this CTIO completes we can free dma resources
2055 * and do whatever else we need to do to finish the
2056 * rest of the command. We *don't* give this to the
2057 * firmware to work on- the caller will do that.
2060 cto->ct_syshandle = handle;
2061 cto->ct_header.rqs_seqno = 1;
2064 cto->ct_scsi_status = scsi_status;
2065 cto->ct_flags |= sflags;
2066 cto->ct_resid = resid;
2069 isp_prt(isp, ISP_LOGTDEBUG1,
2070 "CTIO[%x] lun%d iid %d tag %x ct_flags %x "
2071 "scsi status %x resid %d",
2072 cto->ct_fwhandle, csio->ccb_h.target_lun,
2073 cto->ct_iid, cto->ct_tag_val, cto->ct_flags,
2074 cto->ct_scsi_status, cto->ct_resid);
2076 isp_prt(isp, ISP_LOGTDEBUG1,
2077 "CTIO[%x] lun%d iid%d tag %x ct_flags 0x%x",
2078 cto->ct_fwhandle, csio->ccb_h.target_lun,
2079 cto->ct_iid, cto->ct_tag_val,
2082 isp_put_ctio(isp, cto, qe);
2083 ISP_TDQE(isp, "last tdma_mk", curi, cto);
2085 MEMORYBARRIER(isp, SYNC_REQUEST,
2089 ct_entry_t *oqe = qe;
2092 * Make sure syshandle fields are clean
2094 cto->ct_syshandle = 0;
2095 cto->ct_header.rqs_seqno = 0;
2097 isp_prt(isp, ISP_LOGTDEBUG1,
2098 "CTIO[%x] lun%d for ID%d ct_flags 0x%x",
2099 cto->ct_fwhandle, csio->ccb_h.target_lun,
2100 cto->ct_iid, cto->ct_flags);
2106 ISP_QUEUE_ENTRY(isp->isp_rquest, nxti);
2107 nxti = ISP_NXT_QENTRY(nxti, RQUEST_QUEUE_LEN(isp));
2108 if (nxti == mp->optr) {
2109 isp_prt(isp, ISP_LOGTDEBUG0,
2110 "Queue Overflow in tdma_mk");
2111 mp->error = MUSHERR_NOQENTRIES;
2116 * Now that we're done with the old CTIO,
2117 * flush it out to the request queue.
2119 ISP_TDQE(isp, "dma_tgt_fc", curi, cto);
2120 isp_put_ctio(isp, cto, oqe);
2121 if (nth_ctio != 0) {
2122 MEMORYBARRIER(isp, SYNC_REQUEST, curi,
2125 curi = ISP_NXT_QENTRY(curi, RQUEST_QUEUE_LEN(isp));
2128 * Reset some fields in the CTIO so we can reuse
2129 * for the next one we'll flush to the request
2132 cto->ct_header.rqs_entry_type = RQSTYPE_CTIO;
2133 cto->ct_header.rqs_entry_count = 1;
2134 cto->ct_header.rqs_flags = 0;
2136 cto->ct_scsi_status = 0;
2139 cto->ct_seg_count = 0;
2140 MEMZERO(cto->ct_dataseg, sizeof(cto->ct_dataseg));
2147 * We don't have to do multiple CTIOs here. Instead, we can just do
2148 * continuation segments as needed. This greatly simplifies the code
2149 * improves performance.
2153 tdma_mkfc(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
2156 struct ccb_scsiio *csio;
2158 ct2_entry_t *cto, *qe;
2159 uint32_t curi, nxti;
2164 mp = (mush_t *) arg;
2171 csio = mp->cmd_token;
2174 curi = isp->isp_reqidx;
2175 qe = (ct2_entry_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, curi);
2178 if ((cto->ct_flags & CT2_FLAG_MMASK) != CT2_FLAG_MODE1) {
2179 isp_prt(isp, ISP_LOGWARN,
2180 "dma2_tgt_fc, a status CTIO2 without MODE1 "
2181 "set (0x%x)", cto->ct_flags);
2186 * We preserve ct_lun, ct_iid, ct_rxid. We set the data
2187 * flags to NO DATA and clear relative offset flags.
2188 * We preserve the ct_resid and the response area.
2190 cto->ct_header.rqs_seqno = 1;
2191 cto->ct_seg_count = 0;
2193 isp_prt(isp, ISP_LOGTDEBUG1,
2194 "CTIO2[%x] lun %d->iid%d flgs 0x%x sts 0x%x ssts "
2195 "0x%x res %d", cto->ct_rxid, csio->ccb_h.target_lun,
2196 cto->ct_iid, cto->ct_flags, cto->ct_status,
2197 cto->rsp.m1.ct_scsi_status, cto->ct_resid);
2198 if (FCPARAM(isp)->isp_2klogin) {
2200 (ct2e_entry_t *)cto, (ct2e_entry_t *)qe);
2202 isp_put_ctio2(isp, cto, qe);
2204 ISP_TDQE(isp, "dma2_tgt_fc[no data]", curi, qe);
2208 if ((cto->ct_flags & CT2_FLAG_MMASK) != CT2_FLAG_MODE0) {
2209 isp_prt(isp, ISP_LOGERR,
2210 "dma2_tgt_fc, a data CTIO2 without MODE0 set "
2211 "(0x%x)", cto->ct_flags);
2220 * Check to see if we need to DAC addressing or not.
2222 * Any address that's over the 4GB boundary causes this
2226 if (sizeof (bus_addr_t) > 4) {
2227 for (segcnt = 0; segcnt < nseg; segcnt++) {
2228 uint64_t addr = dm_segs[segcnt].ds_addr;
2229 if (addr >= 0x100000000LL) {
2234 if (segcnt != nseg) {
2235 cto->ct_header.rqs_entry_type = RQSTYPE_CTIO3;
2236 seglim = ISP_RQDSEG_T3;
2237 ds64 = &cto->rsp.m0.u.ct_dataseg64[0];
2240 seglim = ISP_RQDSEG_T2;
2242 ds = &cto->rsp.m0.u.ct_dataseg[0];
2244 cto->ct_seg_count = 0;
2247 * Set up the CTIO2 data segments.
2249 for (segcnt = 0; cto->ct_seg_count < seglim && segcnt < nseg;
2250 cto->ct_seg_count++, segcnt++) {
2253 ((uint64_t) (dm_segs[segcnt].ds_addr) >> 32);
2254 ds64->ds_base = dm_segs[segcnt].ds_addr;
2255 ds64->ds_count = dm_segs[segcnt].ds_len;
2258 ds->ds_base = dm_segs[segcnt].ds_addr;
2259 ds->ds_count = dm_segs[segcnt].ds_len;
2262 cto->rsp.m0.ct_xfrlen += dm_segs[segcnt].ds_len;
2263 #if __FreeBSD_version < 500000
2264 isp_prt(isp, ISP_LOGTDEBUG1,
2265 "isp_send_ctio2: ent0[%d]0x%llx:%llu",
2266 cto->ct_seg_count, (uint64_t)dm_segs[segcnt].ds_addr,
2267 (uint64_t)dm_segs[segcnt].ds_len);
2269 isp_prt(isp, ISP_LOGTDEBUG1,
2270 "isp_send_ctio2: ent0[%d]0x%jx:%ju",
2271 cto->ct_seg_count, (uintmax_t)dm_segs[segcnt].ds_addr,
2272 (uintmax_t)dm_segs[segcnt].ds_len);
2276 while (segcnt < nseg) {
2279 ispcontreq_t local, *crq = &local, *qep;
2281 qep = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti);
2283 nxti = ISP_NXT_QENTRY(curip, RQUEST_QUEUE_LEN(isp));
2284 if (nxti == mp->optr) {
2286 isp_prt(isp, ISP_LOGTDEBUG0,
2287 "tdma_mkfc: request queue overflow");
2288 mp->error = MUSHERR_NOQENTRIES;
2291 cto->ct_header.rqs_entry_count++;
2292 MEMZERO((void *)crq, sizeof (*crq));
2293 crq->req_header.rqs_entry_count = 1;
2294 if (cto->ct_header.rqs_entry_type == RQSTYPE_CTIO3) {
2295 seglim = ISP_CDSEG64;
2297 ds64 = &((ispcontreq64_t *)crq)->req_dataseg[0];
2298 crq->req_header.rqs_entry_type = RQSTYPE_A64_CONT;
2301 ds = &crq->req_dataseg[0];
2303 crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
2305 for (seg = 0; segcnt < nseg && seg < seglim;
2309 ((uint64_t) (dm_segs[segcnt].ds_addr) >> 32);
2310 ds64->ds_base = dm_segs[segcnt].ds_addr;
2311 ds64->ds_count = dm_segs[segcnt].ds_len;
2314 ds->ds_base = dm_segs[segcnt].ds_addr;
2315 ds->ds_count = dm_segs[segcnt].ds_len;
2318 #if __FreeBSD_version < 500000
2319 isp_prt(isp, ISP_LOGTDEBUG1,
2320 "isp_send_ctio2: ent%d[%d]%llx:%llu",
2321 cto->ct_header.rqs_entry_count-1, seg,
2322 (uint64_t)dm_segs[segcnt].ds_addr,
2323 (uint64_t)dm_segs[segcnt].ds_len);
2325 isp_prt(isp, ISP_LOGTDEBUG1,
2326 "isp_send_ctio2: ent%d[%d]%jx:%ju",
2327 cto->ct_header.rqs_entry_count-1, seg,
2328 (uintmax_t)dm_segs[segcnt].ds_addr,
2329 (uintmax_t)dm_segs[segcnt].ds_len);
2331 cto->rsp.m0.ct_xfrlen += dm_segs[segcnt].ds_len;
2332 cto->ct_seg_count++;
2334 MEMORYBARRIER(isp, SYNC_REQUEST, curip, QENTRY_LEN);
2335 isp_put_cont_req(isp, crq, qep);
2336 ISP_TDQE(isp, "cont entry", curi, qep);
2340 * No do final twiddling for the CTIO itself.
2342 cto->ct_header.rqs_seqno = 1;
2343 isp_prt(isp, ISP_LOGTDEBUG1,
2344 "CTIO2[%x] lun %d->iid%d flgs 0x%x sts 0x%x ssts 0x%x resid %d",
2345 cto->ct_rxid, csio->ccb_h.target_lun, (int) cto->ct_iid,
2346 cto->ct_flags, cto->ct_status, cto->rsp.m1.ct_scsi_status,
2348 if (FCPARAM(isp)->isp_2klogin) {
2349 isp_put_ctio2e(isp, (ct2e_entry_t *)cto, (ct2e_entry_t *)qe);
2351 isp_put_ctio2(isp, cto, qe);
2353 ISP_TDQE(isp, "last dma2_tgt_fc", curi, qe);
2358 static void dma_2400(void *, bus_dma_segment_t *, int, int);
2359 static void dma2_a64(void *, bus_dma_segment_t *, int, int);
2360 static void dma2(void *, bus_dma_segment_t *, int, int);
2363 dma_2400(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
2367 struct ccb_scsiio *csio;
2368 struct isp_pcisoftc *pcs;
2370 bus_dma_segment_t *eseg;
2372 int seglim, datalen;
2375 mp = (mush_t *) arg;
2382 isp_prt(mp->isp, ISP_LOGERR, "bad segment count (%d)", nseg);
2387 csio = mp->cmd_token;
2390 pcs = (struct isp_pcisoftc *)mp->isp;
2391 dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
2394 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2395 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREREAD);
2397 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREWRITE);
2399 datalen = XS_XFRLEN(csio);
2402 * We're passed an initial partially filled in entry that
2403 * has most fields filled in except for data transfer
2406 * Our job is to fill in the initial request queue entry and
2407 * then to start allocating and filling in continuation entries
2408 * until we've covered the entire transfer.
2411 rq->req_header.rqs_entry_type = RQSTYPE_T7RQS;
2412 rq->req_dl = datalen;
2413 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2414 rq->req_alen_datadir = 0x2;
2416 rq->req_alen_datadir = 0x1;
2419 eseg = dm_segs + nseg;
2421 rq->req_dataseg.ds_base = DMA_LO32(dm_segs->ds_addr);
2422 rq->req_dataseg.ds_basehi = DMA_HI32(dm_segs->ds_addr);
2423 rq->req_dataseg.ds_count = dm_segs->ds_len;
2425 datalen -= dm_segs->ds_len;
2428 rq->req_seg_count++;
2430 while (datalen > 0 && dm_segs != eseg) {
2432 ispcontreq64_t local, *crq = &local, *cqe;
2434 cqe = (ispcontreq64_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti);
2436 nxti = ISP_NXT_QENTRY(onxti, RQUEST_QUEUE_LEN(isp));
2437 if (nxti == mp->optr) {
2438 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow++");
2439 mp->error = MUSHERR_NOQENTRIES;
2442 rq->req_header.rqs_entry_count++;
2443 MEMZERO((void *)crq, sizeof (*crq));
2444 crq->req_header.rqs_entry_count = 1;
2445 crq->req_header.rqs_entry_type = RQSTYPE_A64_CONT;
2448 while (datalen > 0 && seglim < ISP_CDSEG64 && dm_segs != eseg) {
2449 crq->req_dataseg[seglim].ds_base =
2450 DMA_LO32(dm_segs->ds_addr);
2451 crq->req_dataseg[seglim].ds_basehi =
2452 DMA_HI32(dm_segs->ds_addr);
2453 crq->req_dataseg[seglim].ds_count =
2455 rq->req_seg_count++;
2458 datalen -= dm_segs->ds_len;
2460 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2461 isp_print_bytes(isp, "Continuation", QENTRY_LEN, crq);
2463 isp_put_cont64_req(isp, crq, cqe);
2464 MEMORYBARRIER(isp, SYNC_REQUEST, onxti, QENTRY_LEN);
2470 dma2_a64(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
2474 struct ccb_scsiio *csio;
2475 struct isp_pcisoftc *pcs;
2477 bus_dma_segment_t *eseg;
2479 int seglim, datalen;
2482 mp = (mush_t *) arg;
2489 isp_prt(mp->isp, ISP_LOGERR, "bad segment count (%d)", nseg);
2493 csio = mp->cmd_token;
2496 pcs = (struct isp_pcisoftc *)mp->isp;
2497 dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
2500 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2501 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREREAD);
2503 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREWRITE);
2505 datalen = XS_XFRLEN(csio);
2508 * We're passed an initial partially filled in entry that
2509 * has most fields filled in except for data transfer
2512 * Our job is to fill in the initial request queue entry and
2513 * then to start allocating and filling in continuation entries
2514 * until we've covered the entire transfer.
2518 rq->req_header.rqs_entry_type = RQSTYPE_T3RQS;
2519 seglim = ISP_RQDSEG_T3;
2520 ((ispreqt3_t *)rq)->req_totalcnt = datalen;
2521 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2522 ((ispreqt3_t *)rq)->req_flags |= REQFLAG_DATA_IN;
2524 ((ispreqt3_t *)rq)->req_flags |= REQFLAG_DATA_OUT;
2527 rq->req_header.rqs_entry_type = RQSTYPE_A64;
2528 if (csio->cdb_len > 12) {
2531 seglim = ISP_RQDSEG_A64;
2533 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2534 rq->req_flags |= REQFLAG_DATA_IN;
2536 rq->req_flags |= REQFLAG_DATA_OUT;
2540 eseg = dm_segs + nseg;
2542 while (datalen != 0 && rq->req_seg_count < seglim && dm_segs != eseg) {
2544 ispreqt3_t *rq3 = (ispreqt3_t *)rq;
2545 rq3->req_dataseg[rq3->req_seg_count].ds_base =
2546 DMA_LO32(dm_segs->ds_addr);
2547 rq3->req_dataseg[rq3->req_seg_count].ds_basehi =
2548 DMA_HI32(dm_segs->ds_addr);
2549 rq3->req_dataseg[rq3->req_seg_count].ds_count =
2552 rq->req_dataseg[rq->req_seg_count].ds_base =
2553 DMA_LO32(dm_segs->ds_addr);
2554 rq->req_dataseg[rq->req_seg_count].ds_basehi =
2555 DMA_HI32(dm_segs->ds_addr);
2556 rq->req_dataseg[rq->req_seg_count].ds_count =
2559 datalen -= dm_segs->ds_len;
2560 rq->req_seg_count++;
2564 while (datalen > 0 && dm_segs != eseg) {
2566 ispcontreq64_t local, *crq = &local, *cqe;
2568 cqe = (ispcontreq64_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti);
2570 nxti = ISP_NXT_QENTRY(onxti, RQUEST_QUEUE_LEN(isp));
2571 if (nxti == mp->optr) {
2572 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow++");
2573 mp->error = MUSHERR_NOQENTRIES;
2576 rq->req_header.rqs_entry_count++;
2577 MEMZERO((void *)crq, sizeof (*crq));
2578 crq->req_header.rqs_entry_count = 1;
2579 crq->req_header.rqs_entry_type = RQSTYPE_A64_CONT;
2582 while (datalen > 0 && seglim < ISP_CDSEG64 && dm_segs != eseg) {
2583 crq->req_dataseg[seglim].ds_base =
2584 DMA_LO32(dm_segs->ds_addr);
2585 crq->req_dataseg[seglim].ds_basehi =
2586 DMA_HI32(dm_segs->ds_addr);
2587 crq->req_dataseg[seglim].ds_count =
2589 rq->req_seg_count++;
2592 datalen -= dm_segs->ds_len;
2594 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2595 isp_print_bytes(isp, "Continuation", QENTRY_LEN, crq);
2597 isp_put_cont64_req(isp, crq, cqe);
2598 MEMORYBARRIER(isp, SYNC_REQUEST, onxti, QENTRY_LEN);
2604 dma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
2608 struct ccb_scsiio *csio;
2609 struct isp_pcisoftc *pcs;
2611 bus_dma_segment_t *eseg;
2613 int seglim, datalen;
2616 mp = (mush_t *) arg;
2623 isp_prt(mp->isp, ISP_LOGERR, "bad segment count (%d)", nseg);
2627 csio = mp->cmd_token;
2630 pcs = (struct isp_pcisoftc *)mp->isp;
2631 dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
2634 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2635 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREREAD);
2637 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_PREWRITE);
2640 datalen = XS_XFRLEN(csio);
2643 * We're passed an initial partially filled in entry that
2644 * has most fields filled in except for data transfer
2647 * Our job is to fill in the initial request queue entry and
2648 * then to start allocating and filling in continuation entries
2649 * until we've covered the entire transfer.
2653 seglim = ISP_RQDSEG_T2;
2654 ((ispreqt2_t *)rq)->req_totalcnt = datalen;
2655 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2656 ((ispreqt2_t *)rq)->req_flags |= REQFLAG_DATA_IN;
2658 ((ispreqt2_t *)rq)->req_flags |= REQFLAG_DATA_OUT;
2661 if (csio->cdb_len > 12) {
2664 seglim = ISP_RQDSEG;
2666 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2667 rq->req_flags |= REQFLAG_DATA_IN;
2669 rq->req_flags |= REQFLAG_DATA_OUT;
2673 eseg = dm_segs + nseg;
2675 while (datalen != 0 && rq->req_seg_count < seglim && dm_segs != eseg) {
2677 ispreqt2_t *rq2 = (ispreqt2_t *)rq;
2678 rq2->req_dataseg[rq2->req_seg_count].ds_base =
2679 DMA_LO32(dm_segs->ds_addr);
2680 rq2->req_dataseg[rq2->req_seg_count].ds_count =
2683 rq->req_dataseg[rq->req_seg_count].ds_base =
2684 DMA_LO32(dm_segs->ds_addr);
2685 rq->req_dataseg[rq->req_seg_count].ds_count =
2688 datalen -= dm_segs->ds_len;
2689 rq->req_seg_count++;
2693 while (datalen > 0 && dm_segs != eseg) {
2695 ispcontreq_t local, *crq = &local, *cqe;
2697 cqe = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, nxti);
2699 nxti = ISP_NXT_QENTRY(onxti, RQUEST_QUEUE_LEN(isp));
2700 if (nxti == mp->optr) {
2701 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow++");
2702 mp->error = MUSHERR_NOQENTRIES;
2705 rq->req_header.rqs_entry_count++;
2706 MEMZERO((void *)crq, sizeof (*crq));
2707 crq->req_header.rqs_entry_count = 1;
2708 crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
2711 while (datalen > 0 && seglim < ISP_CDSEG && dm_segs != eseg) {
2712 crq->req_dataseg[seglim].ds_base =
2713 DMA_LO32(dm_segs->ds_addr);
2714 crq->req_dataseg[seglim].ds_count =
2716 rq->req_seg_count++;
2719 datalen -= dm_segs->ds_len;
2721 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2722 isp_print_bytes(isp, "Continuation", QENTRY_LEN, crq);
2724 isp_put_cont_req(isp, crq, cqe);
2725 MEMORYBARRIER(isp, SYNC_REQUEST, onxti, QENTRY_LEN);
2731 * We enter with ISP_LOCK held
2734 isp_pci_dmasetup(ispsoftc_t *isp, struct ccb_scsiio *csio, ispreq_t *rq,
2735 uint32_t *nxtip, uint32_t optr)
2737 struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
2739 bus_dmamap_t *dp = NULL;
2741 void (*eptr)(void *, bus_dma_segment_t *, int, int);
2743 qep = (ispreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest, isp->isp_reqidx);
2744 #ifdef ISP_TARGET_MODE
2745 if (csio->ccb_h.func_code == XPT_CONT_TARGET_IO) {
2751 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE ||
2752 (csio->dxfer_len == 0)) {
2755 mp->cmd_token = csio;
2756 mp->rq = rq; /* really a ct_entry_t or ct2_entry_t */
2760 ISPLOCK_2_CAMLOCK(isp);
2761 (*eptr)(mp, NULL, 0, 0);
2762 CAMLOCK_2_ISPLOCK(isp);
2769 } else if (sizeof (bus_addr_t) > 4) {
2776 if ((csio->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_NONE ||
2777 (csio->dxfer_len == 0)) {
2778 rq->req_seg_count = 1;
2783 * Do a virtual grapevine step to collect info for
2784 * the callback dma allocation that we have to use...
2788 mp->cmd_token = csio;
2794 ISPLOCK_2_CAMLOCK(isp);
2795 if ((csio->ccb_h.flags & CAM_SCATTER_VALID) == 0) {
2796 if ((csio->ccb_h.flags & CAM_DATA_PHYS) == 0) {
2798 dp = &pcs->dmaps[isp_handle_index(rq->req_handle)];
2800 error = bus_dmamap_load(pcs->dmat, *dp,
2801 csio->data_ptr, csio->dxfer_len, eptr, mp, 0);
2802 if (error == EINPROGRESS) {
2803 bus_dmamap_unload(pcs->dmat, *dp);
2805 isp_prt(isp, ISP_LOGERR,
2806 "deferred dma allocation not supported");
2807 } else if (error && mp->error == 0) {
2809 isp_prt(isp, ISP_LOGERR,
2810 "error %d in dma mapping code", error);
2816 /* Pointer to physical buffer */
2817 struct bus_dma_segment seg;
2818 seg.ds_addr = (bus_addr_t)(vm_offset_t)csio->data_ptr;
2819 seg.ds_len = csio->dxfer_len;
2820 (*eptr)(mp, &seg, 1, 0);
2823 struct bus_dma_segment *segs;
2825 if ((csio->ccb_h.flags & CAM_DATA_PHYS) != 0) {
2826 isp_prt(isp, ISP_LOGERR,
2827 "Physical segment pointers unsupported");
2829 } else if ((csio->ccb_h.flags & CAM_SG_LIST_PHYS) == 0) {
2830 isp_prt(isp, ISP_LOGERR,
2831 "Virtual segment addresses unsupported");
2834 /* Just use the segments provided */
2835 segs = (struct bus_dma_segment *) csio->data_ptr;
2836 (*eptr)(mp, segs, csio->sglist_cnt, 0);
2839 CAMLOCK_2_ISPLOCK(isp);
2841 int retval = CMD_COMPLETE;
2842 if (mp->error == MUSHERR_NOQENTRIES) {
2843 retval = CMD_EAGAIN;
2844 } else if (mp->error == EFBIG) {
2845 XS_SETERR(csio, CAM_REQ_TOO_BIG);
2846 } else if (mp->error == EINVAL) {
2847 XS_SETERR(csio, CAM_REQ_INVALID);
2849 XS_SETERR(csio, CAM_UNREC_HBA_ERROR);
2854 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2855 isp_print_bytes(isp, "Request Queue Entry", QENTRY_LEN, rq);
2857 switch (rq->req_header.rqs_entry_type) {
2858 case RQSTYPE_REQUEST:
2859 isp_put_request(isp, rq, qep);
2861 case RQSTYPE_CMDONLY:
2862 isp_put_extended_request(isp, (ispextreq_t *)rq,
2863 (ispextreq_t *)qep);
2866 isp_put_request_t2(isp, (ispreqt2_t *) rq, (ispreqt2_t *) qep);
2870 isp_put_request_t3(isp, (ispreqt3_t *) rq, (ispreqt3_t *) qep);
2873 isp_put_request_t7(isp, (ispreqt7_t *) rq, (ispreqt7_t *) qep);
2876 return (CMD_QUEUED);
2880 isp_pci_dmateardown(ispsoftc_t *isp, XS_T *xs, uint32_t handle)
2882 struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
2883 bus_dmamap_t *dp = &pcs->dmaps[isp_handle_index(handle)];
2884 if ((xs->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) {
2885 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_POSTREAD);
2887 bus_dmamap_sync(pcs->dmat, *dp, BUS_DMASYNC_POSTWRITE);
2889 bus_dmamap_unload(pcs->dmat, *dp);
2894 isp_pci_reset0(ispsoftc_t *isp)
2896 ISP_DISABLE_INTS(isp);
2900 isp_pci_reset1(ispsoftc_t *isp)
2902 if (!IS_24XX(isp)) {
2903 /* Make sure the BIOS is disabled */
2904 isp_pci_wr_reg(isp, HCCR, PCI_HCCR_CMD_BIOS);
2906 /* and enable interrupts */
2907 ISP_ENABLE_INTS(isp);
2911 isp_pci_dumpregs(ispsoftc_t *isp, const char *msg)
2913 struct isp_pcisoftc *pcs = (struct isp_pcisoftc *)isp;
2915 printf("%s: %s\n", device_get_nameunit(isp->isp_dev), msg);
2917 printf("%s:\n", device_get_nameunit(isp->isp_dev));
2919 printf(" biu_conf1=%x", ISP_READ(isp, BIU_CONF1));
2921 printf(" biu_csr=%x", ISP_READ(isp, BIU2100_CSR));
2922 printf(" biu_icr=%x biu_isr=%x biu_sema=%x ", ISP_READ(isp, BIU_ICR),
2923 ISP_READ(isp, BIU_ISR), ISP_READ(isp, BIU_SEMA));
2924 printf("risc_hccr=%x\n", ISP_READ(isp, HCCR));
2928 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
2929 printf(" cdma_conf=%x cdma_sts=%x cdma_fifostat=%x\n",
2930 ISP_READ(isp, CDMA_CONF), ISP_READ(isp, CDMA_STATUS),
2931 ISP_READ(isp, CDMA_FIFO_STS));
2932 printf(" ddma_conf=%x ddma_sts=%x ddma_fifostat=%x\n",
2933 ISP_READ(isp, DDMA_CONF), ISP_READ(isp, DDMA_STATUS),
2934 ISP_READ(isp, DDMA_FIFO_STS));
2935 printf(" sxp_int=%x sxp_gross=%x sxp(scsi_ctrl)=%x\n",
2936 ISP_READ(isp, SXP_INTERRUPT),
2937 ISP_READ(isp, SXP_GROSS_ERR),
2938 ISP_READ(isp, SXP_PINS_CTRL));
2939 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
2941 printf(" mbox regs: %x %x %x %x %x\n",
2942 ISP_READ(isp, OUTMAILBOX0), ISP_READ(isp, OUTMAILBOX1),
2943 ISP_READ(isp, OUTMAILBOX2), ISP_READ(isp, OUTMAILBOX3),
2944 ISP_READ(isp, OUTMAILBOX4));
2945 printf(" PCI Status Command/Status=%x\n",
2946 pci_read_config(pcs->pci_dev, PCIR_COMMAND, 1));