Deleted Added
full compact
isp.c (238486) isp.c (238869)
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 33 unchanged lines hidden (view full) ---

42 */
43#ifdef __NetBSD__
44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD$");
46#include <dev/ic/isp_netbsd.h>
47#endif
48#ifdef __FreeBSD__
49#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 33 unchanged lines hidden (view full) ---

42 */
43#ifdef __NetBSD__
44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD$");
46#include <dev/ic/isp_netbsd.h>
47#endif
48#ifdef __FreeBSD__
49#include <sys/cdefs.h>
50__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 238486 2012-07-15 14:40:49Z brueffer $");
50__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 238869 2012-07-28 20:06:29Z mjacob $");
51#include <dev/isp/isp_freebsd.h>
52#endif
53#ifdef __OpenBSD__
54#include <dev/ic/isp_openbsd.h>
55#endif
56#ifdef __linux__
57#include "isp_linux.h"
58#endif
59#ifdef __svr4__
60#include "isp_solaris.h"
61#endif
62
63/*
64 * General defines
65 */
66#define MBOX_DELAY_COUNT 1000000 / 100
67#define ISP_MARK_PORTDB(a, b, c) \
51#include <dev/isp/isp_freebsd.h>
52#endif
53#ifdef __OpenBSD__
54#include <dev/ic/isp_openbsd.h>
55#endif
56#ifdef __linux__
57#include "isp_linux.h"
58#endif
59#ifdef __svr4__
60#include "isp_solaris.h"
61#endif
62
63/*
64 * General defines
65 */
66#define MBOX_DELAY_COUNT 1000000 / 100
67#define ISP_MARK_PORTDB(a, b, c) \
68 isp_prt(isp, ISP_LOGSANCFG, \
68 isp_prt(isp, ISP_LOG_SANCFG, \
69 "Chan %d ISP_MARK_PORTDB@LINE %d", b, __LINE__); \
70 isp_mark_portdb(a, b, c)
71
72/*
73 * Local static data
74 */
75static const char fconf[] = "Chan %d PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)";
76static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";

--- 588 unchanged lines hidden (view full) ---

665 if (IS_2312(isp) && isp->isp_revision < 2) {
666 ISP_DELAY(100);
667 } else {
668 loops = MBOX_DELAY_COUNT;
669 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
670 ISP_DELAY(100);
671 if (--loops < 0) {
672 ISP_RESET0(isp);
69 "Chan %d ISP_MARK_PORTDB@LINE %d", b, __LINE__); \
70 isp_mark_portdb(a, b, c)
71
72/*
73 * Local static data
74 */
75static const char fconf[] = "Chan %d PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)";
76static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";

--- 588 unchanged lines hidden (view full) ---

665 if (IS_2312(isp) && isp->isp_revision < 2) {
666 ISP_DELAY(100);
667 } else {
668 loops = MBOX_DELAY_COUNT;
669 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
670 ISP_DELAY(100);
671 if (--loops < 0) {
672 ISP_RESET0(isp);
673 isp_prt(isp, ISP_LOGERR,
674 "MBOX_BUSY never cleared on reset");
673 isp_prt(isp, ISP_LOGERR, "MBOX_BUSY never cleared on reset");
675 return;
676 }
677 }
678 }
679
680 /*
681 * Up until this point we've done everything by just reading or
682 * setting registers. From this point on we rely on at least *some*

--- 1027 unchanged lines hidden (view full) ---

1710 *
1711 * NB: for the 2300, ICBOPT_EXTENDED is required.
1712 */
1713 if (IS_2200(isp) || IS_23XX(isp)) {
1714 icbp->icb_fwoptions |= ICBOPT_EXTENDED;
1715
1716 icbp->icb_xfwoptions = fcp->isp_xfwoptions;
1717
674 return;
675 }
676 }
677 }
678
679 /*
680 * Up until this point we've done everything by just reading or
681 * setting registers. From this point on we rely on at least *some*

--- 1027 unchanged lines hidden (view full) ---

1709 *
1710 * NB: for the 2300, ICBOPT_EXTENDED is required.
1711 */
1712 if (IS_2200(isp) || IS_23XX(isp)) {
1713 icbp->icb_fwoptions |= ICBOPT_EXTENDED;
1714
1715 icbp->icb_xfwoptions = fcp->isp_xfwoptions;
1716
1717 if (ISP_CAP_FCTAPE(isp)) {
1718 if (isp->isp_confopts & ISP_CFG_NOFCTAPE)
1719 icbp->icb_xfwoptions &= ~ICBXOPT_FCTAPE;
1720
1721 if (isp->isp_confopts & ISP_CFG_FCTAPE)
1722 icbp->icb_xfwoptions |= ICBXOPT_FCTAPE;
1723
1724 if (icbp->icb_xfwoptions & ICBXOPT_FCTAPE) {
1725 icbp->icb_fwoptions &= ~ICBOPT_FULL_LOGIN; /* per documents */
1726 icbp->icb_xfwoptions |= ICBXOPT_FCTAPE_CCQ|ICBXOPT_FCTAPE_CONFIRM;
1727 FCPARAM(isp, 0)->fctape_enabled = 1;
1728 } else {
1729 FCPARAM(isp, 0)->fctape_enabled = 0;
1730 }
1731 } else {
1732 icbp->icb_xfwoptions &= ~ICBXOPT_FCTAPE;
1733 FCPARAM(isp, 0)->fctape_enabled = 0;
1734 }
1735
1718 /*
1719 * Prefer or force Point-To-Point instead Loop?
1720 */
1721 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
1722 case ISP_CFG_NPORT:
1723 icbp->icb_xfwoptions &= ~ICBXOPT_TOPO_MASK;
1724 icbp->icb_xfwoptions |= ICBXOPT_PTP_2_LOOP;
1725 break;

--- 73 unchanged lines hidden (view full) ---

1799 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1800 MBSINIT(&mbs, MBOX_SET_FIRMWARE_OPTIONS, MBLOGALL, 0);
1801 mbs.param[1] = IFCOPT1_DISF7SWTCH|IFCOPT1_LIPASYNC|IFCOPT1_LIPF8;
1802 mbs.param[2] = 0;
1803 mbs.param[3] = 0;
1804 if (ISP_FW_NEWER_THAN(isp, 3, 16, 0)) {
1805 mbs.param[1] |= IFCOPT1_EQFQASYNC|IFCOPT1_CTIO_RETRY;
1806 if (fcp->role & ISP_ROLE_TARGET) {
1736 /*
1737 * Prefer or force Point-To-Point instead Loop?
1738 */
1739 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
1740 case ISP_CFG_NPORT:
1741 icbp->icb_xfwoptions &= ~ICBXOPT_TOPO_MASK;
1742 icbp->icb_xfwoptions |= ICBXOPT_PTP_2_LOOP;
1743 break;

--- 73 unchanged lines hidden (view full) ---

1817 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1818 MBSINIT(&mbs, MBOX_SET_FIRMWARE_OPTIONS, MBLOGALL, 0);
1819 mbs.param[1] = IFCOPT1_DISF7SWTCH|IFCOPT1_LIPASYNC|IFCOPT1_LIPF8;
1820 mbs.param[2] = 0;
1821 mbs.param[3] = 0;
1822 if (ISP_FW_NEWER_THAN(isp, 3, 16, 0)) {
1823 mbs.param[1] |= IFCOPT1_EQFQASYNC|IFCOPT1_CTIO_RETRY;
1824 if (fcp->role & ISP_ROLE_TARGET) {
1825 if (ISP_FW_NEWER_THAN(isp, 3, 25, 0)) {
1826 mbs.param[1] |= IFCOPT1_ENAPURE;
1827 }
1807 mbs.param[3] = IFCOPT3_NOPRLI;
1808 }
1809 }
1810 isp_mboxcmd(isp, &mbs);
1811 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1812 return;
1813 }
1814 }
1815 icbp->icb_logintime = ICB_LOGIN_TOV;
1828 mbs.param[3] = IFCOPT3_NOPRLI;
1829 }
1830 }
1831 isp_mboxcmd(isp, &mbs);
1832 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1833 return;
1834 }
1835 }
1836 icbp->icb_logintime = ICB_LOGIN_TOV;
1816 icbp->icb_lunetimeout = ICB_LUN_ENABLE_TOV;
1817
1837
1838#ifdef ISP_TARGET_MODE
1839 if (ISP_FW_NEWER_THAN(isp, 3, 25, 0) && (icbp->icb_fwoptions & ICBOPT_TGT_ENABLE)) {
1840 icbp->icb_lunenables = 0xffff;
1841 icbp->icb_ccnt = DFLT_CMND_CNT;
1842 icbp->icb_icnt = DFLT_INOT_CNT;
1843 icbp->icb_lunetimeout = ICB_LUN_ENABLE_TOV;
1844 }
1845#endif
1818 if (fcp->isp_wwnn && fcp->isp_wwpn && (fcp->isp_wwnn >> 60) != 2) {
1819 icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS;
1820 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwnn);
1821 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1822 isp_prt(isp, ISP_LOGDEBUG1,
1823 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x",
1824 ((uint32_t) (fcp->isp_wwnn >> 32)),
1825 ((uint32_t) (fcp->isp_wwnn)),

--- 79 unchanged lines hidden (view full) ---

1905 */
1906 for (chan = 0; chan < isp->isp_nchan; chan++) {
1907 fcp = FCPARAM(isp, chan);
1908 if (fcp->role != ISP_ROLE_NONE) {
1909 break;
1910 }
1911 }
1912 if (chan == isp->isp_nchan) {
1846 if (fcp->isp_wwnn && fcp->isp_wwpn && (fcp->isp_wwnn >> 60) != 2) {
1847 icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS;
1848 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwnn);
1849 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1850 isp_prt(isp, ISP_LOGDEBUG1,
1851 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x",
1852 ((uint32_t) (fcp->isp_wwnn >> 32)),
1853 ((uint32_t) (fcp->isp_wwnn)),

--- 79 unchanged lines hidden (view full) ---

1933 */
1934 for (chan = 0; chan < isp->isp_nchan; chan++) {
1935 fcp = FCPARAM(isp, chan);
1936 if (fcp->role != ISP_ROLE_NONE) {
1937 break;
1938 }
1939 }
1940 if (chan == isp->isp_nchan) {
1913 isp_prt(isp, ISP_LOGDEBUG0, "all %d channels with role 'none'", chan);
1941 isp_prt(isp, ISP_LOG_WARN1, "all %d channels with role 'none'", chan);
1914 isp->isp_state = ISP_INITSTATE;
1915 return;
1916 }
1917
1918 /*
1919 * Start with channel 0.
1920 */
1921 fcp = FCPARAM(isp, 0);

--- 51 unchanged lines hidden (view full) ---

1973 icbp->icb_hardaddr = 0;
1974 ownloopid = 0;
1975 }
1976
1977 if (ownloopid)
1978 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
1979
1980 icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
1942 isp->isp_state = ISP_INITSTATE;
1943 return;
1944 }
1945
1946 /*
1947 * Start with channel 0.
1948 */
1949 fcp = FCPARAM(isp, 0);

--- 51 unchanged lines hidden (view full) ---

2001 icbp->icb_hardaddr = 0;
2002 ownloopid = 0;
2003 }
2004
2005 if (ownloopid)
2006 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
2007
2008 icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
2009 if (isp->isp_confopts & ISP_CFG_NOFCTAPE) {
2010 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_FCTAPE;
2011 }
2012 if (isp->isp_confopts & ISP_CFG_FCTAPE) {
2013 icbp->icb_fwoptions2 |= ICB2400_OPT2_FCTAPE;
2014 }
2015
2016 if (icbp->icb_fwoptions2 & ICB2400_OPT2_FCTAPE) {
2017 FCPARAM(isp, chan)->fctape_enabled = 1;
2018 } else {
2019 FCPARAM(isp, chan)->fctape_enabled = 0;
2020 }
2021
1981 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
1982 case ISP_CFG_NPORT_ONLY:
1983 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1984 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_ONLY;
1985 break;
1986 case ISP_CFG_LPORT_ONLY:
1987 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1988 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_ONLY;

--- 342 unchanged lines hidden (view full) ---

2331 case PLOGX_IOCBERR_NOPCB:
2332 msg = "no PCB allocated";
2333 break;
2334 case PLOGX_IOCBERR_EINVAL:
2335 ISP_SNPRINTF(buf, sizeof (buf), "invalid parameter at offset 0x%x", parm1);
2336 msg = buf;
2337 break;
2338 case PLOGX_IOCBERR_PORTUSED:
2022 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
2023 case ISP_CFG_NPORT_ONLY:
2024 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
2025 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_ONLY;
2026 break;
2027 case ISP_CFG_LPORT_ONLY:
2028 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
2029 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_ONLY;

--- 342 unchanged lines hidden (view full) ---

2372 case PLOGX_IOCBERR_NOPCB:
2373 msg = "no PCB allocated";
2374 break;
2375 case PLOGX_IOCBERR_EINVAL:
2376 ISP_SNPRINTF(buf, sizeof (buf), "invalid parameter at offset 0x%x", parm1);
2377 msg = buf;
2378 break;
2379 case PLOGX_IOCBERR_PORTUSED:
2339 lev = ISP_LOGSANCFG|ISP_LOGDEBUG0;
2380 lev = ISP_LOG_SANCFG|ISP_LOG_WARN1;
2340 ISP_SNPRINTF(buf, sizeof (buf), "already logged in with N-Port handle 0x%x", parm1);
2341 msg = buf;
2342 rval = MBOX_PORT_ID_USED | (parm1 << 16);
2343 break;
2344 case PLOGX_IOCBERR_HNDLUSED:
2381 ISP_SNPRINTF(buf, sizeof (buf), "already logged in with N-Port handle 0x%x", parm1);
2382 msg = buf;
2383 rval = MBOX_PORT_ID_USED | (parm1 << 16);
2384 break;
2385 case PLOGX_IOCBERR_HNDLUSED:
2345 lev = ISP_LOGSANCFG|ISP_LOGDEBUG0;
2386 lev = ISP_LOG_SANCFG|ISP_LOG_WARN1;
2346 ISP_SNPRINTF(buf, sizeof (buf), "handle already used for PortID 0x%06x", parm1);
2347 msg = buf;
2348 rval = MBOX_LOOP_ID_USED;
2349 break;
2350 case PLOGX_IOCBERR_NOHANDLE:
2351 msg = "no handle allocated";
2352 break;
2353 case PLOGX_IOCBERR_NOFLOGI:

--- 29 unchanged lines hidden (view full) ---

2383 mbs.param[2] = portid >> 16;
2384 mbs.param[3] = portid;
2385 mbs.logval = MBLOGNONE;
2386 mbs.timeout = 500000;
2387 isp_mboxcmd(isp, &mbs);
2388
2389 switch (mbs.param[0]) {
2390 case MBOX_PORT_ID_USED:
2387 ISP_SNPRINTF(buf, sizeof (buf), "handle already used for PortID 0x%06x", parm1);
2388 msg = buf;
2389 rval = MBOX_LOOP_ID_USED;
2390 break;
2391 case PLOGX_IOCBERR_NOHANDLE:
2392 msg = "no handle allocated";
2393 break;
2394 case PLOGX_IOCBERR_NOFLOGI:

--- 29 unchanged lines hidden (view full) ---

2424 mbs.param[2] = portid >> 16;
2425 mbs.param[3] = portid;
2426 mbs.logval = MBLOGNONE;
2427 mbs.timeout = 500000;
2428 isp_mboxcmd(isp, &mbs);
2429
2430 switch (mbs.param[0]) {
2431 case MBOX_PORT_ID_USED:
2391 isp_prt(isp, ISP_LOGDEBUG0,
2392 "isp_port_login: portid 0x%06x already logged in as %u",
2393 portid, mbs.param[1]);
2432 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: portid 0x%06x already logged in as %u", portid, mbs.param[1]);
2394 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16));
2395
2396 case MBOX_LOOP_ID_USED:
2433 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16));
2434
2435 case MBOX_LOOP_ID_USED:
2397 isp_prt(isp, ISP_LOGDEBUG0,
2398 "isp_port_login: handle 0x%04x in use for port id 0x%02xXXXX",
2399 handle, mbs.param[1] & 0xff);
2436 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: handle 0x%04x in use for port id 0x%02xXXXX", handle, mbs.param[1] & 0xff);
2400 return (MBOX_LOOP_ID_USED);
2401
2402 case MBOX_COMMAND_COMPLETE:
2403 return (0);
2404
2405 case MBOX_COMMAND_ERROR:
2437 return (MBOX_LOOP_ID_USED);
2438
2439 case MBOX_COMMAND_COMPLETE:
2440 return (0);
2441
2442 case MBOX_COMMAND_ERROR:
2406 isp_prt(isp, ISP_LOGINFO,
2407 "isp_port_login: error 0x%x in PLOGI to port 0x%06x",
2408 mbs.param[1], portid);
2443 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: error 0x%x in PLOGI to port 0x%06x", mbs.param[1], portid);
2409 return (MBOX_COMMAND_ERROR);
2410
2411 case MBOX_ALL_IDS_USED:
2444 return (MBOX_COMMAND_ERROR);
2445
2446 case MBOX_ALL_IDS_USED:
2412 isp_prt(isp, ISP_LOGINFO,
2413 "isp_port_login: all IDs used for fabric login");
2447 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "isp_port_login: all IDs used for fabric login");
2414 return (MBOX_ALL_IDS_USED);
2415
2416 default:
2448 return (MBOX_ALL_IDS_USED);
2449
2450 default:
2417 isp_prt(isp, ISP_LOGINFO,
2418 "isp_port_login: error 0x%x on port login of 0x%06x@0x%0x",
2419 mbs.param[0], portid, handle);
2451 isp_prt(isp, ISP_LOG_SANCFG, "isp_port_login: error 0x%x on port login of 0x%06x@0x%0x", mbs.param[0], portid, handle);
2420 return (mbs.param[0]);
2421 }
2422}
2423
2424/*
2425 * Pre-24XX fabric port logout
2426 *
2427 * Note that portid is not used

--- 50 unchanged lines hidden (view full) ---

2478 if (dolock) {
2479 FC_SCRATCH_RELEASE(isp, chan);
2480 }
2481 return (mbs.param[0]);
2482 }
2483 if (IS_24XX(isp)) {
2484 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill);
2485 pdb->handle = un.bill.pdb_handle;
2452 return (mbs.param[0]);
2453 }
2454}
2455
2456/*
2457 * Pre-24XX fabric port logout
2458 *
2459 * Note that portid is not used

--- 50 unchanged lines hidden (view full) ---

2510 if (dolock) {
2511 FC_SCRATCH_RELEASE(isp, chan);
2512 }
2513 return (mbs.param[0]);
2514 }
2515 if (IS_24XX(isp)) {
2516 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill);
2517 pdb->handle = un.bill.pdb_handle;
2486 pdb->s3_role = un.bill.pdb_prli_svc3;
2518 pdb->prli_word3 = un.bill.pdb_prli_svc3;
2487 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
2488 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
2489 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
2519 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
2520 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
2521 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
2490 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2491 "Chan %d Port 0x%06x flags 0x%x curstate %x",
2492 chan, pdb->portid, un.bill.pdb_flags,
2493 un.bill.pdb_curstate);
2494 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE ||
2495 un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
2522 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Port 0x%06x flags 0x%x curstate %x", chan, pdb->portid, un.bill.pdb_flags, un.bill.pdb_curstate);
2523 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
2496 mbs.param[0] = MBOX_NOT_LOGGED_IN;
2497 if (dolock) {
2498 FC_SCRATCH_RELEASE(isp, chan);
2499 }
2500 return (mbs.param[0]);
2501 }
2502 } else {
2503 isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred);
2504 pdb->handle = un.fred.pdb_loopid;
2524 mbs.param[0] = MBOX_NOT_LOGGED_IN;
2525 if (dolock) {
2526 FC_SCRATCH_RELEASE(isp, chan);
2527 }
2528 return (mbs.param[0]);
2529 }
2530 } else {
2531 isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred);
2532 pdb->handle = un.fred.pdb_loopid;
2505 pdb->s3_role = un.fred.pdb_prli_svc3;
2533 pdb->prli_word3 = un.fred.pdb_prli_svc3;
2506 pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
2507 ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
2508 ISP_MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
2509 }
2510 if (dolock) {
2511 FC_SCRATCH_RELEASE(isp, chan);
2512 }
2513 return (0);

--- 9 unchanged lines hidden (view full) ---

2523 lim = NPH_MAX_2K;
2524 } else {
2525 lim = NPH_MAX;
2526 }
2527 for (loopid = 0; loopid != lim; loopid++) {
2528 if (isp_getpdb(isp, chan, loopid, &pdb, dolock)) {
2529 continue;
2530 }
2534 pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
2535 ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
2536 ISP_MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
2537 }
2538 if (dolock) {
2539 FC_SCRATCH_RELEASE(isp, chan);
2540 }
2541 return (0);

--- 9 unchanged lines hidden (view full) ---

2551 lim = NPH_MAX_2K;
2552 } else {
2553 lim = NPH_MAX;
2554 }
2555 for (loopid = 0; loopid != lim; loopid++) {
2556 if (isp_getpdb(isp, chan, loopid, &pdb, dolock)) {
2557 continue;
2558 }
2531 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGINFO, "Chan %d Loopid 0x%04x "
2559 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGINFO, "Chan %d Loopid 0x%04x "
2532 "PortID 0x%06x WWPN 0x%02x%02x%02x%02x%02x%02x%02x%02x",
2533 chan, loopid, pdb.portid, pdb.portname[0], pdb.portname[1],
2534 pdb.portname[2], pdb.portname[3], pdb.portname[4],
2535 pdb.portname[5], pdb.portname[6], pdb.portname[7]);
2536 }
2537}
2538
2539static uint64_t

--- 61 unchanged lines hidden (view full) ---

2601 uint8_t lwfs;
2602 int loopid;
2603 fcparam *fcp;
2604 fcportdb_t *lp;
2605 isp_pdb_t pdb;
2606
2607 fcp = FCPARAM(isp, chan);
2608
2560 "PortID 0x%06x WWPN 0x%02x%02x%02x%02x%02x%02x%02x%02x",
2561 chan, loopid, pdb.portid, pdb.portname[0], pdb.portname[1],
2562 pdb.portname[2], pdb.portname[3], pdb.portname[4],
2563 pdb.portname[5], pdb.portname[6], pdb.portname[7]);
2564 }
2565}
2566
2567static uint64_t

--- 61 unchanged lines hidden (view full) ---

2629 uint8_t lwfs;
2630 int loopid;
2631 fcparam *fcp;
2632 fcportdb_t *lp;
2633 isp_pdb_t pdb;
2634
2635 fcp = FCPARAM(isp, chan);
2636
2609 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d FC Link Test Entry", chan);
2637 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Link Test Entry", chan);
2610 ISP_MARK_PORTDB(isp, chan, 1);
2611
2612 /*
2613 * Wait up to N microseconds for F/W to go to a ready state.
2614 */
2615 lwfs = FW_CONFIG_WAIT;
2616 count = 0;
2617 while (count < usdelay) {
2618 uint64_t enano;
2619 uint32_t wrk;
2620 NANOTIME_T hra, hrb;
2621
2622 GET_NANOTIME(&hra);
2623 isp_fw_state(isp, chan);
2624 if (lwfs != fcp->isp_fwstate) {
2638 ISP_MARK_PORTDB(isp, chan, 1);
2639
2640 /*
2641 * Wait up to N microseconds for F/W to go to a ready state.
2642 */
2643 lwfs = FW_CONFIG_WAIT;
2644 count = 0;
2645 while (count < usdelay) {
2646 uint64_t enano;
2647 uint32_t wrk;
2648 NANOTIME_T hra, hrb;
2649
2650 GET_NANOTIME(&hra);
2651 isp_fw_state(isp, chan);
2652 if (lwfs != fcp->isp_fwstate) {
2625 isp_prt(isp, ISP_LOGCONFIG|ISP_LOGSANCFG, "Chan %d Firmware State <%s->%s>", chan, isp_fc_fw_statename((int)lwfs), isp_fc_fw_statename((int)fcp->isp_fwstate));
2653 isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG, "Chan %d Firmware State <%s->%s>", chan, isp_fc_fw_statename((int)lwfs), isp_fc_fw_statename((int)fcp->isp_fwstate));
2626 lwfs = fcp->isp_fwstate;
2627 }
2628 if (fcp->isp_fwstate == FW_READY) {
2629 break;
2630 }
2631 GET_NANOTIME(&hrb);
2632
2633 /*

--- 34 unchanged lines hidden (view full) ---

2668 }
2669
2670
2671
2672 /*
2673 * If we haven't gone to 'ready' state, return.
2674 */
2675 if (fcp->isp_fwstate != FW_READY) {
2654 lwfs = fcp->isp_fwstate;
2655 }
2656 if (fcp->isp_fwstate == FW_READY) {
2657 break;
2658 }
2659 GET_NANOTIME(&hrb);
2660
2661 /*

--- 34 unchanged lines hidden (view full) ---

2696 }
2697
2698
2699
2700 /*
2701 * If we haven't gone to 'ready' state, return.
2702 */
2703 if (fcp->isp_fwstate != FW_READY) {
2676 isp_prt(isp, ISP_LOGSANCFG, "%s: chan %d not at FW_READY state", __func__, chan);
2704 isp_prt(isp, ISP_LOG_SANCFG, "%s: chan %d not at FW_READY state", __func__, chan);
2677 return (-1);
2678 }
2679
2680 /*
2681 * Get our Loop ID and Port ID.
2682 */
2683 MBSINIT(&mbs, MBOX_GET_LOOP_ID, MBLOGALL, 0);
2684 mbs.param[9] = chan;

--- 48 unchanged lines hidden (view full) ---

2733 } else {
2734 int i;
2735 for (i = 0; alpa_map[i]; i++) {
2736 if (alpa_map[i] == alpa) {
2737 break;
2738 }
2739 }
2740 if (alpa_map[i] && fcp->isp_loopid != i) {
2705 return (-1);
2706 }
2707
2708 /*
2709 * Get our Loop ID and Port ID.
2710 */
2711 MBSINIT(&mbs, MBOX_GET_LOOP_ID, MBLOGALL, 0);
2712 mbs.param[9] = chan;

--- 48 unchanged lines hidden (view full) ---

2761 } else {
2762 int i;
2763 for (i = 0; alpa_map[i]; i++) {
2764 if (alpa_map[i] == alpa) {
2765 break;
2766 }
2767 }
2768 if (alpa_map[i] && fcp->isp_loopid != i) {
2741 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d deriving loopid %d from AL_PA map (AL_PA 0x%x) and ignoring returned value %d (AL_PA 0x%x)", chan, i, alpa_map[i], fcp->isp_loopid, alpa);
2769 isp_prt(isp, ISP_LOG_SANCFG,
2770 "Chan %d deriving loopid %d from AL_PA map (AL_PA 0x%x) and ignoring returned value %d (AL_PA 0x%x)",
2771 chan, i, alpa_map[i], fcp->isp_loopid, alpa);
2742 fcp->isp_loopid = i;
2743 }
2744 }
2745 }
2746
2747
2748 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE FOR 2K F/W? XXX */
2749 loopid = NPH_FL_ID;

--- 23 unchanged lines hidden (view full) ---

2773
2774 /*
2775 * Save the Fabric controller's port database entry.
2776 */
2777 lp = &fcp->portdb[FL_ID];
2778 lp->state = FC_PORTDB_STATE_PENDING_VALID;
2779 MAKE_WWN_FROM_NODE_NAME(lp->node_wwn, pdb.nodename);
2780 MAKE_WWN_FROM_NODE_NAME(lp->port_wwn, pdb.portname);
2772 fcp->isp_loopid = i;
2773 }
2774 }
2775 }
2776
2777
2778 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE FOR 2K F/W? XXX */
2779 loopid = NPH_FL_ID;

--- 23 unchanged lines hidden (view full) ---

2803
2804 /*
2805 * Save the Fabric controller's port database entry.
2806 */
2807 lp = &fcp->portdb[FL_ID];
2808 lp->state = FC_PORTDB_STATE_PENDING_VALID;
2809 MAKE_WWN_FROM_NODE_NAME(lp->node_wwn, pdb.nodename);
2810 MAKE_WWN_FROM_NODE_NAME(lp->port_wwn, pdb.portname);
2781 lp->roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
2811 lp->prli_word3 = pdb.prli_word3;
2782 lp->portid = pdb.portid;
2783 lp->handle = pdb.handle;
2784 lp->new_portid = lp->portid;
2812 lp->portid = pdb.portid;
2813 lp->handle = pdb.handle;
2814 lp->new_portid = lp->portid;
2785 lp->new_roles = lp->roles;
2815 lp->new_prli_word3 = lp->prli_word3;
2786 if (IS_24XX(isp)) {
2787 if (check_for_fabric) {
2788 /*
2789 * The mbs is still hanging out from the MBOX_GET_LOOP_ID above.
2790 */
2791 fcp->isp_fabric_params = mbs.param[7];
2816 if (IS_24XX(isp)) {
2817 if (check_for_fabric) {
2818 /*
2819 * The mbs is still hanging out from the MBOX_GET_LOOP_ID above.
2820 */
2821 fcp->isp_fabric_params = mbs.param[7];
2792 isp_prt(isp, ISP_LOGCONFIG, "fabric params 0x%x", mbs.param[7]);
2793 } else {
2794 fcp->isp_fabric_params = 0;
2795 }
2796 if (chan) {
2797 fcp->isp_sns_hdl = NPH_SNS_HDLBASE + chan;
2798 r = isp_plogx(isp, chan, fcp->isp_sns_hdl, SNS_PORT_ID, PLOGX_FLG_CMD_PLOGI | PLOGX_FLG_COND_PLOGI | PLOGX_FLG_SKIP_PRLI, 0);
2799 if (r) {
2800 isp_prt(isp, ISP_LOGWARN, "%s: Chan %d cannot log into SNS", __func__, chan);
2801 return (-1);
2802 }
2803 } else {
2804 fcp->isp_sns_hdl = NPH_SNS_ID;
2805 }
2806 r = isp_register_fc4_type_24xx(isp, chan);
2807 } else {
2808 fcp->isp_sns_hdl = SNS_ID;
2809 r = isp_register_fc4_type(isp, chan);
2810 }
2811 if (r) {
2822 } else {
2823 fcp->isp_fabric_params = 0;
2824 }
2825 if (chan) {
2826 fcp->isp_sns_hdl = NPH_SNS_HDLBASE + chan;
2827 r = isp_plogx(isp, chan, fcp->isp_sns_hdl, SNS_PORT_ID, PLOGX_FLG_CMD_PLOGI | PLOGX_FLG_COND_PLOGI | PLOGX_FLG_SKIP_PRLI, 0);
2828 if (r) {
2829 isp_prt(isp, ISP_LOGWARN, "%s: Chan %d cannot log into SNS", __func__, chan);
2830 return (-1);
2831 }
2832 } else {
2833 fcp->isp_sns_hdl = NPH_SNS_ID;
2834 }
2835 r = isp_register_fc4_type_24xx(isp, chan);
2836 } else {
2837 fcp->isp_sns_hdl = SNS_ID;
2838 r = isp_register_fc4_type(isp, chan);
2839 }
2840 if (r) {
2812 isp_prt(isp, ISP_LOGWARN|ISP_LOGSANCFG, "%s: register fc4 type failed", __func__);
2841 isp_prt(isp, ISP_LOGWARN|ISP_LOG_SANCFG, "%s: register fc4 type failed", __func__);
2813 return (-1);
2814 }
2815 } else {
2816not_on_fabric:
2817 fcp->portdb[FL_ID].state = FC_PORTDB_STATE_NIL;
2818 }
2819
2820 fcp->isp_gbspeed = 1;

--- 17 unchanged lines hidden (view full) ---

2838 fcp->isp_gbspeed = 1;
2839 }
2840 }
2841 }
2842
2843 /*
2844 * Announce ourselves, too.
2845 */
2842 return (-1);
2843 }
2844 } else {
2845not_on_fabric:
2846 fcp->portdb[FL_ID].state = FC_PORTDB_STATE_NIL;
2847 }
2848
2849 fcp->isp_gbspeed = 1;

--- 17 unchanged lines hidden (view full) ---

2867 fcp->isp_gbspeed = 1;
2868 }
2869 }
2870 }
2871
2872 /*
2873 * Announce ourselves, too.
2874 */
2846 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGCONFIG, topology, chan, (uint32_t) (fcp->isp_wwpn >> 32), (uint32_t) fcp->isp_wwpn, fcp->isp_portid, fcp->isp_loopid, isp_fc_toponame(fcp));
2847 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d FC Link Test Complete", chan);
2875 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOGCONFIG, topology, chan, (uint32_t) (fcp->isp_wwpn >> 32), (uint32_t) fcp->isp_wwpn, fcp->isp_portid, fcp->isp_loopid, isp_fc_toponame(fcp));
2876 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Link Test Complete", chan);
2848 return (0);
2849}
2850
2851/*
2852 * Complete the synchronization of our Port Database.
2853 *
2854 * At this point, we've scanned the local loop (if any) and the fabric
2855 * and performed fabric logins on all new devices.

--- 51 unchanged lines hidden (view full) ---

2907 if (isp_scan_fabric(isp, chan) != 0) {
2908 isp_prt(isp, ISP_LOGWARN,
2909 "isp_pdb_sync: isp_scan_fabric failed");
2910 return (-1);
2911 }
2912 }
2913 }
2914
2877 return (0);
2878}
2879
2880/*
2881 * Complete the synchronization of our Port Database.
2882 *
2883 * At this point, we've scanned the local loop (if any) and the fabric
2884 * and performed fabric logins on all new devices.

--- 51 unchanged lines hidden (view full) ---

2936 if (isp_scan_fabric(isp, chan) != 0) {
2937 isp_prt(isp, ISP_LOGWARN,
2938 "isp_pdb_sync: isp_scan_fabric failed");
2939 return (-1);
2940 }
2941 }
2942 }
2943
2915 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2916 "Chan %d Synchronizing PDBs", chan);
2944 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Synchronizing PDBs", chan);
2917
2918 fcp->isp_loopstate = LOOP_SYNCING_PDB;
2919
2920 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
2921 lp = &fcp->portdb[dbidx];
2922
2923 if (lp->state == FC_PORTDB_STATE_NIL || lp->target_mode) {
2924 continue;

--- 20 unchanged lines hidden (view full) ---

2945 (void) isp_plogx(isp, chan, lp->handle,
2946 lp->portid,
2947 PLOGX_FLG_CMD_LOGO |
2948 PLOGX_FLG_IMPLICIT |
2949 PLOGX_FLG_FREE_NPHDL, 0);
2950 } else {
2951 lp->autologin = 0;
2952 }
2945
2946 fcp->isp_loopstate = LOOP_SYNCING_PDB;
2947
2948 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
2949 lp = &fcp->portdb[dbidx];
2950
2951 if (lp->state == FC_PORTDB_STATE_NIL || lp->target_mode) {
2952 continue;

--- 20 unchanged lines hidden (view full) ---

2973 (void) isp_plogx(isp, chan, lp->handle,
2974 lp->portid,
2975 PLOGX_FLG_CMD_LOGO |
2976 PLOGX_FLG_IMPLICIT |
2977 PLOGX_FLG_FREE_NPHDL, 0);
2978 } else {
2979 lp->autologin = 0;
2980 }
2953 lp->new_roles = 0;
2981 lp->new_prli_word3 = 0;
2954 lp->new_portid = 0;
2955 /*
2956 * Note that we might come out of this with our state
2957 * set to FC_PORTDB_STATE_ZOMBIE.
2958 */
2959 break;
2960 case FC_PORTDB_STATE_NEW:
2961 /*
2962 * It's up to the outer layers to assign a virtual
2963 * target id in isp_dev_map (if any).
2964 */
2965 lp->portid = lp->new_portid;
2982 lp->new_portid = 0;
2983 /*
2984 * Note that we might come out of this with our state
2985 * set to FC_PORTDB_STATE_ZOMBIE.
2986 */
2987 break;
2988 case FC_PORTDB_STATE_NEW:
2989 /*
2990 * It's up to the outer layers to assign a virtual
2991 * target id in isp_dev_map (if any).
2992 */
2993 lp->portid = lp->new_portid;
2966 lp->roles = lp->new_roles;
2994 lp->prli_word3 = lp->new_prli_word3;
2967 lp->state = FC_PORTDB_STATE_VALID;
2968 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
2995 lp->state = FC_PORTDB_STATE_VALID;
2996 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
2969 lp->new_roles = 0;
2997 lp->new_prli_word3 = 0;
2970 lp->new_portid = 0;
2998 lp->new_portid = 0;
2971 lp->reserved = 0;
2972 lp->new_reserved = 0;
2999 lp->announced = 0;
2973 break;
2974 case FC_PORTDB_STATE_CHANGED:
2975/*
2976 * XXXX FIX THIS
2977 */
2978 lp->state = FC_PORTDB_STATE_VALID;
2979 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
3000 break;
3001 case FC_PORTDB_STATE_CHANGED:
3002/*
3003 * XXXX FIX THIS
3004 */
3005 lp->state = FC_PORTDB_STATE_VALID;
3006 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
2980 lp->new_roles = 0;
3007 lp->new_prli_word3 = 0;
2981 lp->new_portid = 0;
3008 lp->new_portid = 0;
2982 lp->reserved = 0;
2983 lp->new_reserved = 0;
3009 lp->announced = 0;
2984 break;
2985 case FC_PORTDB_STATE_PENDING_VALID:
2986 lp->portid = lp->new_portid;
3010 break;
3011 case FC_PORTDB_STATE_PENDING_VALID:
3012 lp->portid = lp->new_portid;
2987 lp->roles = lp->new_roles;
3013 lp->prli_word3 = lp->new_prli_word3;
2988 if (lp->dev_map_idx) {
2989 int t = lp->dev_map_idx - 1;
2990 fcp->isp_dev_map[t] = dbidx + 1;
2991 }
2992 lp->state = FC_PORTDB_STATE_VALID;
2993 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
2994 if (dbidx != FL_ID) {
3014 if (lp->dev_map_idx) {
3015 int t = lp->dev_map_idx - 1;
3016 fcp->isp_dev_map[t] = dbidx + 1;
3017 }
3018 lp->state = FC_PORTDB_STATE_VALID;
3019 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
3020 if (dbidx != FL_ID) {
2995 lp->new_roles = 0;
3021 lp->new_prli_word3 = 0;
2996 lp->new_portid = 0;
2997 }
3022 lp->new_portid = 0;
3023 }
2998 lp->reserved = 0;
2999 lp->new_reserved = 0;
3024 lp->announced = 0;
3000 break;
3001 case FC_PORTDB_STATE_ZOMBIE:
3002 break;
3003 default:
3004 isp_prt(isp, ISP_LOGWARN,
3005 "isp_scan_loop: state %d for idx %d",
3006 lp->state, dbidx);
3007 isp_dump_portdb(isp, chan);

--- 41 unchanged lines hidden (view full) ---

3049 * If we're a N-port connection, we treat this is a short loop (0..1).
3050 */
3051 switch (fcp->isp_topo) {
3052 case TOPO_NL_PORT:
3053 lim = LOCAL_LOOP_LIM;
3054 break;
3055 case TOPO_FL_PORT:
3056 if (IS_24XX(isp) && isp->isp_nchan > 1) {
3025 break;
3026 case FC_PORTDB_STATE_ZOMBIE:
3027 break;
3028 default:
3029 isp_prt(isp, ISP_LOGWARN,
3030 "isp_scan_loop: state %d for idx %d",
3031 lp->state, dbidx);
3032 isp_dump_portdb(isp, chan);

--- 41 unchanged lines hidden (view full) ---

3074 * If we're a N-port connection, we treat this is a short loop (0..1).
3075 */
3076 switch (fcp->isp_topo) {
3077 case TOPO_NL_PORT:
3078 lim = LOCAL_LOOP_LIM;
3079 break;
3080 case TOPO_FL_PORT:
3081 if (IS_24XX(isp) && isp->isp_nchan > 1) {
3057 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3058 "Chan %d Skipping Local Loop Scan", chan);
3082 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Skipping Local Loop Scan", chan);
3059 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3060 return (0);
3061 }
3062 lim = LOCAL_LOOP_LIM;
3063 break;
3064 case TOPO_N_PORT:
3065 lim = 2;
3066 break;
3067 default:
3083 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3084 return (0);
3085 }
3086 lim = LOCAL_LOOP_LIM;
3087 break;
3088 case TOPO_N_PORT:
3089 lim = 2;
3090 break;
3091 default:
3068 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3069 "Chan %d no loop topology to scan", chan);
3092 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d no loop topology to scan", chan);
3070 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3071 return (0);
3072 }
3073
3074 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
3075
3093 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3094 return (0);
3095 }
3096
3097 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
3098
3076 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3077 "Chan %d FC scan loop 0..%d", chan, lim-1);
3099 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop 0..%d", chan, lim-1);
3078
3079
3080 /*
3081 * Run through the list and get the port database info for each one.
3082 */
3083 for (handle = 0; handle < lim; handle++) {
3084 int r;
3085 /*

--- 9 unchanged lines hidden (view full) ---

3095 }
3096 /*
3097 * In older cards with older f/w GET_PORT_DATABASE has been
3098 * known to hang. This trick gets around that problem.
3099 */
3100 if (IS_2100(isp) || IS_2200(isp)) {
3101 uint64_t node_wwn = isp_get_wwn(isp, chan, handle, 1);
3102 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3100
3101
3102 /*
3103 * Run through the list and get the port database info for each one.
3104 */
3105 for (handle = 0; handle < lim; handle++) {
3106 int r;
3107 /*

--- 9 unchanged lines hidden (view full) ---

3117 }
3118 /*
3119 * In older cards with older f/w GET_PORT_DATABASE has been
3120 * known to hang. This trick gets around that problem.
3121 */
3122 if (IS_2100(isp) || IS_2200(isp)) {
3123 uint64_t node_wwn = isp_get_wwn(isp, chan, handle, 1);
3124 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3103 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3104 "Chan %d FC scan loop DONE (bad)", chan);
3125 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE (bad)", chan);
3105 return (-1);
3106 }
3107 if (node_wwn == INI_NONE) {
3108 continue;
3109 }
3110 }
3111
3112 /*
3113 * Get the port database entity for this index.
3114 */
3115 r = isp_getpdb(isp, chan, handle, &pdb, 1);
3116 if (r != 0) {
3117 isp_prt(isp, ISP_LOGDEBUG1,
3118 "Chan %d FC scan loop handle %d returned %x",
3119 chan, handle, r);
3120 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3121 ISP_MARK_PORTDB(isp, chan, 1);
3126 return (-1);
3127 }
3128 if (node_wwn == INI_NONE) {
3129 continue;
3130 }
3131 }
3132
3133 /*
3134 * Get the port database entity for this index.
3135 */
3136 r = isp_getpdb(isp, chan, handle, &pdb, 1);
3137 if (r != 0) {
3138 isp_prt(isp, ISP_LOGDEBUG1,
3139 "Chan %d FC scan loop handle %d returned %x",
3140 chan, handle, r);
3141 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3142 ISP_MARK_PORTDB(isp, chan, 1);
3122 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3123 "Chan %d FC scan loop DONE (bad)", chan);
3143 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE (bad)", chan);
3124 return (-1);
3125 }
3126 continue;
3127 }
3128
3129 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3130 ISP_MARK_PORTDB(isp, chan, 1);
3144 return (-1);
3145 }
3146 continue;
3147 }
3148
3149 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3150 ISP_MARK_PORTDB(isp, chan, 1);
3131 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3132 "Chan %d FC scan loop DONE (bad)", chan);
3151 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE (bad)", chan);
3133 return (-1);
3134 }
3135
3136 /*
3137 * On *very* old 2100 firmware we would end up sometimes
3138 * with the firmware returning the port database entry
3139 * for something else. We used to restart this, but
3140 * now we just punt.
3141 */
3142 if (IS_2100(isp) && pdb.handle != handle) {
3143 isp_prt(isp, ISP_LOGWARN,
3144 "Chan %d cannot synchronize port database", chan);
3145 ISP_MARK_PORTDB(isp, chan, 1);
3152 return (-1);
3153 }
3154
3155 /*
3156 * On *very* old 2100 firmware we would end up sometimes
3157 * with the firmware returning the port database entry
3158 * for something else. We used to restart this, but
3159 * now we just punt.
3160 */
3161 if (IS_2100(isp) && pdb.handle != handle) {
3162 isp_prt(isp, ISP_LOGWARN,
3163 "Chan %d cannot synchronize port database", chan);
3164 ISP_MARK_PORTDB(isp, chan, 1);
3146 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3147 "Chan %d FC scan loop DONE (bad)", chan);
3165 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE (bad)", chan);
3148 return (-1);
3149 }
3150
3151 /*
3152 * Save the pertinent info locally.
3153 */
3154 MAKE_WWN_FROM_NODE_NAME(tmp.node_wwn, pdb.nodename);
3155 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname);
3166 return (-1);
3167 }
3168
3169 /*
3170 * Save the pertinent info locally.
3171 */
3172 MAKE_WWN_FROM_NODE_NAME(tmp.node_wwn, pdb.nodename);
3173 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname);
3156 tmp.roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
3174 tmp.prli_word3 = pdb.prli_word3;
3157 tmp.portid = pdb.portid;
3158 tmp.handle = pdb.handle;
3159
3160 /*
3161 * Check to make sure it's still a valid entry. The 24XX seems
3162 * to return a portid but not a WWPN/WWNN or role for devices
3163 * which shift on a loop.
3164 */

--- 22 unchanged lines hidden (view full) ---

3187
3188 /*
3189 * Now search the entire port database
3190 * for the same Port and Node WWN.
3191 */
3192 for (i = 0; i < MAX_FC_TARG; i++) {
3193 lp = &fcp->portdb[i];
3194
3175 tmp.portid = pdb.portid;
3176 tmp.handle = pdb.handle;
3177
3178 /*
3179 * Check to make sure it's still a valid entry. The 24XX seems
3180 * to return a portid but not a WWPN/WWNN or role for devices
3181 * which shift on a loop.
3182 */

--- 22 unchanged lines hidden (view full) ---

3205
3206 /*
3207 * Now search the entire port database
3208 * for the same Port and Node WWN.
3209 */
3210 for (i = 0; i < MAX_FC_TARG; i++) {
3211 lp = &fcp->portdb[i];
3212
3195 if (lp->state == FC_PORTDB_STATE_NIL ||
3196 lp->target_mode) {
3213 if (lp->state == FC_PORTDB_STATE_NIL || lp->target_mode) {
3197 continue;
3198 }
3199 if (lp->node_wwn != tmp.node_wwn) {
3200 continue;
3201 }
3202 if (lp->port_wwn != tmp.port_wwn) {
3203 continue;
3204 }

--- 4 unchanged lines hidden (view full) ---

3209 */
3210 if (lp->state != FC_PORTDB_STATE_PROBATIONAL &&
3211 lp->state != FC_PORTDB_STATE_ZOMBIE) {
3212 isp_prt(isp, ISP_LOGERR,
3213 "Chan %d [%d] not probational/zombie (0x%x)",
3214 chan, i, lp->state);
3215 isp_dump_portdb(isp, chan);
3216 ISP_MARK_PORTDB(isp, chan, 1);
3214 continue;
3215 }
3216 if (lp->node_wwn != tmp.node_wwn) {
3217 continue;
3218 }
3219 if (lp->port_wwn != tmp.port_wwn) {
3220 continue;
3221 }

--- 4 unchanged lines hidden (view full) ---

3226 */
3227 if (lp->state != FC_PORTDB_STATE_PROBATIONAL &&
3228 lp->state != FC_PORTDB_STATE_ZOMBIE) {
3229 isp_prt(isp, ISP_LOGERR,
3230 "Chan %d [%d] not probational/zombie (0x%x)",
3231 chan, i, lp->state);
3232 isp_dump_portdb(isp, chan);
3233 ISP_MARK_PORTDB(isp, chan, 1);
3217 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3218 "Chan %d FC scan loop DONE (bad)", chan);
3234 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE (bad)", chan);
3219 return (-1);
3220 }
3221
3222 /*
3223 * Mark the device as something the f/w logs into
3224 * automatically.
3225 */
3226 lp->autologin = 1;
3227
3228 /*
3229 * Check to make see if really still the same
3230 * device. If it is, we mark it pending valid.
3231 */
3235 return (-1);
3236 }
3237
3238 /*
3239 * Mark the device as something the f/w logs into
3240 * automatically.
3241 */
3242 lp->autologin = 1;
3243
3244 /*
3245 * Check to make see if really still the same
3246 * device. If it is, we mark it pending valid.
3247 */
3232 if (lp->portid == tmp.portid &&
3233 lp->handle == tmp.handle &&
3234 lp->roles == tmp.roles) {
3248 if (lp->portid == tmp.portid && lp->handle == tmp.handle && lp->prli_word3 == tmp.prli_word3) {
3235 lp->new_portid = tmp.portid;
3249 lp->new_portid = tmp.portid;
3236 lp->new_roles = tmp.roles;
3250 lp->new_prli_word3 = tmp.prli_word3;
3237 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3251 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3238 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3239 "Chan %d Loop Port 0x%06x@0x%04x Pending "
3240 "Valid", chan, tmp.portid, tmp.handle);
3252 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x Pending Valid", chan, tmp.portid, tmp.handle);
3241 break;
3242 }
3243
3244 /*
3245 * We can wipe out the old handle value
3246 * here because it's no longer valid.
3247 */
3248 lp->handle = tmp.handle;
3249
3250 /*
3251 * Claim that this has changed and let somebody else
3252 * decide what to do.
3253 */
3253 break;
3254 }
3255
3256 /*
3257 * We can wipe out the old handle value
3258 * here because it's no longer valid.
3259 */
3260 lp->handle = tmp.handle;
3261
3262 /*
3263 * Claim that this has changed and let somebody else
3264 * decide what to do.
3265 */
3254 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3255 "Chan %d Loop Port 0x%06x@0x%04x changed",
3256 chan, tmp.portid, tmp.handle);
3266 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x changed", chan, tmp.portid, tmp.handle);
3257 lp->state = FC_PORTDB_STATE_CHANGED;
3258 lp->new_portid = tmp.portid;
3267 lp->state = FC_PORTDB_STATE_CHANGED;
3268 lp->new_portid = tmp.portid;
3259 lp->new_roles = tmp.roles;
3269 lp->new_prli_word3 = tmp.prli_word3;
3260 break;
3261 }
3262
3263 /*
3264 * Did we find and update an old entry?
3265 */
3266 if (i < MAX_FC_TARG) {
3267 continue;

--- 17 unchanged lines hidden (view full) ---

3285 continue;
3286 }
3287 lp = &fcp->portdb[i];
3288
3289 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3290 lp->autologin = 1;
3291 lp->state = FC_PORTDB_STATE_NEW;
3292 lp->new_portid = tmp.portid;
3270 break;
3271 }
3272
3273 /*
3274 * Did we find and update an old entry?
3275 */
3276 if (i < MAX_FC_TARG) {
3277 continue;

--- 17 unchanged lines hidden (view full) ---

3295 continue;
3296 }
3297 lp = &fcp->portdb[i];
3298
3299 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3300 lp->autologin = 1;
3301 lp->state = FC_PORTDB_STATE_NEW;
3302 lp->new_portid = tmp.portid;
3293 lp->new_roles = tmp.roles;
3303 lp->new_prli_word3 = tmp.prli_word3;
3294 lp->handle = tmp.handle;
3295 lp->port_wwn = tmp.port_wwn;
3296 lp->node_wwn = tmp.node_wwn;
3304 lp->handle = tmp.handle;
3305 lp->port_wwn = tmp.port_wwn;
3306 lp->node_wwn = tmp.node_wwn;
3297 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3298 "Chan %d Loop Port 0x%06x@0x%04x is New Entry",
3299 chan, tmp.portid, tmp.handle);
3307 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x is New Entry", chan, tmp.portid, tmp.handle);
3300 }
3301 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3308 }
3309 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3302 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3303 "Chan %d FC scan loop DONE", chan);
3310 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE", chan);
3304 return (0);
3305}
3306
3307/*
3308 * Scan the fabric for devices and add them to our port database.
3309 *
3310 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows.
3311 *

--- 26 unchanged lines hidden (view full) ---

3338 union {
3339 sns_gid_ft_req_t _x;
3340 uint8_t _y[SNS_GID_FT_REQ_SIZE];
3341 } un;
3342 fcparam *fcp = FCPARAM(isp, chan);
3343 sns_gid_ft_req_t *rq = &un._x;
3344 mbreg_t mbs;
3345
3311 return (0);
3312}
3313
3314/*
3315 * Scan the fabric for devices and add them to our port database.
3316 *
3317 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows.
3318 *

--- 26 unchanged lines hidden (view full) ---

3345 union {
3346 sns_gid_ft_req_t _x;
3347 uint8_t _y[SNS_GID_FT_REQ_SIZE];
3348 } un;
3349 fcparam *fcp = FCPARAM(isp, chan);
3350 sns_gid_ft_req_t *rq = &un._x;
3351 mbreg_t mbs;
3352
3346 isp_prt(isp, ISP_LOGDEBUG0,
3347 "Chan %d scanning fabric (GID_FT) via SNS", chan);
3353 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d scanning fabric (GID_FT) via SNS", chan);
3348
3349 ISP_MEMZERO(rq, SNS_GID_FT_REQ_SIZE);
3350 rq->snscb_rblen = GIDLEN >> 1;
3351 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + IGPOFF);
3352 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + IGPOFF);
3353 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + IGPOFF);
3354 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + IGPOFF);
3355 rq->snscb_sblen = 6;

--- 32 unchanged lines hidden (view full) ---

3388 ct_hdr_t clocal;
3389 uint8_t q[QENTRY_LEN];
3390 } un;
3391 isp_ct_pt_t *pt;
3392 ct_hdr_t *ct;
3393 uint32_t *rp;
3394 uint8_t *scp = fcp->isp_scratch;
3395
3354
3355 ISP_MEMZERO(rq, SNS_GID_FT_REQ_SIZE);
3356 rq->snscb_rblen = GIDLEN >> 1;
3357 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + IGPOFF);
3358 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + IGPOFF);
3359 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + IGPOFF);
3360 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + IGPOFF);
3361 rq->snscb_sblen = 6;

--- 32 unchanged lines hidden (view full) ---

3394 ct_hdr_t clocal;
3395 uint8_t q[QENTRY_LEN];
3396 } un;
3397 isp_ct_pt_t *pt;
3398 ct_hdr_t *ct;
3399 uint32_t *rp;
3400 uint8_t *scp = fcp->isp_scratch;
3401
3396 isp_prt(isp, ISP_LOGDEBUG0,
3397 "Chan %d scanning fabric (GID_FT) via CT", chan);
3402 isp_prt(isp, ISP_LOGDEBUG0, "Chan %d scanning fabric (GID_FT) via CT", chan);
3398
3399 if (!IS_24XX(isp)) {
3400 return (1);
3401 }
3402
3403 /*
3404 * Build a Passthrough IOCB in memory.
3405 */

--- 77 unchanged lines hidden (view full) ---

3483{
3484 fcparam *fcp = FCPARAM(isp, chan);
3485 uint32_t portid;
3486 uint16_t handle, oldhandle, loopid;
3487 isp_pdb_t pdb;
3488 int portidx, portlim, r;
3489 sns_gid_ft_rsp_t *rs0, *rs1;
3490
3403
3404 if (!IS_24XX(isp)) {
3405 return (1);
3406 }
3407
3408 /*
3409 * Build a Passthrough IOCB in memory.
3410 */

--- 77 unchanged lines hidden (view full) ---

3488{
3489 fcparam *fcp = FCPARAM(isp, chan);
3490 uint32_t portid;
3491 uint16_t handle, oldhandle, loopid;
3492 isp_pdb_t pdb;
3493 int portidx, portlim, r;
3494 sns_gid_ft_rsp_t *rs0, *rs1;
3495
3491 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3492 "Chan %d FC Scan Fabric", chan);
3493 if (fcp->isp_fwstate != FW_READY ||
3494 fcp->isp_loopstate < LOOP_LSCAN_DONE) {
3496 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Scan Fabric", chan);
3497 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_LSCAN_DONE) {
3495 return (-1);
3496 }
3497 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) {
3498 return (0);
3499 }
3500 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) {
3501 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3498 return (-1);
3499 }
3500 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) {
3501 return (0);
3502 }
3503 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) {
3504 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3502 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3503 "Chan %d FC Scan Fabric Done (no fabric)", chan);
3505 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Scan Fabric Done (no fabric)", chan);
3504 return (0);
3505 }
3506
3507 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
3508 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
3509 isp_prt(isp, ISP_LOGERR, sacq);
3510 ISP_MARK_PORTDB(isp, chan, 1);
3511 return (-1);

--- 51 unchanged lines hidden (view full) ---

3563 isp_get_gid_ft_response(isp, rs0, rs1, NGENT);
3564 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3565 FC_SCRATCH_RELEASE(isp, chan);
3566 ISP_MARK_PORTDB(isp, chan, 1);
3567 return (-1);
3568 }
3569 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) {
3570 int level;
3506 return (0);
3507 }
3508
3509 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
3510 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
3511 isp_prt(isp, ISP_LOGERR, sacq);
3512 ISP_MARK_PORTDB(isp, chan, 1);
3513 return (-1);

--- 51 unchanged lines hidden (view full) ---

3565 isp_get_gid_ft_response(isp, rs0, rs1, NGENT);
3566 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3567 FC_SCRATCH_RELEASE(isp, chan);
3568 ISP_MARK_PORTDB(isp, chan, 1);
3569 return (-1);
3570 }
3571 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) {
3572 int level;
3571 if (rs1->snscb_cthdr.ct_reason == 9 &&
3572 rs1->snscb_cthdr.ct_explanation == 7) {
3573 level = ISP_LOGSANCFG|ISP_LOGDEBUG0;
3573 if (rs1->snscb_cthdr.ct_reason == 9 && rs1->snscb_cthdr.ct_explanation == 7) {
3574 level = ISP_LOG_SANCFG;
3574 } else {
3575 level = ISP_LOGWARN;
3576 }
3577 isp_prt(isp, level, "Chan %d Fabric Nameserver rejected GID_FT"
3578 " (Reason=0x%x Expl=0x%x)", chan,
3579 rs1->snscb_cthdr.ct_reason,
3580 rs1->snscb_cthdr.ct_explanation);
3581 FC_SCRATCH_RELEASE(isp, chan);

--- 27 unchanged lines hidden (view full) ---

3609 /*
3610 * If we're not at the last entry, our list wasn't big enough.
3611 */
3612 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) {
3613 isp_prt(isp, ISP_LOGWARN,
3614 "fabric too big for scratch area: increase ISP_FC_SCRLEN");
3615 }
3616 portlim = portidx + 1;
3575 } else {
3576 level = ISP_LOGWARN;
3577 }
3578 isp_prt(isp, level, "Chan %d Fabric Nameserver rejected GID_FT"
3579 " (Reason=0x%x Expl=0x%x)", chan,
3580 rs1->snscb_cthdr.ct_reason,
3581 rs1->snscb_cthdr.ct_explanation);
3582 FC_SCRATCH_RELEASE(isp, chan);

--- 27 unchanged lines hidden (view full) ---

3610 /*
3611 * If we're not at the last entry, our list wasn't big enough.
3612 */
3613 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) {
3614 isp_prt(isp, ISP_LOGWARN,
3615 "fabric too big for scratch area: increase ISP_FC_SCRLEN");
3616 }
3617 portlim = portidx + 1;
3617 isp_prt(isp, ISP_LOGSANCFG,
3618 isp_prt(isp, ISP_LOG_SANCFG,
3618 "Chan %d got %d ports back from name server", chan, portlim);
3619
3620 for (portidx = 0; portidx < portlim; portidx++) {
3621 int npidx;
3622
3623 portid =
3624 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3625 ((rs1->snscb_ports[portidx].portid[1]) << 8) |

--- 8 unchanged lines hidden (view full) ---

3634 break;
3635 }
3636 }
3637
3638 if (npidx < portlim) {
3639 rs1->snscb_ports[npidx].portid[0] = 0;
3640 rs1->snscb_ports[npidx].portid[1] = 0;
3641 rs1->snscb_ports[npidx].portid[2] = 0;
3619 "Chan %d got %d ports back from name server", chan, portlim);
3620
3621 for (portidx = 0; portidx < portlim; portidx++) {
3622 int npidx;
3623
3624 portid =
3625 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3626 ((rs1->snscb_ports[portidx].portid[1]) << 8) |

--- 8 unchanged lines hidden (view full) ---

3635 break;
3636 }
3637 }
3638
3639 if (npidx < portlim) {
3640 rs1->snscb_ports[npidx].portid[0] = 0;
3641 rs1->snscb_ports[npidx].portid[1] = 0;
3642 rs1->snscb_ports[npidx].portid[2] = 0;
3642 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3643 "Chan %d removing duplicate PortID 0x%06x"
3644 " entry from list", chan, portid);
3643 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d removing duplicate PortID 0x%06x entry from list", chan, portid);
3645 }
3646 }
3647
3648 /*
3649 * We now have a list of Port IDs for all FC4 SCSI devices
3650 * that the Fabric Name server knows about.
3651 *
3652 * For each entry on this list go through our port database looking

--- 13 unchanged lines hidden (view full) ---

3666 int dbidx, nr;
3667
3668 portid =
3669 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3670 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3671 ((rs1->snscb_ports[portidx].portid[2]));
3672
3673 if (portid == 0) {
3644 }
3645 }
3646
3647 /*
3648 * We now have a list of Port IDs for all FC4 SCSI devices
3649 * that the Fabric Name server knows about.
3650 *
3651 * For each entry on this list go through our port database looking

--- 13 unchanged lines hidden (view full) ---

3665 int dbidx, nr;
3666
3667 portid =
3668 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3669 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3670 ((rs1->snscb_ports[portidx].portid[2]));
3671
3672 if (portid == 0) {
3674 isp_prt(isp, ISP_LOGSANCFG,
3673 isp_prt(isp, ISP_LOG_SANCFG,
3675 "Chan %d skipping null PortID at idx %d",
3676 chan, portidx);
3677 continue;
3678 }
3679
3680 /*
3681 * Skip ourselves here and on other channels. If we're
3682 * multi-id, we can't check the portids in other FCPARAM
3683 * arenas because the resolutions here aren't synchronized.
3684 * The best way to do this is to exclude looking at portids
3685 * that have the same domain and area code as our own
3686 * portid.
3687 */
3688 if (ISP_CAP_MULTI_ID(isp)) {
3689 if ((portid >> 8) == (fcp->isp_portid >> 8)) {
3674 "Chan %d skipping null PortID at idx %d",
3675 chan, portidx);
3676 continue;
3677 }
3678
3679 /*
3680 * Skip ourselves here and on other channels. If we're
3681 * multi-id, we can't check the portids in other FCPARAM
3682 * arenas because the resolutions here aren't synchronized.
3683 * The best way to do this is to exclude looking at portids
3684 * that have the same domain and area code as our own
3685 * portid.
3686 */
3687 if (ISP_CAP_MULTI_ID(isp)) {
3688 if ((portid >> 8) == (fcp->isp_portid >> 8)) {
3690 isp_prt(isp, ISP_LOGSANCFG,
3689 isp_prt(isp, ISP_LOG_SANCFG,
3691 "Chan %d skip PortID 0x%06x",
3692 chan, portid);
3693 continue;
3694 }
3695 } else if (portid == fcp->isp_portid) {
3690 "Chan %d skip PortID 0x%06x",
3691 chan, portid);
3692 continue;
3693 }
3694 } else if (portid == fcp->isp_portid) {
3696 isp_prt(isp, ISP_LOGSANCFG,
3695 isp_prt(isp, ISP_LOG_SANCFG,
3697 "Chan %d skip ourselves on @ PortID 0x%06x",
3698 chan, portid);
3699 continue;
3700 }
3701
3696 "Chan %d skip ourselves on @ PortID 0x%06x",
3697 chan, portid);
3698 continue;
3699 }
3700
3702 isp_prt(isp, ISP_LOGSANCFG,
3701 isp_prt(isp, ISP_LOG_SANCFG,
3703 "Chan %d Checking Fabric Port 0x%06x", chan, portid);
3704
3705 /*
3706 * We now search our Port Database for any
3707 * probational entries with this PortID. We don't
3708 * look for zombies here- only probational
3709 * entries (we've already logged out of zombies).
3710 */
3711 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3712 lp = &fcp->portdb[dbidx];
3713
3702 "Chan %d Checking Fabric Port 0x%06x", chan, portid);
3703
3704 /*
3705 * We now search our Port Database for any
3706 * probational entries with this PortID. We don't
3707 * look for zombies here- only probational
3708 * entries (we've already logged out of zombies).
3709 */
3710 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3711 lp = &fcp->portdb[dbidx];
3712
3714 if (lp->state != FC_PORTDB_STATE_PROBATIONAL ||
3715 lp->target_mode) {
3713 if (lp->state != FC_PORTDB_STATE_PROBATIONAL || lp->target_mode) {
3716 continue;
3717 }
3718 if (lp->portid == portid) {
3719 break;
3720 }
3721 }
3722
3723 /*

--- 25 unchanged lines hidden (view full) ---

3749 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3750 FC_SCRATCH_RELEASE(isp, chan);
3751 ISP_MARK_PORTDB(isp, chan, 1);
3752 return (-1);
3753 }
3754 if (r != 0) {
3755 lp->new_portid = portid;
3756 lp->state = FC_PORTDB_STATE_DEAD;
3714 continue;
3715 }
3716 if (lp->portid == portid) {
3717 break;
3718 }
3719 }
3720
3721 /*

--- 25 unchanged lines hidden (view full) ---

3747 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3748 FC_SCRATCH_RELEASE(isp, chan);
3749 ISP_MARK_PORTDB(isp, chan, 1);
3750 return (-1);
3751 }
3752 if (r != 0) {
3753 lp->new_portid = portid;
3754 lp->state = FC_PORTDB_STATE_DEAD;
3757 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3758 "Chan %d Fabric Port 0x%06x is dead",
3759 chan, portid);
3755 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x is dead", chan, portid);
3760 continue;
3761 }
3762
3763
3764 /*
3765 * Check to make sure that handle, portid, WWPN and
3766 * WWNN agree. If they don't, then the association
3767 * between this PortID and the stated handle has been
3768 * broken by the firmware.
3769 */
3770 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3771 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3772 if (pdb.handle != lp->handle ||
3773 pdb.portid != portid ||
3774 wwpn != lp->port_wwn ||
3775 wwnn != lp->node_wwn) {
3756 continue;
3757 }
3758
3759
3760 /*
3761 * Check to make sure that handle, portid, WWPN and
3762 * WWNN agree. If they don't, then the association
3763 * between this PortID and the stated handle has been
3764 * broken by the firmware.
3765 */
3766 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3767 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3768 if (pdb.handle != lp->handle ||
3769 pdb.portid != portid ||
3770 wwpn != lp->port_wwn ||
3771 wwnn != lp->node_wwn) {
3776 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3772 isp_prt(isp, ISP_LOG_SANCFG,
3777 fconf, chan, dbidx, pdb.handle, pdb.portid,
3778 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,
3779 (uint32_t) (wwpn >> 32), (uint32_t) wwpn,
3780 lp->handle, portid,
3781 (uint32_t) (lp->node_wwn >> 32),
3782 (uint32_t) lp->node_wwn,
3783 (uint32_t) (lp->port_wwn >> 32),
3784 (uint32_t) lp->port_wwn);

--- 34 unchanged lines hidden (view full) ---

3819 lp->state = FC_PORTDB_STATE_DEAD;
3820 continue;
3821 }
3822
3823 lp->handle = pdb.handle;
3824 handle_changed++;
3825 }
3826
3773 fconf, chan, dbidx, pdb.handle, pdb.portid,
3774 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,
3775 (uint32_t) (wwpn >> 32), (uint32_t) wwpn,
3776 lp->handle, portid,
3777 (uint32_t) (lp->node_wwn >> 32),
3778 (uint32_t) lp->node_wwn,
3779 (uint32_t) (lp->port_wwn >> 32),
3780 (uint32_t) lp->port_wwn);

--- 34 unchanged lines hidden (view full) ---

3815 lp->state = FC_PORTDB_STATE_DEAD;
3816 continue;
3817 }
3818
3819 lp->handle = pdb.handle;
3820 handle_changed++;
3821 }
3822
3827 nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
3823 nr = pdb.prli_word3;
3828
3829 /*
3830 * Check to see whether the portid and roles have
3831 * stayed the same. If they have stayed the same,
3832 * we believe that this is the same device and it
3833 * hasn't become disconnected and reconnected, so
3834 * mark it as pending valid.
3835 *
3836 * If they aren't the same, mark the device as a
3837 * changed device and save the new port id and role
3838 * and let somebody else decide.
3839 */
3840
3841 lp->new_portid = portid;
3824
3825 /*
3826 * Check to see whether the portid and roles have
3827 * stayed the same. If they have stayed the same,
3828 * we believe that this is the same device and it
3829 * hasn't become disconnected and reconnected, so
3830 * mark it as pending valid.
3831 *
3832 * If they aren't the same, mark the device as a
3833 * changed device and save the new port id and role
3834 * and let somebody else decide.
3835 */
3836
3837 lp->new_portid = portid;
3842 lp->new_roles = nr;
3843 if (pdb.portid != lp->portid || nr != lp->roles ||
3844 handle_changed) {
3845 isp_prt(isp, ISP_LOGSANCFG,
3846 "Chan %d Fabric Port 0x%06x changed",
3847 chan, portid);
3838 lp->new_prli_word3 = nr;
3839 if (pdb.portid != lp->portid || nr != lp->prli_word3 || handle_changed) {
3840 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x changed", chan, portid);
3848 lp->state = FC_PORTDB_STATE_CHANGED;
3849 } else {
3841 lp->state = FC_PORTDB_STATE_CHANGED;
3842 } else {
3850 isp_prt(isp, ISP_LOGSANCFG,
3851 "Chan %d Fabric Port 0x%06x "
3852 "Now Pending Valid", chan, portid);
3843 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x Now Pending Valid", chan, portid);
3853 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3854 }
3855 continue;
3856 }
3857
3858 /*
3859 * Ah- a new entry. Search the database again for all non-NIL
3860 * entries to make sure we never ever make a new database entry

--- 69 unchanged lines hidden (view full) ---

3930 ISP_MARK_PORTDB(isp, chan, 1);
3931 return (-1);
3932 }
3933 FCPARAM(isp, 0)->isp_lasthdl = oldhandle;
3934
3935 handle = pdb.handle;
3936 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3937 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3844 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3845 }
3846 continue;
3847 }
3848
3849 /*
3850 * Ah- a new entry. Search the database again for all non-NIL
3851 * entries to make sure we never ever make a new database entry

--- 69 unchanged lines hidden (view full) ---

3921 ISP_MARK_PORTDB(isp, chan, 1);
3922 return (-1);
3923 }
3924 FCPARAM(isp, 0)->isp_lasthdl = oldhandle;
3925
3926 handle = pdb.handle;
3927 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3928 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3938 nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
3929 nr = pdb.prli_word3;
3939
3940 /*
3941 * And go through the database *one* more time to make sure
3942 * that we do not make more than one entry that has the same
3943 * WWNN/WWPN duple
3944 */
3945 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3946 if (dbidx >= FL_ID && dbidx <= SNS_ID) {
3947 continue;
3948 }
3949 if (fcp->portdb[dbidx].target_mode) {
3950 continue;
3951 }
3930
3931 /*
3932 * And go through the database *one* more time to make sure
3933 * that we do not make more than one entry that has the same
3934 * WWNN/WWPN duple
3935 */
3936 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3937 if (dbidx >= FL_ID && dbidx <= SNS_ID) {
3938 continue;
3939 }
3940 if (fcp->portdb[dbidx].target_mode) {
3941 continue;
3942 }
3952 if (fcp->portdb[dbidx].node_wwn == wwnn &&
3953 fcp->portdb[dbidx].port_wwn == wwpn) {
3943 if (fcp->portdb[dbidx].node_wwn == wwnn && fcp->portdb[dbidx].port_wwn == wwpn) {
3954 break;
3955 }
3956 }
3957
3958 if (dbidx == MAX_FC_TARG) {
3959 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3960 lp->handle = handle;
3961 lp->node_wwn = wwnn;
3962 lp->port_wwn = wwpn;
3963 lp->new_portid = portid;
3944 break;
3945 }
3946 }
3947
3948 if (dbidx == MAX_FC_TARG) {
3949 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3950 lp->handle = handle;
3951 lp->node_wwn = wwnn;
3952 lp->port_wwn = wwpn;
3953 lp->new_portid = portid;
3964 lp->new_roles = nr;
3954 lp->new_prli_word3 = nr;
3965 lp->state = FC_PORTDB_STATE_NEW;
3955 lp->state = FC_PORTDB_STATE_NEW;
3966 isp_prt(isp, ISP_LOGSANCFG,
3967 "Chan %d Fabric Port 0x%06x is a New Entry",
3968 chan, portid);
3956 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x is a New Entry", chan, portid);
3969 continue;
3970 }
3971
3972 if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) {
3973 isp_prt(isp, ISP_LOGWARN,
3974 "Chan %d PortID 0x%x 0x%08x%08x/0x%08x%08x %ld "
3975 "already at idx %d, state 0x%x", chan, portid,
3976 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,

--- 9 unchanged lines hidden (view full) ---

3986 * are the same. For fabric devices, we
3987 * don't care that handle is different
3988 * as we assign that. If role or portid
3989 * are different, it maybe a changed device.
3990 */
3991 lp = &fcp->portdb[dbidx];
3992 lp->handle = handle;
3993 lp->new_portid = portid;
3957 continue;
3958 }
3959
3960 if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) {
3961 isp_prt(isp, ISP_LOGWARN,
3962 "Chan %d PortID 0x%x 0x%08x%08x/0x%08x%08x %ld "
3963 "already at idx %d, state 0x%x", chan, portid,
3964 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,

--- 9 unchanged lines hidden (view full) ---

3974 * are the same. For fabric devices, we
3975 * don't care that handle is different
3976 * as we assign that. If role or portid
3977 * are different, it maybe a changed device.
3978 */
3979 lp = &fcp->portdb[dbidx];
3980 lp->handle = handle;
3981 lp->new_portid = portid;
3994 lp->new_roles = nr;
3995 if (lp->portid != portid || lp->roles != nr) {
3996 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3997 "Chan %d Zombie Fabric Port 0x%06x Now Changed",
3998 chan, portid);
3982 lp->new_prli_word3 = nr;
3983 if (lp->portid != portid || lp->prli_word3 != nr) {
3984 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Changed", chan, portid);
3999 lp->state = FC_PORTDB_STATE_CHANGED;
4000 } else {
3985 lp->state = FC_PORTDB_STATE_CHANGED;
3986 } else {
4001 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
4002 "Chan %d Zombie Fabric Port 0x%06x "
4003 "Now Pending Valid", chan, portid);
3987 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Pending Valid", chan, portid);
4004 lp->state = FC_PORTDB_STATE_PENDING_VALID;
4005 }
4006 }
4007
4008 FC_SCRATCH_RELEASE(isp, chan);
4009 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
4010 ISP_MARK_PORTDB(isp, chan, 1);
4011 return (-1);
4012 }
4013 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3988 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3989 }
3990 }
3991
3992 FC_SCRATCH_RELEASE(isp, chan);
3993 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3994 ISP_MARK_PORTDB(isp, chan, 1);
3995 return (-1);
3996 }
3997 fcp->isp_loopstate = LOOP_FSCAN_DONE;
4014 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
4015 "Chan %d FC Scan Fabric Done", chan);
3998 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Scan Fabric Done", chan);
4016 return (0);
4017}
4018
4019/*
4020 * Find an unused handle and try and use to login to a port.
4021 */
4022static int
4023isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)

--- 232 unchanged lines hidden (view full) ---

4256 chan, pt->ctp_status);
4257 return (1);
4258 }
4259
4260 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct);
4261 FC_SCRATCH_RELEASE(isp, chan);
4262
4263 if (ct->ct_cmd_resp == LS_RJT) {
3999 return (0);
4000}
4001
4002/*
4003 * Find an unused handle and try and use to login to a port.
4004 */
4005static int
4006isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)

--- 232 unchanged lines hidden (view full) ---

4239 chan, pt->ctp_status);
4240 return (1);
4241 }
4242
4243 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct);
4244 FC_SCRATCH_RELEASE(isp, chan);
4245
4246 if (ct->ct_cmd_resp == LS_RJT) {
4264 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
4265 "Chan %d Register FC4 Type rejected", chan);
4247 isp_prt(isp, ISP_LOG_SANCFG|ISP_LOG_WARN1, "Chan %d Register FC4 Type rejected", chan);
4266 return (-1);
4267 } else if (ct->ct_cmd_resp == LS_ACC) {
4248 return (-1);
4249 } else if (ct->ct_cmd_resp == LS_ACC) {
4268 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
4269 "Chan %d Register FC4 Type accepted", chan);
4250 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Register FC4 Type accepted", chan);
4270 return (0);
4271 } else {
4251 return (0);
4252 } else {
4272 isp_prt(isp, ISP_LOGWARN,
4273 "Chan %d Register FC4 Type: 0x%x",
4274 chan, ct->ct_cmd_resp);
4253 isp_prt(isp, ISP_LOGWARN, "Chan %d Register FC4 Type: 0x%x", chan, ct->ct_cmd_resp);
4275 return (-1);
4276 }
4277}
4278
4279static uint16_t
4280isp_nxt_handle(ispsoftc_t *isp, int chan, uint16_t handle)
4281{
4282 int i;

--- 81 unchanged lines hidden (view full) ---

4364 * Translate the target to device handle as appropriate, checking
4365 * for correct device state as well.
4366 */
4367 target = XS_TGT(xs);
4368 if (IS_FC(isp)) {
4369 fcparam *fcp = FCPARAM(isp, XS_CHANNEL(xs));
4370
4371 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
4254 return (-1);
4255 }
4256}
4257
4258static uint16_t
4259isp_nxt_handle(ispsoftc_t *isp, int chan, uint16_t handle)
4260{
4261 int i;

--- 81 unchanged lines hidden (view full) ---

4343 * Translate the target to device handle as appropriate, checking
4344 * for correct device state as well.
4345 */
4346 target = XS_TGT(xs);
4347 if (IS_FC(isp)) {
4348 fcparam *fcp = FCPARAM(isp, XS_CHANNEL(xs));
4349
4350 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
4351 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d I am not an initiator", XS_CHANNEL(xs), target, XS_LUN(xs));
4372 XS_SETERR(xs, HBA_SELTIMEOUT);
4373 return (CMD_COMPLETE);
4374 }
4375
4376 /*
4377 * Try again later.
4378 */
4379 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {
4380 return (CMD_RQLATER);
4381 }
4382
4383 if (XS_TGT(xs) >= MAX_FC_TARG) {
4352 XS_SETERR(xs, HBA_SELTIMEOUT);
4353 return (CMD_COMPLETE);
4354 }
4355
4356 /*
4357 * Try again later.
4358 */
4359 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {
4360 return (CMD_RQLATER);
4361 }
4362
4363 if (XS_TGT(xs) >= MAX_FC_TARG) {
4364 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d target too big", XS_CHANNEL(xs), target, XS_LUN(xs));
4384 XS_SETERR(xs, HBA_SELTIMEOUT);
4385 return (CMD_COMPLETE);
4386 }
4387
4388 hdlidx = fcp->isp_dev_map[XS_TGT(xs)] - 1;
4389 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d- hdlidx value %d", XS_TGT(xs), hdlidx);
4390 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4391 XS_SETERR(xs, HBA_SELTIMEOUT);
4392 return (CMD_COMPLETE);
4393 }
4394 if (fcp->portdb[hdlidx].state == FC_PORTDB_STATE_ZOMBIE) {
4365 XS_SETERR(xs, HBA_SELTIMEOUT);
4366 return (CMD_COMPLETE);
4367 }
4368
4369 hdlidx = fcp->isp_dev_map[XS_TGT(xs)] - 1;
4370 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d- hdlidx value %d", XS_TGT(xs), hdlidx);
4371 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4372 XS_SETERR(xs, HBA_SELTIMEOUT);
4373 return (CMD_COMPLETE);
4374 }
4375 if (fcp->portdb[hdlidx].state == FC_PORTDB_STATE_ZOMBIE) {
4376 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d target zombie", XS_CHANNEL(xs), target, XS_LUN(xs));
4395 return (CMD_RQLATER);
4396 }
4397 if (fcp->portdb[hdlidx].state != FC_PORTDB_STATE_VALID) {
4377 return (CMD_RQLATER);
4378 }
4379 if (fcp->portdb[hdlidx].state != FC_PORTDB_STATE_VALID) {
4380 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d bad db port state 0x%x", XS_CHANNEL(xs), target, XS_LUN(xs), fcp->portdb[hdlidx].state);
4398 XS_SETERR(xs, HBA_SELTIMEOUT);
4399 return (CMD_COMPLETE);
4400 }
4401 target = fcp->portdb[hdlidx].handle;
4402 fcp->portdb[hdlidx].dirty = 1;
4403 } else {
4404 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
4405 if ((sdp->role & ISP_ROLE_INITIATOR) == 0) {
4381 XS_SETERR(xs, HBA_SELTIMEOUT);
4382 return (CMD_COMPLETE);
4383 }
4384 target = fcp->portdb[hdlidx].handle;
4385 fcp->portdb[hdlidx].dirty = 1;
4386 } else {
4387 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
4388 if ((sdp->role & ISP_ROLE_INITIATOR) == 0) {
4389 isp_prt(isp, ISP_LOGDEBUG1, "%d.%d.%d I am not an initiator", XS_CHANNEL(xs), target, XS_LUN(xs));
4406 XS_SETERR(xs, HBA_SELTIMEOUT);
4407 return (CMD_COMPLETE);
4408 }
4409 if (sdp->update) {
4410 isp_spi_update(isp, XS_CHANNEL(xs));
4411 }
4412 }
4413
4414 start_again:
4415
4416 qep = isp_getrqentry(isp);
4417 if (qep == NULL) {
4390 XS_SETERR(xs, HBA_SELTIMEOUT);
4391 return (CMD_COMPLETE);
4392 }
4393 if (sdp->update) {
4394 isp_spi_update(isp, XS_CHANNEL(xs));
4395 }
4396 }
4397
4398 start_again:
4399
4400 qep = isp_getrqentry(isp);
4401 if (qep == NULL) {
4418 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow");
4402 isp_prt(isp, ISP_LOG_WARN1, "Request Queue Overflow");
4419 XS_SETERR(xs, HBA_BOTCH);
4420 return (CMD_EAGAIN);
4421 }
4422 XS_SETERR(xs, HBA_NOERROR);
4423
4424 /*
4425 * Now see if we need to synchronize the ISP with respect to anything.
4426 * We do dual duty here (cough) for synchronizing for busses other

--- 17 unchanged lines hidden (view full) ---

4444 isp_put_marker(isp, m, qep);
4445 }
4446 ISP_SYNC_REQUEST(isp);
4447 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 0);
4448 goto start_again;
4449 }
4450
4451 reqp->req_header.rqs_entry_count = 1;
4403 XS_SETERR(xs, HBA_BOTCH);
4404 return (CMD_EAGAIN);
4405 }
4406 XS_SETERR(xs, HBA_NOERROR);
4407
4408 /*
4409 * Now see if we need to synchronize the ISP with respect to anything.
4410 * We do dual duty here (cough) for synchronizing for busses other

--- 17 unchanged lines hidden (view full) ---

4428 isp_put_marker(isp, m, qep);
4429 }
4430 ISP_SYNC_REQUEST(isp);
4431 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 0);
4432 goto start_again;
4433 }
4434
4435 reqp->req_header.rqs_entry_count = 1;
4436
4437 /*
4438 * Select and install Header Code.
4439 * Note that it might be overridden before going out
4440 * if we're on a 64 bit platform. The lower level
4441 * code (isp_send_cmd) will select the appropriate
4442 * 64 bit variant if it needs to.
4443 */
4452 if (IS_24XX(isp)) {
4453 reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS;
4454 } else if (IS_FC(isp)) {
4455 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS;
4456 } else {
4457 if (XS_CDBLEN(xs) > 12) {
4458 reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY;
4459 } else {
4460 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;
4461 }
4462 }
4463
4444 if (IS_24XX(isp)) {
4445 reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS;
4446 } else if (IS_FC(isp)) {
4447 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS;
4448 } else {
4449 if (XS_CDBLEN(xs) > 12) {
4450 reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY;
4451 } else {
4452 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;
4453 }
4454 }
4455
4456 /*
4457 * Set task attributes
4458 */
4464 if (IS_24XX(isp)) {
4465 int ttype;
4466 if (XS_TAG_P(xs)) {
4467 ttype = XS_TAG_TYPE(xs);
4468 } else {
4469 if (XS_CDBP(xs)[0] == 0x3) {
4470 ttype = REQFLAG_HTAG;
4471 } else {

--- 36 unchanged lines hidden (view full) ---

4508 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && XS_TAG_P(xs)) {
4509 reqp->req_flags = XS_TAG_TYPE(xs);
4510 }
4511 }
4512
4513 tptr = &reqp->req_time;
4514
4515 /*
4459 if (IS_24XX(isp)) {
4460 int ttype;
4461 if (XS_TAG_P(xs)) {
4462 ttype = XS_TAG_TYPE(xs);
4463 } else {
4464 if (XS_CDBP(xs)[0] == 0x3) {
4465 ttype = REQFLAG_HTAG;
4466 } else {

--- 36 unchanged lines hidden (view full) ---

4503 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && XS_TAG_P(xs)) {
4504 reqp->req_flags = XS_TAG_TYPE(xs);
4505 }
4506 }
4507
4508 tptr = &reqp->req_time;
4509
4510 /*
4516 * NB: we do not support long CDBs
4511 * NB: we do not support long CDBs (yet)
4517 */
4518 cdblen = XS_CDBLEN(xs);
4519
4520 if (IS_SCSI(isp)) {
4512 */
4513 cdblen = XS_CDBLEN(xs);
4514
4515 if (IS_SCSI(isp)) {
4516 if (cdblen > sizeof (reqp->req_cdb)) {
4517 isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen);
4518 XS_SETERR(xs, HBA_BOTCH);
4519 return (CMD_COMPLETE);
4520 }
4521 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
4522 reqp->req_lun_trn = XS_LUN(xs);
4521 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
4522 reqp->req_lun_trn = XS_LUN(xs);
4523 cdblen = ISP_MIN(cdblen, sizeof (reqp->req_cdb));
4524 cdbp = reqp->req_cdb;
4525 reqp->req_cdblen = cdblen;
4526 } else if (IS_24XX(isp)) {
4527 ispreqt7_t *t7 = (ispreqt7_t *)local;
4528 fcportdb_t *lp;
4529
4523 cdbp = reqp->req_cdb;
4524 reqp->req_cdblen = cdblen;
4525 } else if (IS_24XX(isp)) {
4526 ispreqt7_t *t7 = (ispreqt7_t *)local;
4527 fcportdb_t *lp;
4528
4529 if (cdblen > sizeof (t7->req_cdb)) {
4530 isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen);
4531 XS_SETERR(xs, HBA_BOTCH);
4532 return (CMD_COMPLETE);
4533 }
4534
4530 lp = &FCPARAM(isp, XS_CHANNEL(xs))->portdb[hdlidx];
4531 t7->req_nphdl = target;
4532 t7->req_tidlo = lp->portid;
4533 t7->req_tidhi = lp->portid >> 16;
4534 t7->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
4535 if (XS_LUN(xs) > 256) {
4536 t7->req_lun[0] = XS_LUN(xs) >> 8;
4537 t7->req_lun[0] |= 0x40;
4538 }
4539 t7->req_lun[1] = XS_LUN(xs);
4535 lp = &FCPARAM(isp, XS_CHANNEL(xs))->portdb[hdlidx];
4536 t7->req_nphdl = target;
4537 t7->req_tidlo = lp->portid;
4538 t7->req_tidhi = lp->portid >> 16;
4539 t7->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
4540 if (XS_LUN(xs) > 256) {
4541 t7->req_lun[0] = XS_LUN(xs) >> 8;
4542 t7->req_lun[0] |= 0x40;
4543 }
4544 t7->req_lun[1] = XS_LUN(xs);
4540 FCP_NEXT_CRN(isp, xs, t7->req_crn, XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
4545 if (FCPARAM(isp, XS_CHANNEL(xs))->fctape_enabled && (lp->prli_word3 & PRLI_WD3_RETRY)) {
4546 if (FCP_NEXT_CRN(isp, &t7->req_crn, xs)) {
4547 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d cannot generate next CRN", XS_CHANNEL(xs), target, XS_LUN(xs));
4548 XS_SETERR(xs, HBA_BOTCH);
4549 return (CMD_EAGAIN);
4550 }
4551 }
4541 tptr = &t7->req_time;
4542 cdbp = t7->req_cdb;
4552 tptr = &t7->req_time;
4553 cdbp = t7->req_cdb;
4543 cdblen = ISP_MIN(cdblen, sizeof (t7->req_cdb));
4544 } else if (ISP_CAP_2KLOGIN(isp)) {
4545 ispreqt2e_t *t2e = (ispreqt2e_t *)local;
4546 t2e->req_target = target;
4547 t2e->req_scclun = XS_LUN(xs);
4548 cdbp = t2e->req_cdb;
4549 cdblen = ISP_MIN(cdblen, sizeof (t2e->req_cdb));
4550 } else if (ISP_CAP_SCCFW(isp)) {
4551 ispreqt2_t *t2 = (ispreqt2_t *)local;
4552 t2->req_target = target;
4553 t2->req_scclun = XS_LUN(xs);
4554 cdbp = t2->req_cdb;
4555 cdblen = ISP_MIN(cdblen, sizeof (t2->req_cdb));
4556 } else {
4557 ispreqt2_t *t2 = (ispreqt2_t *)local;
4554 } else {
4555 ispreqt2_t *t2 = (ispreqt2_t *)local;
4558 t2->req_target = target;
4559 t2->req_lun_trn = XS_LUN(xs);
4560 cdbp = t2->req_cdb;
4561 cdblen = ISP_MIN(cdblen, sizeof (t2->req_cdb));
4556 fcportdb_t *lp;
4557
4558 if (cdblen > sizeof t2->req_cdb) {
4559 isp_prt(isp, ISP_LOGERR, "Command Length %u too long for this chip", cdblen);
4560 XS_SETERR(xs, HBA_BOTCH);
4561 return (CMD_COMPLETE);
4562 }
4563 lp = &FCPARAM(isp, XS_CHANNEL(xs))->portdb[hdlidx];
4564 if (FCPARAM(isp, XS_CHANNEL(xs))->fctape_enabled && (lp->prli_word3 & PRLI_WD3_RETRY)) {
4565 if (FCP_NEXT_CRN(isp, &t2->req_crn, xs)) {
4566 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d cannot generate next CRN", XS_CHANNEL(xs), target, XS_LUN(xs));
4567 XS_SETERR(xs, HBA_BOTCH);
4568 return (CMD_EAGAIN);
4569 }
4570 }
4571 if (ISP_CAP_2KLOGIN(isp)) {
4572 ispreqt2e_t *t2e = (ispreqt2e_t *)local;
4573 t2e->req_target = target;
4574 t2e->req_scclun = XS_LUN(xs);
4575 cdbp = t2e->req_cdb;
4576 } else if (ISP_CAP_SCCFW(isp)) {
4577 ispreqt2_t *t2 = (ispreqt2_t *)local;
4578 t2->req_target = target;
4579 t2->req_scclun = XS_LUN(xs);
4580 cdbp = t2->req_cdb;
4581 } else {
4582 t2->req_target = target;
4583 t2->req_lun_trn = XS_LUN(xs);
4584 cdbp = t2->req_cdb;
4585 }
4562 }
4563 ISP_MEMCPY(cdbp, XS_CDBP(xs), cdblen);
4564
4565 *tptr = XS_TIME(xs) / 1000;
4566 if (*tptr == 0 && XS_TIME(xs)) {
4567 *tptr = 1;
4568 }
4569 if (IS_24XX(isp) && *tptr > 0x1999) {
4570 *tptr = 0x1999;
4571 }
4572
4573 if (isp_allocate_xs(isp, xs, &handle)) {
4586 }
4587 ISP_MEMCPY(cdbp, XS_CDBP(xs), cdblen);
4588
4589 *tptr = XS_TIME(xs) / 1000;
4590 if (*tptr == 0 && XS_TIME(xs)) {
4591 *tptr = 1;
4592 }
4593 if (IS_24XX(isp) && *tptr > 0x1999) {
4594 *tptr = 0x1999;
4595 }
4596
4597 if (isp_allocate_xs(isp, xs, &handle)) {
4574 isp_prt(isp, ISP_LOGDEBUG0, "out of xflist pointers");
4598 isp_prt(isp, ISP_LOG_WARN1, "out of xflist pointers");
4575 XS_SETERR(xs, HBA_BOTCH);
4576 return (CMD_EAGAIN);
4577 }
4578 /* Whew. Thankfully the same for type 7 requests */
4579 reqp->req_handle = handle;
4580
4581 /*
4582 * Set up DMA and/or do any platform dependent swizzling of the request entry

--- 30 unchanged lines hidden (view full) ---

4613 va_list ap;
4614
4615 switch (ctl) {
4616 case ISPCTL_RESET_BUS:
4617 /*
4618 * Issue a bus reset.
4619 */
4620 if (IS_24XX(isp)) {
4599 XS_SETERR(xs, HBA_BOTCH);
4600 return (CMD_EAGAIN);
4601 }
4602 /* Whew. Thankfully the same for type 7 requests */
4603 reqp->req_handle = handle;
4604
4605 /*
4606 * Set up DMA and/or do any platform dependent swizzling of the request entry

--- 30 unchanged lines hidden (view full) ---

4637 va_list ap;
4638
4639 switch (ctl) {
4640 case ISPCTL_RESET_BUS:
4641 /*
4642 * Issue a bus reset.
4643 */
4644 if (IS_24XX(isp)) {
4621 isp_prt(isp, ISP_LOGWARN, "RESET BUS NOT IMPLEMENTED");
4645 isp_prt(isp, ISP_LOGERR, "BUS RESET NOT IMPLEMENTED");
4622 break;
4623 } else if (IS_FC(isp)) {
4624 mbs.param[1] = 10;
4625 chan = 0;
4626 } else {
4627 va_start(ap, ctl);
4628 chan = va_arg(ap, int);
4629 va_end(ap);

--- 4 unchanged lines hidden (view full) ---

4634 mbs.param[2] = chan;
4635 }
4636 MBSINIT(&mbs, MBOX_BUS_RESET, MBLOGALL, 0);
4637 ISP_SET_SENDMARKER(isp, chan, 1);
4638 isp_mboxcmd(isp, &mbs);
4639 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4640 break;
4641 }
4646 break;
4647 } else if (IS_FC(isp)) {
4648 mbs.param[1] = 10;
4649 chan = 0;
4650 } else {
4651 va_start(ap, ctl);
4652 chan = va_arg(ap, int);
4653 va_end(ap);

--- 4 unchanged lines hidden (view full) ---

4658 mbs.param[2] = chan;
4659 }
4660 MBSINIT(&mbs, MBOX_BUS_RESET, MBLOGALL, 0);
4661 ISP_SET_SENDMARKER(isp, chan, 1);
4662 isp_mboxcmd(isp, &mbs);
4663 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4664 break;
4665 }
4642 isp_prt(isp, ISP_LOGINFO,
4643 "driver initiated bus reset of bus %d", chan);
4666 isp_prt(isp, ISP_LOGINFO, "driver initiated bus reset of bus %d", chan);
4644 return (0);
4645
4646 case ISPCTL_RESET_DEV:
4647 va_start(ap, ctl);
4648 chan = va_arg(ap, int);
4649 tgt = va_arg(ap, int);
4650 va_end(ap);
4651 if (IS_24XX(isp)) {
4652 uint8_t local[QENTRY_LEN];
4653 isp24xx_tmf_t *tmf;
4654 isp24xx_statusreq_t *sp;
4655 fcparam *fcp = FCPARAM(isp, chan);
4656 fcportdb_t *lp;
4657 int hdlidx;
4658
4659 hdlidx = fcp->isp_dev_map[tgt] - 1;
4660 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4667 return (0);
4668
4669 case ISPCTL_RESET_DEV:
4670 va_start(ap, ctl);
4671 chan = va_arg(ap, int);
4672 tgt = va_arg(ap, int);
4673 va_end(ap);
4674 if (IS_24XX(isp)) {
4675 uint8_t local[QENTRY_LEN];
4676 isp24xx_tmf_t *tmf;
4677 isp24xx_statusreq_t *sp;
4678 fcparam *fcp = FCPARAM(isp, chan);
4679 fcportdb_t *lp;
4680 int hdlidx;
4681
4682 hdlidx = fcp->isp_dev_map[tgt] - 1;
4683 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4661 isp_prt(isp, ISP_LOGWARN,
4662 "Chan %d bad handle %d trying to reset"
4663 "target %d", chan, hdlidx, tgt);
4684 isp_prt(isp, ISP_LOGWARN, "Chan %d bad handle %d trying to reset target %d", chan, hdlidx, tgt);
4664 break;
4665 }
4666 lp = &fcp->portdb[hdlidx];
4667 if (lp->state != FC_PORTDB_STATE_VALID) {
4685 break;
4686 }
4687 lp = &fcp->portdb[hdlidx];
4688 if (lp->state != FC_PORTDB_STATE_VALID) {
4668 isp_prt(isp, ISP_LOGWARN,
4669 "Chan %d handle %d for abort of target %d "
4670 "no longer valid", chan,
4671 hdlidx, tgt);
4689 isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d for abort of target %d no longer valid", chan, hdlidx, tgt);
4672 break;
4673 }
4674
4675 tmf = (isp24xx_tmf_t *) local;
4676 ISP_MEMZERO(tmf, QENTRY_LEN);
4677 tmf->tmf_header.rqs_entry_type = RQSTYPE_TSK_MGMT;
4678 tmf->tmf_header.rqs_entry_count = 1;
4679 tmf->tmf_nphdl = lp->handle;

--- 18 unchanged lines hidden (view full) ---

4698 isp_put_24xx_tmf(isp, tmf, fcp->isp_scratch);
4699 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN, chan);
4700 fcp->sendmarker = 1;
4701 isp_mboxcmd(isp, &mbs);
4702 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4703 FC_SCRATCH_RELEASE(isp, chan);
4704 break;
4705 }
4690 break;
4691 }
4692
4693 tmf = (isp24xx_tmf_t *) local;
4694 ISP_MEMZERO(tmf, QENTRY_LEN);
4695 tmf->tmf_header.rqs_entry_type = RQSTYPE_TSK_MGMT;
4696 tmf->tmf_header.rqs_entry_count = 1;
4697 tmf->tmf_nphdl = lp->handle;

--- 18 unchanged lines hidden (view full) ---

4716 isp_put_24xx_tmf(isp, tmf, fcp->isp_scratch);
4717 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN, chan);
4718 fcp->sendmarker = 1;
4719 isp_mboxcmd(isp, &mbs);
4720 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4721 FC_SCRATCH_RELEASE(isp, chan);
4722 break;
4723 }
4706 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN,
4707 QENTRY_LEN, chan);
4724 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
4708 sp = (isp24xx_statusreq_t *) local;
4725 sp = (isp24xx_statusreq_t *) local;
4709 isp_get_24xx_response(isp,
4710 &((isp24xx_statusreq_t *)fcp->isp_scratch)[1], sp);
4726 isp_get_24xx_response(isp, &((isp24xx_statusreq_t *)fcp->isp_scratch)[1], sp);
4711 FC_SCRATCH_RELEASE(isp, chan);
4712 if (sp->req_completion_status == 0) {
4713 return (0);
4714 }
4727 FC_SCRATCH_RELEASE(isp, chan);
4728 if (sp->req_completion_status == 0) {
4729 return (0);
4730 }
4715 isp_prt(isp, ISP_LOGWARN,
4716 "Chan %d reset of target %d returned 0x%x",
4717 chan, tgt, sp->req_completion_status);
4731 isp_prt(isp, ISP_LOGWARN, "Chan %d reset of target %d returned 0x%x", chan, tgt, sp->req_completion_status);
4718 break;
4719 } else if (IS_FC(isp)) {
4720 if (ISP_CAP_2KLOGIN(isp)) {
4721 mbs.param[1] = tgt;
4722 mbs.ibits = (1 << 10);
4723 } else {
4724 mbs.param[1] = (tgt << 8);
4725 }
4726 } else {
4727 mbs.param[1] = (chan << 15) | (tgt << 8);
4728 }
4729 MBSINIT(&mbs, MBOX_ABORT_TARGET, MBLOGALL, 0);
4730 mbs.param[2] = 3; /* 'delay', in seconds */
4731 isp_mboxcmd(isp, &mbs);
4732 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4733 break;
4734 }
4732 break;
4733 } else if (IS_FC(isp)) {
4734 if (ISP_CAP_2KLOGIN(isp)) {
4735 mbs.param[1] = tgt;
4736 mbs.ibits = (1 << 10);
4737 } else {
4738 mbs.param[1] = (tgt << 8);
4739 }
4740 } else {
4741 mbs.param[1] = (chan << 15) | (tgt << 8);
4742 }
4743 MBSINIT(&mbs, MBOX_ABORT_TARGET, MBLOGALL, 0);
4744 mbs.param[2] = 3; /* 'delay', in seconds */
4745 isp_mboxcmd(isp, &mbs);
4746 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4747 break;
4748 }
4735 isp_prt(isp, ISP_LOGINFO,
4736 "Target %d on Bus %d Reset Succeeded", tgt, chan);
4749 isp_prt(isp, ISP_LOGINFO, "Target %d on Bus %d Reset Succeeded", tgt, chan);
4737 ISP_SET_SENDMARKER(isp, chan, 1);
4738 return (0);
4739
4740 case ISPCTL_ABORT_CMD:
4741 va_start(ap, ctl);
4742 xs = va_arg(ap, XS_T *);
4743 va_end(ap);
4744
4745 tgt = XS_TGT(xs);
4746 chan = XS_CHANNEL(xs);
4747
4748 handle = isp_find_handle(isp, xs);
4749 if (handle == 0) {
4750 ISP_SET_SENDMARKER(isp, chan, 1);
4751 return (0);
4752
4753 case ISPCTL_ABORT_CMD:
4754 va_start(ap, ctl);
4755 xs = va_arg(ap, XS_T *);
4756 va_end(ap);
4757
4758 tgt = XS_TGT(xs);
4759 chan = XS_CHANNEL(xs);
4760
4761 handle = isp_find_handle(isp, xs);
4762 if (handle == 0) {
4750 isp_prt(isp, ISP_LOGWARN,
4751 "cannot find handle for command to abort");
4763 isp_prt(isp, ISP_LOGWARN, "cannot find handle for command to abort");
4752 break;
4753 }
4754 if (IS_24XX(isp)) {
4755 isp24xx_abrt_t local, *ab = &local, *ab2;
4756 fcparam *fcp;
4757 fcportdb_t *lp;
4758 int hdlidx;
4759
4760 fcp = FCPARAM(isp, chan);
4761 hdlidx = fcp->isp_dev_map[tgt] - 1;
4762 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4764 break;
4765 }
4766 if (IS_24XX(isp)) {
4767 isp24xx_abrt_t local, *ab = &local, *ab2;
4768 fcparam *fcp;
4769 fcportdb_t *lp;
4770 int hdlidx;
4771
4772 fcp = FCPARAM(isp, chan);
4773 hdlidx = fcp->isp_dev_map[tgt] - 1;
4774 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4763 isp_prt(isp, ISP_LOGWARN,
4764 "Chan %d bad handle %d trying to abort"
4765 "target %d", chan, hdlidx, tgt);
4775 isp_prt(isp, ISP_LOGWARN, "Chan %d bad handle %d trying to abort target %d", chan, hdlidx, tgt);
4766 break;
4767 }
4768 lp = &fcp->portdb[hdlidx];
4769 if (lp->state != FC_PORTDB_STATE_VALID) {
4776 break;
4777 }
4778 lp = &fcp->portdb[hdlidx];
4779 if (lp->state != FC_PORTDB_STATE_VALID) {
4770 isp_prt(isp, ISP_LOGWARN,
4771 "Chan %d handle %d for abort of target %d "
4772 "no longer valid", chan, hdlidx, tgt);
4780 isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d for abort of target %d no longer valid", chan, hdlidx, tgt);
4773 break;
4774 }
4781 break;
4782 }
4775 isp_prt(isp, ISP_LOGALL,
4776 "Chan %d Abort Cmd for N-Port 0x%04x @ Port "
4777 "0x%06x %p", chan, lp->handle, lp->portid, xs);
4783 isp_prt(isp, ISP_LOGALL, "Chan %d Abort Cmd for N-Port 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
4778 ISP_MEMZERO(ab, QENTRY_LEN);
4779 ab->abrt_header.rqs_entry_type = RQSTYPE_ABORT_IO;
4780 ab->abrt_header.rqs_entry_count = 1;
4781 ab->abrt_handle = lp->handle;
4782 ab->abrt_cmd_handle = handle;
4783 ab->abrt_tidlo = lp->portid;
4784 ab->abrt_tidhi = lp->portid >> 16;
4785 ab->abrt_vpidx = ISP_GET_VPIDX(isp, chan);

--- 6 unchanged lines hidden (view full) ---

4792 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
4793 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
4794
4795 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4796 isp_prt(isp, ISP_LOGERR, sacq);
4797 break;
4798 }
4799 isp_put_24xx_abrt(isp, ab, fcp->isp_scratch);
4784 ISP_MEMZERO(ab, QENTRY_LEN);
4785 ab->abrt_header.rqs_entry_type = RQSTYPE_ABORT_IO;
4786 ab->abrt_header.rqs_entry_count = 1;
4787 ab->abrt_handle = lp->handle;
4788 ab->abrt_cmd_handle = handle;
4789 ab->abrt_tidlo = lp->portid;
4790 ab->abrt_tidhi = lp->portid >> 16;
4791 ab->abrt_vpidx = ISP_GET_VPIDX(isp, chan);

--- 6 unchanged lines hidden (view full) ---

4798 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
4799 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
4800
4801 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4802 isp_prt(isp, ISP_LOGERR, sacq);
4803 break;
4804 }
4805 isp_put_24xx_abrt(isp, ab, fcp->isp_scratch);
4800 ab2 = (isp24xx_abrt_t *)
4801 &((uint8_t *)fcp->isp_scratch)[QENTRY_LEN];
4806 ab2 = (isp24xx_abrt_t *) &((uint8_t *)fcp->isp_scratch)[QENTRY_LEN];
4802 ab2->abrt_nphdl = 0xdeaf;
4803 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
4804 isp_mboxcmd(isp, &mbs);
4805 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4806 FC_SCRATCH_RELEASE(isp, chan);
4807 break;
4808 }
4807 ab2->abrt_nphdl = 0xdeaf;
4808 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN, chan);
4809 isp_mboxcmd(isp, &mbs);
4810 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4811 FC_SCRATCH_RELEASE(isp, chan);
4812 break;
4813 }
4809 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN,
4810 QENTRY_LEN, chan);
4814 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN, chan);
4811 isp_get_24xx_abrt(isp, ab2, ab);
4812 FC_SCRATCH_RELEASE(isp, chan);
4813 if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY) {
4814 return (0);
4815 }
4815 isp_get_24xx_abrt(isp, ab2, ab);
4816 FC_SCRATCH_RELEASE(isp, chan);
4817 if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY) {
4818 return (0);
4819 }
4816 isp_prt(isp, ISP_LOGWARN,
4817 "Chan %d handle %d abort returned 0x%x", chan,
4818 hdlidx, ab->abrt_nphdl);
4820 isp_prt(isp, ISP_LOGWARN, "Chan %d handle %d abort returned 0x%x", chan, hdlidx, ab->abrt_nphdl);
4819 break;
4820 } else if (IS_FC(isp)) {
4821 if (ISP_CAP_SCCFW(isp)) {
4822 if (ISP_CAP_2KLOGIN(isp)) {
4823 mbs.param[1] = tgt;
4824 } else {
4825 mbs.param[1] = tgt << 8;
4826 }

--- 171 unchanged lines hidden (view full) ---

4998#define MAX_REQUESTQ_COMPLETIONS 32
4999#endif
5000
5001void
5002isp_intr(ispsoftc_t *isp, uint32_t isr, uint16_t sema, uint16_t mbox)
5003{
5004 XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs;
5005 uint32_t iptr, optr, junk;
4821 break;
4822 } else if (IS_FC(isp)) {
4823 if (ISP_CAP_SCCFW(isp)) {
4824 if (ISP_CAP_2KLOGIN(isp)) {
4825 mbs.param[1] = tgt;
4826 } else {
4827 mbs.param[1] = tgt << 8;
4828 }

--- 171 unchanged lines hidden (view full) ---

5000#define MAX_REQUESTQ_COMPLETIONS 32
5001#endif
5002
5003void
5004isp_intr(ispsoftc_t *isp, uint32_t isr, uint16_t sema, uint16_t mbox)
5005{
5006 XS_T *complist[MAX_REQUESTQ_COMPLETIONS], *xs;
5007 uint32_t iptr, optr, junk;
5006 int i, nlooked = 0, ndone = 0;
5008 int i, nlooked = 0, ndone = 0, continuations_expected = 0;
5009 int etype, last_etype = 0;
5007
5008again:
5009 optr = isp->isp_residx;
5010 /*
5011 * Is this a mailbox related interrupt?
5012 * The mailbox semaphore will be nonzero if so.
5013 */
5014 if (sema) {

--- 159 unchanged lines hidden (view full) ---

5174 }
5175 }
5176 isp->isp_resodx = iptr;
5177
5178 while (optr != iptr) {
5179 uint8_t qe[QENTRY_LEN];
5180 ispstatusreq_t *sp = (ispstatusreq_t *) qe;
5181 isphdr_t *hp;
5010
5011again:
5012 optr = isp->isp_residx;
5013 /*
5014 * Is this a mailbox related interrupt?
5015 * The mailbox semaphore will be nonzero if so.
5016 */
5017 if (sema) {

--- 159 unchanged lines hidden (view full) ---

5177 }
5178 }
5179 isp->isp_resodx = iptr;
5180
5181 while (optr != iptr) {
5182 uint8_t qe[QENTRY_LEN];
5183 ispstatusreq_t *sp = (ispstatusreq_t *) qe;
5184 isphdr_t *hp;
5182 int buddaboom, etype, scsi_status, completion_status;
5185 int buddaboom, scsi_status, completion_status;
5183 int req_status_flags, req_state_flags;
5184 uint8_t *snsp, *resp;
5186 int req_status_flags, req_state_flags;
5187 uint8_t *snsp, *resp;
5185 uint32_t rlen, slen;
5188 uint32_t rlen, slen, totslen;
5186 long resid;
5187 uint16_t oop;
5188
5189 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr);
5190 oop = optr;
5191 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp));
5192 nlooked++;
5193 read_again:

--- 35 unchanged lines hidden (view full) ---

5229 }
5230 for (i = 0; i < rio->req_header.rqs_seqno; i++) {
5231 isp_fastpost_complete(isp, rio->req_handles[i]);
5232 }
5233 if (isp->isp_fpcchiwater < rio->req_header.rqs_seqno) {
5234 isp->isp_fpcchiwater = rio->req_header.rqs_seqno;
5235 }
5236 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5189 long resid;
5190 uint16_t oop;
5191
5192 hp = (isphdr_t *) ISP_QUEUE_ENTRY(isp->isp_result, optr);
5193 oop = optr;
5194 optr = ISP_NXT_QENTRY(optr, RESULT_QUEUE_LEN(isp));
5195 nlooked++;
5196 read_again:

--- 35 unchanged lines hidden (view full) ---

5232 }
5233 for (i = 0; i < rio->req_header.rqs_seqno; i++) {
5234 isp_fastpost_complete(isp, rio->req_handles[i]);
5235 }
5236 if (isp->isp_fpcchiwater < rio->req_header.rqs_seqno) {
5237 isp->isp_fpcchiwater = rio->req_header.rqs_seqno;
5238 }
5239 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5240 last_etype = etype;
5237 continue;
5238 } else if (etype == RQSTYPE_RIO2) {
5241 continue;
5242 } else if (etype == RQSTYPE_RIO2) {
5239 isp_prt(isp, ISP_LOGERR, "dropping RIO2 response\n");
5243 isp_prt(isp, ISP_LOGERR, "dropping RIO2 response");
5240 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5244 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5245 last_etype = etype;
5241 continue;
5246 continue;
5247 } else if (etype == RQSTYPE_STATUS_CONT) {
5248 isp_get_cont_response(isp, (ispstatus_cont_t *) hp, (ispstatus_cont_t *) sp);
5249 if (last_etype == RQSTYPE_RESPONSE && continuations_expected && ndone > 0 && (xs = complist[ndone-1]) != NULL) {
5250 ispstatus_cont_t *scp = (ispstatus_cont_t *) sp;
5251 XS_SENSE_APPEND(xs, scp->req_sense_data, sizeof (scp->req_sense_data));
5252 isp_prt(isp, ISP_LOGDEBUG0|ISP_LOG_CWARN, "%d more Status Continuations expected", --continuations_expected);
5253 } else {
5254 isp_prt(isp, ISP_LOG_WARN1, "Ignored Continuation Response");
5255 }
5256 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5257 continue;
5242 } else {
5243 /*
5244 * Somebody reachable via isp_handle_other_response
5245 * may have updated the response queue pointers for
5246 * us, so we reload our goal index.
5247 */
5248 int r;
5249 uint32_t tsto = oop;
5250 r = isp_handle_other_response(isp, etype, hp, &tsto);
5251 if (r < 0) {
5252 goto read_again;
5253 }
5254 /*
5255 * If somebody updated the output pointer, then reset
5256 * optr to be one more than the updated amount.
5257 */
5258 while (tsto != oop) {
5258 } else {
5259 /*
5260 * Somebody reachable via isp_handle_other_response
5261 * may have updated the response queue pointers for
5262 * us, so we reload our goal index.
5263 */
5264 int r;
5265 uint32_t tsto = oop;
5266 r = isp_handle_other_response(isp, etype, hp, &tsto);
5267 if (r < 0) {
5268 goto read_again;
5269 }
5270 /*
5271 * If somebody updated the output pointer, then reset
5272 * optr to be one more than the updated amount.
5273 */
5274 while (tsto != oop) {
5259 optr = ISP_NXT_QENTRY(tsto,
5260 RESULT_QUEUE_LEN(isp));
5275 optr = ISP_NXT_QENTRY(tsto, RESULT_QUEUE_LEN(isp));
5261 }
5262 if (r > 0) {
5263 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5264 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5276 }
5277 if (r > 0) {
5278 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5279 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5280 last_etype = etype;
5265 continue;
5266 }
5267
5268 /*
5269 * After this point, we'll just look at the header as
5270 * we don't know how to deal with the rest of the
5271 * response.
5272 */
5273
5274 /*
5275 * It really has to be a bounced request just copied
5276 * from the request queue to the response queue. If
5277 * not, something bad has happened.
5278 */
5279 if (etype != RQSTYPE_REQUEST) {
5281 continue;
5282 }
5283
5284 /*
5285 * After this point, we'll just look at the header as
5286 * we don't know how to deal with the rest of the
5287 * response.
5288 */
5289
5290 /*
5291 * It really has to be a bounced request just copied
5292 * from the request queue to the response queue. If
5293 * not, something bad has happened.
5294 */
5295 if (etype != RQSTYPE_REQUEST) {
5280 isp_prt(isp, ISP_LOGERR, notresp,
5281 etype, oop, optr, nlooked);
5282 isp_print_bytes(isp,
5283 "Request Queue Entry", QENTRY_LEN, sp);
5296 isp_prt(isp, ISP_LOGERR, notresp, etype, oop, optr, nlooked);
5297 isp_print_bytes(isp, "Request Queue Entry", QENTRY_LEN, sp);
5284 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5298 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5299 last_etype = etype;
5285 continue;
5286 }
5287 buddaboom = 1;
5288 scsi_status = sp->req_scsi_status;
5289 completion_status = sp->req_completion_status;
5290 req_status_flags = sp->req_status_flags;
5291 req_state_flags = sp->req_state_flags;
5292 resid = sp->req_resid;
5293 }
5294
5295 if (sp->req_header.rqs_flags & RQSFLAG_MASK) {
5296 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
5297 isp_print_bytes(isp, "unexpected continuation segment", QENTRY_LEN, sp);
5298 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5300 continue;
5301 }
5302 buddaboom = 1;
5303 scsi_status = sp->req_scsi_status;
5304 completion_status = sp->req_completion_status;
5305 req_status_flags = sp->req_status_flags;
5306 req_state_flags = sp->req_state_flags;
5307 resid = sp->req_resid;
5308 }
5309
5310 if (sp->req_header.rqs_flags & RQSFLAG_MASK) {
5311 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
5312 isp_print_bytes(isp, "unexpected continuation segment", QENTRY_LEN, sp);
5313 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5314 last_etype = etype;
5299 continue;
5300 }
5301 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
5315 continue;
5316 }
5317 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
5302 isp_prt(isp, ISP_LOGDEBUG0, "internal queues full");
5318 isp_prt(isp, ISP_LOG_WARN1, "internal queues full");
5303 /*
5304 * We'll synthesize a QUEUE FULL message below.
5305 */
5306 }
5307 if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) {
5308 isp_print_bytes(isp, "bad header flag", QENTRY_LEN, sp);
5309 buddaboom++;
5310 }
5311 if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) {
5312 isp_print_bytes(isp, "bad request packet", QENTRY_LEN, sp);
5313 buddaboom++;
5314 }
5315 if (sp->req_header.rqs_flags & RQSFLAG_BADCOUNT) {
5316 isp_print_bytes(isp, "invalid entry count", QENTRY_LEN, sp);
5317 buddaboom++;
5318 }
5319 if (sp->req_header.rqs_flags & RQSFLAG_BADORDER) {
5320 isp_print_bytes(isp, "invalid IOCB ordering", QENTRY_LEN, sp);
5321 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5319 /*
5320 * We'll synthesize a QUEUE FULL message below.
5321 */
5322 }
5323 if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) {
5324 isp_print_bytes(isp, "bad header flag", QENTRY_LEN, sp);
5325 buddaboom++;
5326 }
5327 if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) {
5328 isp_print_bytes(isp, "bad request packet", QENTRY_LEN, sp);
5329 buddaboom++;
5330 }
5331 if (sp->req_header.rqs_flags & RQSFLAG_BADCOUNT) {
5332 isp_print_bytes(isp, "invalid entry count", QENTRY_LEN, sp);
5333 buddaboom++;
5334 }
5335 if (sp->req_header.rqs_flags & RQSFLAG_BADORDER) {
5336 isp_print_bytes(isp, "invalid IOCB ordering", QENTRY_LEN, sp);
5337 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5338 last_etype = etype;
5322 continue;
5323 }
5324 }
5325
5326 if (!ISP_VALID_HANDLE(isp, sp->req_handle)) {
5327 isp_prt(isp, ISP_LOGERR, "bad request handle 0x%x (iocb type 0x%x)", sp->req_handle, etype);
5328 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5329 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5339 continue;
5340 }
5341 }
5342
5343 if (!ISP_VALID_HANDLE(isp, sp->req_handle)) {
5344 isp_prt(isp, ISP_LOGERR, "bad request handle 0x%x (iocb type 0x%x)", sp->req_handle, etype);
5345 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5346 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5347 last_etype = etype;
5330 continue;
5331 }
5332 xs = isp_find_xs(isp, sp->req_handle);
5333 if (xs == NULL) {
5334 uint8_t ts = completion_status & 0xff;
5335 /*
5336 * Only whine if this isn't the expected fallout of
5337 * aborting the command or resetting the target.
5338 */
5339 if (etype != RQSTYPE_RESPONSE) {
5340 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (type 0x%x)", sp->req_handle, etype);
5341 } else if (ts != RQCS_ABORTED && ts != RQCS_RESET_OCCURRED) {
5342 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (status 0x%x)", sp->req_handle, ts);
5343 }
5344 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5345 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5348 continue;
5349 }
5350 xs = isp_find_xs(isp, sp->req_handle);
5351 if (xs == NULL) {
5352 uint8_t ts = completion_status & 0xff;
5353 /*
5354 * Only whine if this isn't the expected fallout of
5355 * aborting the command or resetting the target.
5356 */
5357 if (etype != RQSTYPE_RESPONSE) {
5358 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (type 0x%x)", sp->req_handle, etype);
5359 } else if (ts != RQCS_ABORTED && ts != RQCS_RESET_OCCURRED) {
5360 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (status 0x%x)", sp->req_handle, ts);
5361 }
5362 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5363 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5364 last_etype = etype;
5346 continue;
5347 }
5348 if (req_status_flags & RQSTF_BUS_RESET) {
5365 continue;
5366 }
5367 if (req_status_flags & RQSTF_BUS_RESET) {
5368 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d bus was reset", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5349 XS_SETERR(xs, HBA_BUSRESET);
5350 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 1);
5351 }
5352 if (buddaboom) {
5369 XS_SETERR(xs, HBA_BUSRESET);
5370 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 1);
5371 }
5372 if (buddaboom) {
5373 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d buddaboom", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5353 XS_SETERR(xs, HBA_BOTCH);
5354 }
5355
5356 resp = NULL;
5357 rlen = 0;
5358 snsp = NULL;
5374 XS_SETERR(xs, HBA_BOTCH);
5375 }
5376
5377 resp = NULL;
5378 rlen = 0;
5379 snsp = NULL;
5359 slen = 0;
5380 totslen = slen = 0;
5360 if (IS_24XX(isp) && (scsi_status & (RQCS_RV|RQCS_SV)) != 0) {
5361 resp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
5362 rlen = ((isp24xx_statusreq_t *)sp)->req_response_len;
5363 } else if (IS_FC(isp) && (scsi_status & RQCS_RV) != 0) {
5364 resp = sp->req_response;
5365 rlen = sp->req_response_len;
5366 }
5367 if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) {
5368 /*
5369 * Fibre Channel F/W doesn't say we got status
5370 * if there's Sense Data instead. I guess they
5371 * think it goes w/o saying.
5372 */
5373 req_state_flags |= RQSF_GOT_STATUS|RQSF_GOT_SENSE;
5374 if (IS_24XX(isp)) {
5375 snsp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
5376 snsp += rlen;
5381 if (IS_24XX(isp) && (scsi_status & (RQCS_RV|RQCS_SV)) != 0) {
5382 resp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
5383 rlen = ((isp24xx_statusreq_t *)sp)->req_response_len;
5384 } else if (IS_FC(isp) && (scsi_status & RQCS_RV) != 0) {
5385 resp = sp->req_response;
5386 rlen = sp->req_response_len;
5387 }
5388 if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) {
5389 /*
5390 * Fibre Channel F/W doesn't say we got status
5391 * if there's Sense Data instead. I guess they
5392 * think it goes w/o saying.
5393 */
5394 req_state_flags |= RQSF_GOT_STATUS|RQSF_GOT_SENSE;
5395 if (IS_24XX(isp)) {
5396 snsp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
5397 snsp += rlen;
5377 slen = ((isp24xx_statusreq_t *)sp)->req_sense_len;
5398 totslen = ((isp24xx_statusreq_t *)sp)->req_sense_len;
5399 slen = (sizeof (((isp24xx_statusreq_t *)sp)->req_rsp_sense)) - rlen;
5400 if (totslen < slen)
5401 slen = totslen;
5378 } else {
5379 snsp = sp->req_sense_data;
5402 } else {
5403 snsp = sp->req_sense_data;
5380 slen = sp->req_sense_len;
5404 totslen = sp->req_sense_len;
5405 slen = sizeof (sp->req_sense_data);
5406 if (totslen < slen)
5407 slen = totslen;
5381 }
5382 } else if (IS_SCSI(isp) && (req_state_flags & RQSF_GOT_SENSE)) {
5383 snsp = sp->req_sense_data;
5408 }
5409 } else if (IS_SCSI(isp) && (req_state_flags & RQSF_GOT_SENSE)) {
5410 snsp = sp->req_sense_data;
5384 slen = sp->req_sense_len;
5411 totslen = sp->req_sense_len;
5412 slen = sizeof (sp->req_sense_data);
5413 if (totslen < slen)
5414 slen = totslen;
5385 }
5386 if (req_state_flags & RQSF_GOT_STATUS) {
5387 *XS_STSP(xs) = scsi_status & 0xff;
5388 }
5389
5390 switch (etype) {
5391 case RQSTYPE_RESPONSE:
5392 if (resp && rlen >= 4 && resp[FCP_RSPNS_CODE_OFFSET] != 0) {

--- 44 unchanged lines hidden (view full) ---

5437 XS_SET_RESID(xs, 0);
5438 } else if (scsi_status & RQCS_RESID) {
5439 XS_SET_RESID(xs, resid);
5440 } else {
5441 XS_SET_RESID(xs, 0);
5442 }
5443 }
5444 if (snsp && slen) {
5415 }
5416 if (req_state_flags & RQSF_GOT_STATUS) {
5417 *XS_STSP(xs) = scsi_status & 0xff;
5418 }
5419
5420 switch (etype) {
5421 case RQSTYPE_RESPONSE:
5422 if (resp && rlen >= 4 && resp[FCP_RSPNS_CODE_OFFSET] != 0) {

--- 44 unchanged lines hidden (view full) ---

5467 XS_SET_RESID(xs, 0);
5468 } else if (scsi_status & RQCS_RESID) {
5469 XS_SET_RESID(xs, resid);
5470 } else {
5471 XS_SET_RESID(xs, 0);
5472 }
5473 }
5474 if (snsp && slen) {
5445 XS_SAVE_SENSE(xs, snsp, slen);
5475 if (totslen > slen) {
5476 continuations_expected += ((totslen - slen + QENTRY_LEN - 5) / (QENTRY_LEN - 4));
5477 if (ndone > (MAX_REQUESTQ_COMPLETIONS - continuations_expected - 1)) {
5478 /* we'll lose some stats, but that's a small price to pay */
5479 for (i = 0; i < ndone; i++) {
5480 if (complist[i]) {
5481 isp->isp_rsltccmplt++;
5482 isp_done(complist[i]);
5483 }
5484 }
5485 ndone = 0;
5486 }
5487 isp_prt(isp, ISP_LOGDEBUG0|ISP_LOG_CWARN, "Expecting %d more Status Continuations for total sense length of %u",
5488 continuations_expected, totslen);
5489 }
5490 XS_SAVE_SENSE(xs, snsp, totslen, slen);
5446 } else if ((req_status_flags & RQSF_GOT_STATUS) && (scsi_status & 0xff) == SCSI_CHECK && IS_FC(isp)) {
5447 isp_prt(isp, ISP_LOGWARN, "CHECK CONDITION w/o sense data for CDB=0x%x", XS_CDBP(xs)[0] & 0xff);
5448 isp_print_bytes(isp, "CC with no Sense", QENTRY_LEN, qe);
5449 }
5450 isp_prt(isp, ISP_LOGDEBUG2, "asked for %ld got raw resid %ld settled for %ld", (long) XS_XFRLEN(xs), resid, (long) XS_GET_RESID(xs));
5451 break;
5452 case RQSTYPE_REQUEST:
5453 case RQSTYPE_A64:
5454 case RQSTYPE_T2RQS:
5455 case RQSTYPE_T3RQS:
5456 case RQSTYPE_T7RQS:
5457 if (!IS_24XX(isp) && (sp->req_header.rqs_flags & RQSFLAG_FULL)) {
5458 /*
5459 * Force Queue Full status.
5460 */
5461 *XS_STSP(xs) = SCSI_QFULL;
5462 XS_SETERR(xs, HBA_NOERROR);
5463 } else if (XS_NOERR(xs)) {
5491 } else if ((req_status_flags & RQSF_GOT_STATUS) && (scsi_status & 0xff) == SCSI_CHECK && IS_FC(isp)) {
5492 isp_prt(isp, ISP_LOGWARN, "CHECK CONDITION w/o sense data for CDB=0x%x", XS_CDBP(xs)[0] & 0xff);
5493 isp_print_bytes(isp, "CC with no Sense", QENTRY_LEN, qe);
5494 }
5495 isp_prt(isp, ISP_LOGDEBUG2, "asked for %ld got raw resid %ld settled for %ld", (long) XS_XFRLEN(xs), resid, (long) XS_GET_RESID(xs));
5496 break;
5497 case RQSTYPE_REQUEST:
5498 case RQSTYPE_A64:
5499 case RQSTYPE_T2RQS:
5500 case RQSTYPE_T3RQS:
5501 case RQSTYPE_T7RQS:
5502 if (!IS_24XX(isp) && (sp->req_header.rqs_flags & RQSFLAG_FULL)) {
5503 /*
5504 * Force Queue Full status.
5505 */
5506 *XS_STSP(xs) = SCSI_QFULL;
5507 XS_SETERR(xs, HBA_NOERROR);
5508 } else if (XS_NOERR(xs)) {
5509 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d badness at %s:%u", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), __func__, __LINE__);
5464 XS_SETERR(xs, HBA_BOTCH);
5465 }
5466 XS_SET_RESID(xs, XS_XFRLEN(xs));
5467 break;
5468 default:
5469 isp_print_bytes(isp, "Unhandled Response Type", QENTRY_LEN, qe);
5470 if (XS_NOERR(xs)) {
5471 XS_SETERR(xs, HBA_BOTCH);

--- 5 unchanged lines hidden (view full) ---

5477 * Free any DMA resources. As a side effect, this may
5478 * also do any cache flushing necessary for data coherence.
5479 */
5480 if (XS_XFRLEN(xs)) {
5481 ISP_DMAFREE(isp, xs, sp->req_handle);
5482 }
5483 isp_destroy_handle(isp, sp->req_handle);
5484
5510 XS_SETERR(xs, HBA_BOTCH);
5511 }
5512 XS_SET_RESID(xs, XS_XFRLEN(xs));
5513 break;
5514 default:
5515 isp_print_bytes(isp, "Unhandled Response Type", QENTRY_LEN, qe);
5516 if (XS_NOERR(xs)) {
5517 XS_SETERR(xs, HBA_BOTCH);

--- 5 unchanged lines hidden (view full) ---

5523 * Free any DMA resources. As a side effect, this may
5524 * also do any cache flushing necessary for data coherence.
5525 */
5526 if (XS_XFRLEN(xs)) {
5527 ISP_DMAFREE(isp, xs, sp->req_handle);
5528 }
5529 isp_destroy_handle(isp, sp->req_handle);
5530
5485 if (((isp->isp_dblev & (ISP_LOGDEBUG1|ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
5486 ((isp->isp_dblev & (ISP_LOGDEBUG0|ISP_LOG_CWARN) && ((!XS_NOERR(xs)) || (*XS_STSP(xs) != SCSI_GOOD))))) {
5487 isp_prt_endcmd(isp, xs);
5488 }
5489 if (isp->isp_nactive > 0) {
5490 isp->isp_nactive--;
5491 }
5492 complist[ndone++] = xs; /* defer completion call until later */
5493 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5531 if (isp->isp_nactive > 0) {
5532 isp->isp_nactive--;
5533 }
5534 complist[ndone++] = xs; /* defer completion call until later */
5535 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5536 last_etype = etype;
5494 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
5495 break;
5496 }
5497 }
5498
5499 /*
5500 * If we looked at any commands, then it's valid to find out
5501 * what the outpointer is. It also is a trigger to update the

--- 18 unchanged lines hidden (view full) ---

5520 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
5521 ISP_WRITE(isp, BIU_SEMA, 0);
5522 }
5523
5524 isp->isp_residx = optr;
5525 for (i = 0; i < ndone; i++) {
5526 xs = complist[i];
5527 if (xs) {
5537 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
5538 break;
5539 }
5540 }
5541
5542 /*
5543 * If we looked at any commands, then it's valid to find out
5544 * what the outpointer is. It also is a trigger to update the

--- 18 unchanged lines hidden (view full) ---

5563 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
5564 ISP_WRITE(isp, BIU_SEMA, 0);
5565 }
5566
5567 isp->isp_residx = optr;
5568 for (i = 0; i < ndone; i++) {
5569 xs = complist[i];
5570 if (xs) {
5571 if (((isp->isp_dblev & (ISP_LOGDEBUG1|ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
5572 ((isp->isp_dblev & (ISP_LOGDEBUG0|ISP_LOG_CWARN) && ((!XS_NOERR(xs)) || (*XS_STSP(xs) != SCSI_GOOD))))) {
5573 isp_prt_endcmd(isp, xs);
5574 }
5528 isp->isp_rsltccmplt++;
5529 isp_done(xs);
5530 }
5531 }
5532}
5533
5534/*
5535 * Support routines.

--- 6 unchanged lines hidden (view full) ---

5542 int i, lim;
5543
5544 lim = XS_CDBLEN(xs) > 16? 16 : XS_CDBLEN(xs);
5545 ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "0x%02x ", XS_CDBP(xs)[0]);
5546 for (i = 1; i < lim; i++) {
5547 ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "%s0x%02x ", cdbstr, XS_CDBP(xs)[i]);
5548 }
5549 if (XS_SENSE_VALID(xs)) {
5575 isp->isp_rsltccmplt++;
5576 isp_done(xs);
5577 }
5578 }
5579}
5580
5581/*
5582 * Support routines.

--- 6 unchanged lines hidden (view full) ---

5589 int i, lim;
5590
5591 lim = XS_CDBLEN(xs) > 16? 16 : XS_CDBLEN(xs);
5592 ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "0x%02x ", XS_CDBP(xs)[0]);
5593 for (i = 1; i < lim; i++) {
5594 ISP_SNPRINTF(cdbstr, sizeof (cdbstr), "%s0x%02x ", cdbstr, XS_CDBP(xs)[i]);
5595 }
5596 if (XS_SENSE_VALID(xs)) {
5550 isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s KEY/ASC/ASCQ=0x%02x/0x%02x/0x%02x",
5551 XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, XS_SNSKEY(xs), XS_SNSASC(xs), XS_SNSASCQ(xs));
5597 isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s SenseLength=%u/%u KEY/ASC/ASCQ=0x%02x/0x%02x/0x%02x",
5598 XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, XS_CUR_SNSLEN(xs), XS_TOT_SNSLEN(xs), XS_SNSKEY(xs), XS_SNSASC(xs), XS_SNSASCQ(xs));
5552 } else {
5553 isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s STS 0x%x XS_ERR=0x%x", XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, *XS_STSP(xs), XS_ERR(xs));
5554 }
5555}
5556
5557/*
5558 * Parse an ASYNC mailbox complete
5559 *

--- 311 unchanged lines hidden (view full) ---

5871 if (ISP_H2HT(hdp->handle) != ISP_HANDLE_INITIATOR) {
5872 continue;
5873 }
5874 xs = hdp->cmd;
5875 if (XS_CHANNEL(xs) != chan) {
5876 continue;
5877 }
5878 j++;
5599 } else {
5600 isp_xs_prt(isp, xs, ISP_LOGALL, "FIN dl%d resid %ld CDB=%s STS 0x%x XS_ERR=0x%x", XS_XFRLEN(xs), (long) XS_GET_RESID(xs), cdbstr, *XS_STSP(xs), XS_ERR(xs));
5601 }
5602}
5603
5604/*
5605 * Parse an ASYNC mailbox complete
5606 *

--- 311 unchanged lines hidden (view full) ---

5918 if (ISP_H2HT(hdp->handle) != ISP_HANDLE_INITIATOR) {
5919 continue;
5920 }
5921 xs = hdp->cmd;
5922 if (XS_CHANNEL(xs) != chan) {
5923 continue;
5924 }
5925 j++;
5926 isp_prt(isp, ISP_LOG_WARN1, "%d.%d.%d bus reset set at %s:%u", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), __func__, __LINE__);
5879 XS_SETERR(xs, HBA_BUSRESET);
5880 }
5881 if (j) {
5882 isp_prt(isp, ISP_LOGERR, lipd, chan, j);
5883 }
5884 }
5885 }
5886 break;

--- 210 unchanged lines hidden (view full) ---

6097 * this is not used currently.
6098 */
6099
6100static int
6101isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *optrp)
6102{
6103 switch (type) {
6104 case RQSTYPE_STATUS_CONT:
5927 XS_SETERR(xs, HBA_BUSRESET);
5928 }
5929 if (j) {
5930 isp_prt(isp, ISP_LOGERR, lipd, chan, j);
5931 }
5932 }
5933 }
5934 break;

--- 210 unchanged lines hidden (view full) ---

6145 * this is not used currently.
6146 */
6147
6148static int
6149isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *optrp)
6150{
6151 switch (type) {
6152 case RQSTYPE_STATUS_CONT:
6105 isp_prt(isp, ISP_LOGDEBUG0, "Ignored Continuation Response");
6153 isp_prt(isp, ISP_LOG_WARN1, "Ignored Continuation Response");
6106 return (1);
6107 case RQSTYPE_MARKER:
6154 return (1);
6155 case RQSTYPE_MARKER:
6108 isp_prt(isp, ISP_LOGDEBUG0, "Marker Response");
6156 isp_prt(isp, ISP_LOG_WARN1, "Marker Response");
6109 return (1);
6110 case RQSTYPE_ATIO:
6111 case RQSTYPE_CTIO:
6112 case RQSTYPE_ENABLE_LUN:
6113 case RQSTYPE_MODIFY_LUN:
6114 case RQSTYPE_NOTIFY:
6115 case RQSTYPE_NOTIFY_ACK:
6116 case RQSTYPE_CTIO1:

--- 48 unchanged lines hidden (view full) ---

6165 case RQCS_COMPLETE:
6166 if (XS_NOERR(xs)) {
6167 XS_SETERR(xs, HBA_NOERROR);
6168 }
6169 return;
6170
6171 case RQCS_INCOMPLETE:
6172 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
6157 return (1);
6158 case RQSTYPE_ATIO:
6159 case RQSTYPE_CTIO:
6160 case RQSTYPE_ENABLE_LUN:
6161 case RQSTYPE_MODIFY_LUN:
6162 case RQSTYPE_NOTIFY:
6163 case RQSTYPE_NOTIFY_ACK:
6164 case RQSTYPE_CTIO1:

--- 48 unchanged lines hidden (view full) ---

6213 case RQCS_COMPLETE:
6214 if (XS_NOERR(xs)) {
6215 XS_SETERR(xs, HBA_NOERROR);
6216 }
6217 return;
6218
6219 case RQCS_INCOMPLETE:
6220 if ((sp->req_state_flags & RQSF_GOT_TARGET) == 0) {
6173 isp_xs_prt(isp, xs, ISP_LOGDEBUG1, "Selection Timeout");
6221 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "Selection Timeout @ %s:%d", __func__, __LINE__);
6174 if (XS_NOERR(xs)) {
6175 XS_SETERR(xs, HBA_SELTIMEOUT);
6176 *rp = XS_XFRLEN(xs);
6177 }
6178 return;
6179 }
6180 isp_xs_prt(isp, xs, ISP_LOGERR, "Command Incomplete, state 0x%x", sp->req_state_flags);
6181 break;

--- 179 unchanged lines hidden (view full) ---

6361 isp_xs_prt(isp, xs, ISP_LOGERR, "HBA attempted queued cmd when queueing disabled");
6362 break;
6363
6364 case RQCS_BAD_ENTRY:
6365 isp_prt(isp, ISP_LOGERR, "Invalid IOCB entry type detected");
6366 break;
6367
6368 case RQCS_QUEUE_FULL:
6222 if (XS_NOERR(xs)) {
6223 XS_SETERR(xs, HBA_SELTIMEOUT);
6224 *rp = XS_XFRLEN(xs);
6225 }
6226 return;
6227 }
6228 isp_xs_prt(isp, xs, ISP_LOGERR, "Command Incomplete, state 0x%x", sp->req_state_flags);
6229 break;

--- 179 unchanged lines hidden (view full) ---

6409 isp_xs_prt(isp, xs, ISP_LOGERR, "HBA attempted queued cmd when queueing disabled");
6410 break;
6411
6412 case RQCS_BAD_ENTRY:
6413 isp_prt(isp, ISP_LOGERR, "Invalid IOCB entry type detected");
6414 break;
6415
6416 case RQCS_QUEUE_FULL:
6369 isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "internal queues full status 0x%x", *XS_STSP(xs));
6417 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "internal queues full status 0x%x", *XS_STSP(xs));
6370
6371 /*
6372 * If QFULL or some other status byte is set, then this
6373 * isn't an error, per se.
6374 *
6375 * Unfortunately, some QLogic f/w writers have, in
6376 * some cases, ommitted to *set* status to QFULL.
6418
6419 /*
6420 * If QFULL or some other status byte is set, then this
6421 * isn't an error, per se.
6422 *
6423 * Unfortunately, some QLogic f/w writers have, in
6424 * some cases, ommitted to *set* status to QFULL.
6377 *
6378
6425 */
6426#if 0
6379 if (*XS_STSP(xs) != SCSI_GOOD && XS_NOERR(xs)) {
6380 XS_SETERR(xs, HBA_NOERROR);
6381 return;
6382 }
6383
6427 if (*XS_STSP(xs) != SCSI_GOOD && XS_NOERR(xs)) {
6428 XS_SETERR(xs, HBA_NOERROR);
6429 return;
6430 }
6431
6384 *
6385 *
6386 */
6387
6432#endif
6388 *XS_STSP(xs) = SCSI_QFULL;
6389 XS_SETERR(xs, HBA_NOERROR);
6390 return;
6391
6392 case RQCS_PHASE_SKIPPED:
6393 isp_xs_prt(isp, xs, ISP_LOGERR, "SCSI phase skipped");
6394 break;
6395

--- 45 unchanged lines hidden (view full) ---

6441 * It was there (maybe)- treat as a selection timeout.
6442 */
6443 if (sts == RQCS_PORT_UNAVAILABLE) {
6444 reason = "unavailable";
6445 } else {
6446 reason = "logout";
6447 }
6448
6433 *XS_STSP(xs) = SCSI_QFULL;
6434 XS_SETERR(xs, HBA_NOERROR);
6435 return;
6436
6437 case RQCS_PHASE_SKIPPED:
6438 isp_xs_prt(isp, xs, ISP_LOGERR, "SCSI phase skipped");
6439 break;
6440

--- 45 unchanged lines hidden (view full) ---

6486 * It was there (maybe)- treat as a selection timeout.
6487 */
6488 if (sts == RQCS_PORT_UNAVAILABLE) {
6489 reason = "unavailable";
6490 } else {
6491 reason = "logout";
6492 }
6493
6449 isp_prt(isp, ISP_LOGINFO, "port %s for target %d",
6450 reason, XS_TGT(xs));
6494 isp_prt(isp, ISP_LOGINFO, "port %s for target %d", reason, XS_TGT(xs));
6451
6452 /*
6453 * If we're on a local loop, force a LIP (which is overkill)
6454 * to force a re-login of this unit. If we're on fabric,
6455 * then we'll have to log in again as a matter of course.
6456 */
6457 if (FCPARAM(isp, 0)->isp_topo == TOPO_NL_PORT ||
6458 FCPARAM(isp, 0)->isp_topo == TOPO_FL_PORT) {

--- 5 unchanged lines hidden (view full) ---

6464 isp_mboxcmd_qnw(isp, &mbs, 1);
6465 }
6466 if (XS_NOERR(xs)) {
6467 XS_SETERR(xs, HBA_SELTIMEOUT);
6468 }
6469 return;
6470 }
6471 case RQCS_PORT_CHANGED:
6495
6496 /*
6497 * If we're on a local loop, force a LIP (which is overkill)
6498 * to force a re-login of this unit. If we're on fabric,
6499 * then we'll have to log in again as a matter of course.
6500 */
6501 if (FCPARAM(isp, 0)->isp_topo == TOPO_NL_PORT ||
6502 FCPARAM(isp, 0)->isp_topo == TOPO_FL_PORT) {

--- 5 unchanged lines hidden (view full) ---

6508 isp_mboxcmd_qnw(isp, &mbs, 1);
6509 }
6510 if (XS_NOERR(xs)) {
6511 XS_SETERR(xs, HBA_SELTIMEOUT);
6512 }
6513 return;
6514 }
6515 case RQCS_PORT_CHANGED:
6472 isp_prt(isp, ISP_LOGWARN,
6473 "port changed for target %d", XS_TGT(xs));
6516 isp_prt(isp, ISP_LOGWARN, "port changed for target %d", XS_TGT(xs));
6474 if (XS_NOERR(xs)) {
6475 XS_SETERR(xs, HBA_SELTIMEOUT);
6476 }
6477 return;
6478
6479 case RQCS_PORT_BUSY:
6517 if (XS_NOERR(xs)) {
6518 XS_SETERR(xs, HBA_SELTIMEOUT);
6519 }
6520 return;
6521
6522 case RQCS_PORT_BUSY:
6480 isp_prt(isp, ISP_LOGWARN,
6481 "port busy for target %d", XS_TGT(xs));
6523 isp_prt(isp, ISP_LOGWARN, "port busy for target %d", XS_TGT(xs));
6482 if (XS_NOERR(xs)) {
6483 XS_SETERR(xs, HBA_TGTBSY);
6484 }
6485 return;
6486
6487 default:
6524 if (XS_NOERR(xs)) {
6525 XS_SETERR(xs, HBA_TGTBSY);
6526 }
6527 return;
6528
6529 default:
6488 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x",
6489 sp->req_completion_status);
6530 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x", sp->req_completion_status);
6490 break;
6491 }
6492 if (XS_NOERR(xs)) {
6493 XS_SETERR(xs, HBA_BOTCH);
6494 }
6495}
6496
6497static void

--- 44 unchanged lines hidden (view full) ---

6542 XS_SET_RESID(xs, sp->req_resid);
6543 isp_xs_prt(isp, xs, ISP_LOGERR, "Data Overrun");
6544 if (XS_NOERR(xs)) {
6545 XS_SETERR(xs, HBA_DATAOVR);
6546 }
6547 return;
6548
6549 case RQCS_24XX_DRE: /* data reassembly error */
6531 break;
6532 }
6533 if (XS_NOERR(xs)) {
6534 XS_SETERR(xs, HBA_BOTCH);
6535 }
6536}
6537
6538static void

--- 44 unchanged lines hidden (view full) ---

6583 XS_SET_RESID(xs, sp->req_resid);
6584 isp_xs_prt(isp, xs, ISP_LOGERR, "Data Overrun");
6585 if (XS_NOERR(xs)) {
6586 XS_SETERR(xs, HBA_DATAOVR);
6587 }
6588 return;
6589
6590 case RQCS_24XX_DRE: /* data reassembly error */
6550 isp_prt(isp, ISP_LOGERR,
6551 "Chan %d data reassembly error for target %d",
6552 chan, XS_TGT(xs));
6591 isp_prt(isp, ISP_LOGERR, "Chan %d data reassembly error for target %d", chan, XS_TGT(xs));
6553 if (XS_NOERR(xs)) {
6554 XS_SETERR(xs, HBA_ABORTED);
6555 }
6556 *rp = XS_XFRLEN(xs);
6557 return;
6558
6559 case RQCS_24XX_TABORT: /* aborted by target */
6592 if (XS_NOERR(xs)) {
6593 XS_SETERR(xs, HBA_ABORTED);
6594 }
6595 *rp = XS_XFRLEN(xs);
6596 return;
6597
6598 case RQCS_24XX_TABORT: /* aborted by target */
6560 isp_prt(isp, ISP_LOGERR, "Chan %d target %d sent ABTS",
6561 chan, XS_TGT(xs));
6599 isp_prt(isp, ISP_LOGERR, "Chan %d target %d sent ABTS", chan, XS_TGT(xs));
6562 if (XS_NOERR(xs)) {
6563 XS_SETERR(xs, HBA_ABORTED);
6564 }
6565 return;
6566
6567 case RQCS_DATA_UNDERRUN:
6568 ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
6569 /*

--- 5 unchanged lines hidden (view full) ---

6575 (sp->req_resid > XS_XFRLEN(xs))) {
6576 isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
6577 if (XS_NOERR(xs)) {
6578 XS_SETERR(xs, HBA_BOTCH);
6579 }
6580 return;
6581 }
6582 XS_SET_RESID(xs, sp->req_resid);
6600 if (XS_NOERR(xs)) {
6601 XS_SETERR(xs, HBA_ABORTED);
6602 }
6603 return;
6604
6605 case RQCS_DATA_UNDERRUN:
6606 ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
6607 /*

--- 5 unchanged lines hidden (view full) ---

6613 (sp->req_resid > XS_XFRLEN(xs))) {
6614 isp_xs_prt(isp, xs, ISP_LOGWARN, bun, XS_XFRLEN(xs), sp->req_resid, (ru_marked)? "marked" : "not marked");
6615 if (XS_NOERR(xs)) {
6616 XS_SETERR(xs, HBA_BOTCH);
6617 }
6618 return;
6619 }
6620 XS_SET_RESID(xs, sp->req_resid);
6583 isp_xs_prt(isp, xs, ISP_LOGDEBUG0, "Data Underrun (%d) for command 0x%x", sp->req_resid, XS_CDBP(xs)[0] & 0xff);
6621 isp_xs_prt(isp, xs, ISP_LOG_WARN1, "Data Underrun (%d) for command 0x%x", sp->req_resid, XS_CDBP(xs)[0] & 0xff);
6584 if (XS_NOERR(xs)) {
6585 XS_SETERR(xs, HBA_NOERROR);
6586 }
6587 return;
6588
6589 case RQCS_PORT_UNAVAILABLE:
6590 /*
6591 * No such port on the loop. Moral equivalent of SELTIMEO

--- 19 unchanged lines hidden (view full) ---

6611 * There is no MBOX_INIT_LIP for the 24XX.
6612 */
6613 if (XS_NOERR(xs)) {
6614 XS_SETERR(xs, HBA_SELTIMEOUT);
6615 }
6616 return;
6617 }
6618 case RQCS_PORT_CHANGED:
6622 if (XS_NOERR(xs)) {
6623 XS_SETERR(xs, HBA_NOERROR);
6624 }
6625 return;
6626
6627 case RQCS_PORT_UNAVAILABLE:
6628 /*
6629 * No such port on the loop. Moral equivalent of SELTIMEO

--- 19 unchanged lines hidden (view full) ---

6649 * There is no MBOX_INIT_LIP for the 24XX.
6650 */
6651 if (XS_NOERR(xs)) {
6652 XS_SETERR(xs, HBA_SELTIMEOUT);
6653 }
6654 return;
6655 }
6656 case RQCS_PORT_CHANGED:
6619 isp_prt(isp, ISP_LOGWARN,
6620 "port changed for target %d chan %d", XS_TGT(xs), chan);
6657 isp_prt(isp, ISP_LOGWARN, "port changed for target %d chan %d", XS_TGT(xs), chan);
6621 if (XS_NOERR(xs)) {
6622 XS_SETERR(xs, HBA_SELTIMEOUT);
6623 }
6624 return;
6625
6626
6627 case RQCS_24XX_ENOMEM: /* f/w resource unavailable */
6658 if (XS_NOERR(xs)) {
6659 XS_SETERR(xs, HBA_SELTIMEOUT);
6660 }
6661 return;
6662
6663
6664 case RQCS_24XX_ENOMEM: /* f/w resource unavailable */
6628 isp_prt(isp, ISP_LOGWARN,
6629 "f/w resource unavailable for target %d chan %d",
6630 XS_TGT(xs), chan);
6665 isp_prt(isp, ISP_LOGWARN, "f/w resource unavailable for target %d chan %d", XS_TGT(xs), chan);
6631 if (XS_NOERR(xs)) {
6632 *XS_STSP(xs) = SCSI_BUSY;
6633 XS_SETERR(xs, HBA_TGTBSY);
6634 }
6635 return;
6636
6637 case RQCS_24XX_TMO: /* task management overrun */
6666 if (XS_NOERR(xs)) {
6667 *XS_STSP(xs) = SCSI_BUSY;
6668 XS_SETERR(xs, HBA_TGTBSY);
6669 }
6670 return;
6671
6672 case RQCS_24XX_TMO: /* task management overrun */
6638 isp_prt(isp, ISP_LOGWARN,
6639 "command for target %d overlapped task management for "
6640 "chan %d", XS_TGT(xs), chan);
6673 isp_prt(isp, ISP_LOGWARN, "command for target %d overlapped task management for chan %d", XS_TGT(xs), chan);
6641 if (XS_NOERR(xs)) {
6642 *XS_STSP(xs) = SCSI_BUSY;
6643 XS_SETERR(xs, HBA_TGTBSY);
6644 }
6645 return;
6646
6647 default:
6674 if (XS_NOERR(xs)) {
6675 *XS_STSP(xs) = SCSI_BUSY;
6676 XS_SETERR(xs, HBA_TGTBSY);
6677 }
6678 return;
6679
6680 default:
6648 isp_prt(isp, ISP_LOGERR,
6649 "Unknown Completion Status 0x%x on chan %d",
6650 sp->req_completion_status, chan);
6681 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x on chan %d", sp->req_completion_status, chan);
6651 break;
6652 }
6653 if (XS_NOERR(xs)) {
6654 XS_SETERR(xs, HBA_BOTCH);
6655 }
6656}
6657
6658static void

--- 327 unchanged lines hidden (view full) ---

6986 ISP_FC_OPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
6987 ISP_FC_OPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
6988 ISP_FC_OPMAP(0x0f, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
6989 ISP_FC_OPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */
6990 ISP_FC_OPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
6991 ISP_FC_OPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
6992 ISP_FC_OPMAP_FULL(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
6993 ISP_FC_OPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
6682 break;
6683 }
6684 if (XS_NOERR(xs)) {
6685 XS_SETERR(xs, HBA_BOTCH);
6686 }
6687}
6688
6689static void

--- 327 unchanged lines hidden (view full) ---

7017 ISP_FC_OPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
7018 ISP_FC_OPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
7019 ISP_FC_OPMAP(0x0f, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
7020 ISP_FC_OPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */
7021 ISP_FC_OPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
7022 ISP_FC_OPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
7023 ISP_FC_OPMAP_FULL(0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
7024 ISP_FC_OPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
6994 ISP_FC_OPMAP_FULL(0x0, 0x0, 0x0, 0x01, 0x0, 0x3, 0x80, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */
7025 ISP_FC_OPMAP_FULL(0x0, 0x0, 0x0, 0x01, 0x0, 0x3, 0x80, 0x7f), /* 0x08: MBOX_ABOUT_FIRMWARE */
6995 ISP_FC_OPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */
6996 ISP_FC_OPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
6997 ISP_FC_OPMAP_HALF(0x1, 0xff, 0x0, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */
6998 ISP_FC_OPMAP(0x00, 0x00), /* 0x0c: */
6999 ISP_FC_OPMAP_HALF(0x1, 0x0f, 0x0, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */
7000 ISP_FC_OPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
7001 ISP_FC_OPMAP_HALF(0x1, 0x03, 0x0, 0x0d), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */
7002 ISP_FC_OPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */

--- 1467 unchanged lines hidden ---
7026 ISP_FC_OPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */
7027 ISP_FC_OPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
7028 ISP_FC_OPMAP_HALF(0x1, 0xff, 0x0, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */
7029 ISP_FC_OPMAP(0x00, 0x00), /* 0x0c: */
7030 ISP_FC_OPMAP_HALF(0x1, 0x0f, 0x0, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */
7031 ISP_FC_OPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
7032 ISP_FC_OPMAP_HALF(0x1, 0x03, 0x0, 0x0d), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */
7033 ISP_FC_OPMAP(0x1f, 0x11), /* 0x10: MBOX_INIT_REQ_QUEUE */

--- 1467 unchanged lines hidden ---