isp.c (166894) | isp.c (166929) |
---|---|
1/*- 2 * Copyright (c) 1997-2006 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 * 1. Redistributions of source code must retain the above copyright --- 29 unchanged lines hidden (view full) --- 38/* 39 * Include header file appropriate for platform we're building on. 40 */ 41#ifdef __NetBSD__ 42#include <dev/ic/isp_netbsd.h> 43#endif 44#ifdef __FreeBSD__ 45#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997-2006 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 * 1. Redistributions of source code must retain the above copyright --- 29 unchanged lines hidden (view full) --- 38/* 39 * Include header file appropriate for platform we're building on. 40 */ 41#ifdef __NetBSD__ 42#include <dev/ic/isp_netbsd.h> 43#endif 44#ifdef __FreeBSD__ 45#include <sys/cdefs.h> |
46__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 166894 2007-02-23 05:39:58Z mjacob $"); | 46__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 166929 2007-02-23 21:59:21Z mjacob $"); |
47#include <dev/isp/isp_freebsd.h> 48#endif 49#ifdef __OpenBSD__ 50#include <dev/ic/isp_openbsd.h> 51#endif 52#ifdef __linux__ 53#include "isp_linux.h" 54#endif --- 1495 unchanged lines hidden (view full) --- 1550 * Fibre Channel specific initialization. 1551 */ 1552static void 1553isp_fibre_init(ispsoftc_t *isp) 1554{ 1555 fcparam *fcp; 1556 isp_icb_t local, *icbp = &local; 1557 mbreg_t mbs; | 47#include <dev/isp/isp_freebsd.h> 48#endif 49#ifdef __OpenBSD__ 50#include <dev/ic/isp_openbsd.h> 51#endif 52#ifdef __linux__ 53#include "isp_linux.h" 54#endif --- 1495 unchanged lines hidden (view full) --- 1550 * Fibre Channel specific initialization. 1551 */ 1552static void 1553isp_fibre_init(ispsoftc_t *isp) 1554{ 1555 fcparam *fcp; 1556 isp_icb_t local, *icbp = &local; 1557 mbreg_t mbs; |
1558 int ownloopid; |
|
1558 uint64_t nwwn, pwwn; 1559 1560 fcp = isp->isp_param; 1561 1562 MEMZERO(icbp, sizeof (*icbp)); 1563 icbp->icb_version = ICB_VERSION1; 1564 icbp->icb_fwoptions = fcp->isp_fwoptions; 1565 --- 59 unchanged lines hidden (view full) --- 1625 isp_prt(isp, ISP_LOGERR, 1626 "bad execution throttle of %d- using 16", 1627 fcp->isp_execthrottle); 1628 icbp->icb_execthrottle = ICB_DFLT_THROTTLE; 1629 } 1630 icbp->icb_retry_delay = fcp->isp_retry_delay; 1631 icbp->icb_retry_count = fcp->isp_retry_count; 1632 icbp->icb_hardaddr = fcp->isp_loopid; | 1559 uint64_t nwwn, pwwn; 1560 1561 fcp = isp->isp_param; 1562 1563 MEMZERO(icbp, sizeof (*icbp)); 1564 icbp->icb_version = ICB_VERSION1; 1565 icbp->icb_fwoptions = fcp->isp_fwoptions; 1566 --- 59 unchanged lines hidden (view full) --- 1626 isp_prt(isp, ISP_LOGERR, 1627 "bad execution throttle of %d- using 16", 1628 fcp->isp_execthrottle); 1629 icbp->icb_execthrottle = ICB_DFLT_THROTTLE; 1630 } 1631 icbp->icb_retry_delay = fcp->isp_retry_delay; 1632 icbp->icb_retry_count = fcp->isp_retry_count; 1633 icbp->icb_hardaddr = fcp->isp_loopid; |
1634 ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0; |
|
1633 if (icbp->icb_hardaddr > 125) { | 1635 if (icbp->icb_hardaddr > 125) { |
1634 /* 1635 * We end up with these Loop IDs for F-Port topologies 1636 */ 1637 if (icbp->icb_hardaddr != 0xff && 1638 icbp->icb_hardaddr != 0x800 && 1639 icbp->icb_hardaddr != 0xffff) { 1640 isp_prt(isp, ISP_LOGERR, 1641 "bad hard address %u- resetting to zero", 1642 icbp->icb_hardaddr); 1643 icbp->icb_hardaddr = 0; 1644 } | 1636 icbp->icb_hardaddr = 0; 1637 ownloopid = 0; |
1645 } 1646 1647 /* 1648 * Our life seems so much better with 2200s and later with 1649 * the latest f/w if we set Hard Address. 1650 */ | 1638 } 1639 1640 /* 1641 * Our life seems so much better with 2200s and later with 1642 * the latest f/w if we set Hard Address. 1643 */ |
1651 if (ISP_FW_NEWER_THAN(isp, 2, 2, 5)) { | 1644 if (ownloopid || ISP_FW_NEWER_THAN(isp, 2, 2, 5)) { |
1652 icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS; 1653 } 1654 1655 /* 1656 * Right now we just set extended options to prefer point-to-point 1657 * over loop based upon some soft config options. 1658 * 1659 * NB: for the 2300, ICBOPT_EXTENDED is required. --- 135 unchanged lines hidden (view full) --- 1795 mbs.timeout = 30 * 1000000; 1796 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)", 1797 fcp->isp_scratch, (uint32_t) ((uint64_t)fcp->isp_scdma >> 32), 1798 (uint32_t) fcp->isp_scdma); 1799 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp)); 1800 isp_mboxcmd(isp, &mbs); 1801 FC_SCRATCH_RELEASE(isp); 1802 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { | 1645 icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS; 1646 } 1647 1648 /* 1649 * Right now we just set extended options to prefer point-to-point 1650 * over loop based upon some soft config options. 1651 * 1652 * NB: for the 2300, ICBOPT_EXTENDED is required. --- 135 unchanged lines hidden (view full) --- 1788 mbs.timeout = 30 * 1000000; 1789 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)", 1790 fcp->isp_scratch, (uint32_t) ((uint64_t)fcp->isp_scdma >> 32), 1791 (uint32_t) fcp->isp_scdma); 1792 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp)); 1793 isp_mboxcmd(isp, &mbs); 1794 FC_SCRATCH_RELEASE(isp); 1795 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) { |
1796 isp_print_bytes(isp, "isp_fibre_init", sizeof (*icbp), icbp); |
|
1803 return; 1804 } 1805 isp->isp_reqidx = 0; 1806 isp->isp_reqodx = 0; 1807 isp->isp_residx = 0; 1808 1809 /* 1810 * Whatever happens, we're now committed to being here. 1811 */ 1812 isp->isp_state = ISP_INITSTATE; 1813} 1814 1815static void 1816isp_fibre_init_2400(ispsoftc_t *isp) 1817{ 1818 fcparam *fcp; 1819 isp_icb_2400_t local, *icbp = &local; 1820 mbreg_t mbs; | 1797 return; 1798 } 1799 isp->isp_reqidx = 0; 1800 isp->isp_reqodx = 0; 1801 isp->isp_residx = 0; 1802 1803 /* 1804 * Whatever happens, we're now committed to being here. 1805 */ 1806 isp->isp_state = ISP_INITSTATE; 1807} 1808 1809static void 1810isp_fibre_init_2400(ispsoftc_t *isp) 1811{ 1812 fcparam *fcp; 1813 isp_icb_2400_t local, *icbp = &local; 1814 mbreg_t mbs; |
1815 int ownloopid; |
|
1821 uint64_t nwwn, pwwn; 1822 1823 fcp = isp->isp_param; 1824 1825 /* 1826 * Turn on LIP F8 async event (1) 1827 */ 1828 MEMZERO(&mbs, sizeof (mbs)); --- 52 unchanged lines hidden (view full) --- 1881 return; 1882 } 1883 icbp->icb_xchgcnt = mbs.param[3]; 1884 } 1885 1886 icbp->icb_fwoptions1 = fcp->isp_fwoptions; 1887 1888 icbp->icb_hardaddr = fcp->isp_loopid; | 1816 uint64_t nwwn, pwwn; 1817 1818 fcp = isp->isp_param; 1819 1820 /* 1821 * Turn on LIP F8 async event (1) 1822 */ 1823 MEMZERO(&mbs, sizeof (mbs)); --- 52 unchanged lines hidden (view full) --- 1876 return; 1877 } 1878 icbp->icb_xchgcnt = mbs.param[3]; 1879 } 1880 1881 icbp->icb_fwoptions1 = fcp->isp_fwoptions; 1882 1883 icbp->icb_hardaddr = fcp->isp_loopid; |
1884 ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0; |
|
1889 if (icbp->icb_hardaddr > 125) { | 1885 if (icbp->icb_hardaddr > 125) { |
1890 /* 1891 * We end up with these Loop IDs for F-Port topologies 1892 */ 1893 if (icbp->icb_hardaddr != 0xff && 1894 icbp->icb_hardaddr != 0x800 && 1895 icbp->icb_hardaddr != 0xffff) { 1896 isp_prt(isp, ISP_LOGERR, 1897 "bad hard address %u- resetting to zero", 1898 icbp->icb_hardaddr); 1899 icbp->icb_hardaddr = 0; 1900 } | 1886 icbp->icb_hardaddr = 0; 1887 ownloopid = 0; |
1901 } | 1888 } |
1902 1903 if (isp->isp_confopts & ISP_CFG_OWNLOOPID) { | 1889 if (ownloopid) { |
1904 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS; 1905 } 1906 1907 icbp->icb_fwoptions2 = fcp->isp_xfwoptions; 1908 switch(isp->isp_confopts & ISP_CFG_PORT_PREF) { 1909 case ISP_CFG_NPORT: 1910 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK; 1911 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_2_LOOP; --- 363 unchanged lines hidden (view full) --- 2275 isp_mboxcmd(isp, &mbs); 2276 2277 switch (mbs.param[0]) { 2278 case MBOX_PORT_ID_USED: 2279 isp_prt(isp, ISP_LOGDEBUG0, 2280 "isp_plogi_old: portid 0x%06x already logged in as %u", 2281 portid, mbs.param[1]); 2282 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16)); | 1890 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS; 1891 } 1892 1893 icbp->icb_fwoptions2 = fcp->isp_xfwoptions; 1894 switch(isp->isp_confopts & ISP_CFG_PORT_PREF) { 1895 case ISP_CFG_NPORT: 1896 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK; 1897 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_2_LOOP; --- 363 unchanged lines hidden (view full) --- 2261 isp_mboxcmd(isp, &mbs); 2262 2263 switch (mbs.param[0]) { 2264 case MBOX_PORT_ID_USED: 2265 isp_prt(isp, ISP_LOGDEBUG0, 2266 "isp_plogi_old: portid 0x%06x already logged in as %u", 2267 portid, mbs.param[1]); 2268 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16)); |
2283 break; | |
2284 2285 case MBOX_LOOP_ID_USED: 2286 isp_prt(isp, ISP_LOGDEBUG0, 2287 "isp_plogi_old: handle %u in use for port id 0x%02xXXXX", 2288 handle, mbs.param[1] & 0xff); 2289 return (MBOX_LOOP_ID_USED); 2290 2291 case MBOX_COMMAND_COMPLETE: --- 666 unchanged lines hidden (view full) --- 2958 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname); 2959 tmp.roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; 2960 tmp.portid = pdb.portid; 2961 tmp.handle = pdb.handle; 2962 2963 /* 2964 * Check to make sure it's still a valid entry. The 24XX seems 2965 * to return a portid but not a WWPN/WWNN or role for devices | 2269 2270 case MBOX_LOOP_ID_USED: 2271 isp_prt(isp, ISP_LOGDEBUG0, 2272 "isp_plogi_old: handle %u in use for port id 0x%02xXXXX", 2273 handle, mbs.param[1] & 0xff); 2274 return (MBOX_LOOP_ID_USED); 2275 2276 case MBOX_COMMAND_COMPLETE: --- 666 unchanged lines hidden (view full) --- 2943 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname); 2944 tmp.roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT; 2945 tmp.portid = pdb.portid; 2946 tmp.handle = pdb.handle; 2947 2948 /* 2949 * Check to make sure it's still a valid entry. The 24XX seems 2950 * to return a portid but not a WWPN/WWNN or role for devices |
2966 * which shift on a loop, or have a WWPN/WWNN but no portid. | 2951 * which shift on a loop. |
2967 */ 2968 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) { | 2952 */ 2953 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) { |
2969 if (isp->isp_dblev & ISP_LOGSANCFG) { 2970 int a, b, c; 2971 a = !(tmp.node_wwn == 0); 2972 b = !(tmp.port_wwn == 0); 2973 c = !(tmp.portid == 0); 2974 isp_prt(isp, ISP_LOGALL, 2975 "bad pdb (%1d%1d%1d) @ handle 0x%x", 2976 a, b, c, handle); 2977 isp_dump_portdb(isp); 2978 } | 2954 int a, b, c; 2955 a = (tmp.node_wwn == 0); 2956 b = (tmp.port_wwn == 0); 2957 c = (tmp.portid == 0); 2958 isp_prt(isp, ISP_LOGWARN, 2959 "bad pdb (%1d%1d%1d) @ handle 0x%x", a, b, c, 2960 handle); 2961 isp_dump_portdb(isp); |
2979 continue; 2980 } 2981 2982 /* 2983 * Now search the entire port database 2984 * for the same Port and Node WWN. 2985 */ 2986 for (i = 0; i < MAX_FC_TARG; i++) { --- 1584 unchanged lines hidden (view full) --- 4571 "mailbox cmd (0x%x) with no waiters", mbox); 4572 } 4573 } else if (isp_parse_async(isp, mbox) < 0) { 4574 return; 4575 } 4576 if ((IS_FC(isp) && mbox != ASYNC_RIO_RESP) || 4577 isp->isp_state != ISP_RUNSTATE) { 4578 goto out; | 2962 continue; 2963 } 2964 2965 /* 2966 * Now search the entire port database 2967 * for the same Port and Node WWN. 2968 */ 2969 for (i = 0; i < MAX_FC_TARG; i++) { --- 1584 unchanged lines hidden (view full) --- 4554 "mailbox cmd (0x%x) with no waiters", mbox); 4555 } 4556 } else if (isp_parse_async(isp, mbox) < 0) { 4557 return; 4558 } 4559 if ((IS_FC(isp) && mbox != ASYNC_RIO_RESP) || 4560 isp->isp_state != ISP_RUNSTATE) { 4561 goto out; |
4579 return; | |
4580 } 4581 } 4582 4583 /* 4584 * We can't be getting this now. 4585 */ 4586 if (isp->isp_state != ISP_RUNSTATE) { 4587 isp_prt(isp, ISP_LOGINFO, --- 2930 unchanged lines hidden (view full) --- 7518 int loops = 0; 7519 const uint32_t base = 0x7ffe0000; 7520 uint32_t tmp; 7521 7522 ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr); 7523 for (loops = 0; loops < 5000; loops++) { 7524 USEC_DELAY(10); 7525 tmp = ISP_READ(isp, BIU2400_FLASH_ADDR); | 4562 } 4563 } 4564 4565 /* 4566 * We can't be getting this now. 4567 */ 4568 if (isp->isp_state != ISP_RUNSTATE) { 4569 isp_prt(isp, ISP_LOGINFO, --- 2930 unchanged lines hidden (view full) --- 7500 int loops = 0; 7501 const uint32_t base = 0x7ffe0000; 7502 uint32_t tmp; 7503 7504 ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr); 7505 for (loops = 0; loops < 5000; loops++) { 7506 USEC_DELAY(10); 7507 tmp = ISP_READ(isp, BIU2400_FLASH_ADDR); |
7526 if ((tmp & (1 << 31)) != 0) { | 7508 if ((tmp & (1U << 31)) != 0) { |
7527 break; 7528 } 7529 } | 7509 break; 7510 } 7511 } |
7530 if (tmp & (1 << 31)) { | 7512 if (tmp & (1U << 31)) { |
7531 tmp = ISP_READ(isp, BIU2400_FLASH_DATA); 7532 *rp = tmp; 7533 } else { 7534 *rp = 0xffffffff; 7535 } 7536} 7537 7538static void --- 794 unchanged lines hidden --- | 7513 tmp = ISP_READ(isp, BIU2400_FLASH_DATA); 7514 *rp = tmp; 7515 } else { 7516 *rp = 0xffffffff; 7517 } 7518} 7519 7520static void --- 794 unchanged lines hidden --- |