Deleted Added
full compact
isp.c (290981) isp.c (290993)
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 290981 2015-11-17 14:22:56Z mav $");
50__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 290993 2015-11-17 16:33:46Z mav $");
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
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 do { \
69 isp_prt(isp, ISP_LOG_SANCFG, \
70 "Chan %d ISP_MARK_PORTDB@LINE %d", (b), __LINE__); \
71 isp_mark_portdb((a), (b), (c)); \
72 } while (0)
73
74/*
75 * Local static data
76 */
77static 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)";
78static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
79static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x handle 0x%x, Connection '%s'";
80static const char bun[] = "bad underrun (count %d, resid %d, status %s)";

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

127static int isp_scan_loop(ispsoftc_t *, int);
128static int isp_gid_ft_sns(ispsoftc_t *, int);
129static int isp_gid_ft_ct_passthru(ispsoftc_t *, int);
130static int isp_scan_fabric(ispsoftc_t *, int);
131static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *);
132static int isp_register_fc4_type(ispsoftc_t *, int);
133static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
134static uint16_t isp_next_handle(ispsoftc_t *, uint16_t *);
67
68/*
69 * Local static data
70 */
71static 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)";
72static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
73static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x handle 0x%x, Connection '%s'";
74static const char bun[] = "bad underrun (count %d, resid %d, status %s)";

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

121static int isp_scan_loop(ispsoftc_t *, int);
122static int isp_gid_ft_sns(ispsoftc_t *, int);
123static int isp_gid_ft_ct_passthru(ispsoftc_t *, int);
124static int isp_scan_fabric(ispsoftc_t *, int);
125static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *);
126static int isp_register_fc4_type(ispsoftc_t *, int);
127static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
128static uint16_t isp_next_handle(ispsoftc_t *, uint16_t *);
135static void isp_fw_state(ispsoftc_t *, int);
129static int isp_fw_state(ispsoftc_t *, int);
136static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
137static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
138
139static void isp_spi_update(ispsoftc_t *, int);
140static void isp_setdfltsdparm(ispsoftc_t *);
141static void isp_setdfltfcparm(ispsoftc_t *, int);
142static int isp_read_nvram(ispsoftc_t *, int);
143static int isp_read_nvram_2400(ispsoftc_t *, uint8_t *);
144static void isp_rdnvram_word(ispsoftc_t *, int, uint16_t *);
145static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *);
146static void isp_parse_nvram_1020(ispsoftc_t *, uint8_t *);
147static void isp_parse_nvram_1080(ispsoftc_t *, int, uint8_t *);
148static void isp_parse_nvram_12160(ispsoftc_t *, int, uint8_t *);
149static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *);
150static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
151
130static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
131static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
132
133static void isp_spi_update(ispsoftc_t *, int);
134static void isp_setdfltsdparm(ispsoftc_t *);
135static void isp_setdfltfcparm(ispsoftc_t *, int);
136static int isp_read_nvram(ispsoftc_t *, int);
137static int isp_read_nvram_2400(ispsoftc_t *, uint8_t *);
138static void isp_rdnvram_word(ispsoftc_t *, int, uint16_t *);
139static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *);
140static void isp_parse_nvram_1020(ispsoftc_t *, uint8_t *);
141static void isp_parse_nvram_1080(ispsoftc_t *, int, uint8_t *);
142static void isp_parse_nvram_12160(ispsoftc_t *, int, uint8_t *);
143static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *);
144static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
145
146static void
147isp_change_fw_state(ispsoftc_t *isp, int chan, int state)
148{
149 fcparam *fcp = FCPARAM(isp, chan);
150
151 if (fcp->isp_fwstate == state)
152 return;
153 isp_prt(isp, ISP_LOGCONFIG|ISP_LOG_SANCFG,
154 "Chan %d Firmware state <%s->%s>", chan,
155 isp_fc_fw_statename(fcp->isp_fwstate), isp_fc_fw_statename(state));
156 fcp->isp_fwstate = state;
157}
158
152/*
153 * Reset Hardware.
154 *
155 * Hit the chip over the head, download new f/w if available and set it running.
156 *
157 * Locking done elsewhere.
158 */
159

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

1262 "only can enable 1 of %d channels", isp->isp_nchan);
1263 isp->isp_nchan = 1;
1264 } else if (!ISP_CAP_VP0(isp)) {
1265 isp_prt(isp, ISP_LOGWARN, "We can not use MULTIID "
1266 "feature properly without VP0_Decoupling");
1267 isp->isp_nchan = 1;
1268 }
1269 }
159/*
160 * Reset Hardware.
161 *
162 * Hit the chip over the head, download new f/w if available and set it running.
163 *
164 * Locking done elsewhere.
165 */
166

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

1269 "only can enable 1 of %d channels", isp->isp_nchan);
1270 isp->isp_nchan = 1;
1271 } else if (!ISP_CAP_VP0(isp)) {
1272 isp_prt(isp, ISP_LOGWARN, "We can not use MULTIID "
1273 "feature properly without VP0_Decoupling");
1274 isp->isp_nchan = 1;
1275 }
1276 }
1270 for (i = 0; i < isp->isp_nchan; i++) {
1271 isp_fw_state(isp, i);
1277 if (IS_FC(isp)) {
1278 for (i = 0; i < isp->isp_nchan; i++)
1279 isp_change_fw_state(isp, i, FW_CONFIG_WAIT);
1272 }
1273 if (isp->isp_dead) {
1274 isp_shutdown(isp);
1275 ISP_DISABLE_INTS(isp);
1276 return;
1277 }
1278
1279 isp->isp_state = ISP_RESETSTATE;

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

2572 }
2573 if (IS_24XX(isp)) {
2574 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill);
2575 pdb->handle = un.bill.pdb_handle;
2576 pdb->prli_word3 = un.bill.pdb_prli_svc3;
2577 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
2578 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
2579 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
1280 }
1281 if (isp->isp_dead) {
1282 isp_shutdown(isp);
1283 ISP_DISABLE_INTS(isp);
1284 return;
1285 }
1286
1287 isp->isp_state = ISP_RESETSTATE;

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

2580 }
2581 if (IS_24XX(isp)) {
2582 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill);
2583 pdb->handle = un.bill.pdb_handle;
2584 pdb->prli_word3 = un.bill.pdb_prli_svc3;
2585 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
2586 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
2587 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
2580 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d handle 0x%x Port 0x%06x flags 0x%x curstate %x", chan, id, pdb->portid, un.bill.pdb_flags, un.bill.pdb_curstate);
2588 isp_prt(isp, ISP_LOGDEBUG1,
2589 "Chan %d handle 0x%x Port 0x%06x flags 0x%x curstate %x",
2590 chan, id, pdb->portid, un.bill.pdb_flags,
2591 un.bill.pdb_curstate);
2581 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
2582 mbs.param[0] = MBOX_NOT_LOGGED_IN;
2583 if (dolock) {
2584 FC_SCRATCH_RELEASE(isp, chan);
2585 }
2586 return (mbs.param[0]);
2587 }
2588 } else {
2589 isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred);
2590 pdb->handle = un.fred.pdb_loopid;
2591 pdb->prli_word3 = un.fred.pdb_prli_svc3;
2592 pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
2593 ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
2594 ISP_MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
2592 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE || un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
2593 mbs.param[0] = MBOX_NOT_LOGGED_IN;
2594 if (dolock) {
2595 FC_SCRATCH_RELEASE(isp, chan);
2596 }
2597 return (mbs.param[0]);
2598 }
2599 } else {
2600 isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred);
2601 pdb->handle = un.fred.pdb_loopid;
2602 pdb->prli_word3 = un.fred.pdb_prli_svc3;
2603 pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
2604 ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
2605 ISP_MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
2606 isp_prt(isp, ISP_LOGDEBUG1,
2607 "Chan %d handle 0x%x Port 0x%06x", chan, id, pdb->portid);
2595 }
2596 if (dolock) {
2597 FC_SCRATCH_RELEASE(isp, chan);
2598 }
2599 return (0);
2600}
2601
2602static int

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

2694 pdb.portname[5], pdb.portname[6], pdb.portname[7]);
2695 }
2696}
2697
2698static uint64_t
2699isp_get_wwn(ispsoftc_t *isp, int chan, int loopid, int nodename)
2700{
2701 uint64_t wwn = INI_NONE;
2608 }
2609 if (dolock) {
2610 FC_SCRATCH_RELEASE(isp, chan);
2611 }
2612 return (0);
2613}
2614
2615static int

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

2707 pdb.portname[5], pdb.portname[6], pdb.portname[7]);
2708 }
2709}
2710
2711static uint64_t
2712isp_get_wwn(ispsoftc_t *isp, int chan, int loopid, int nodename)
2713{
2714 uint64_t wwn = INI_NONE;
2702 fcparam *fcp = FCPARAM(isp, chan);
2703 mbreg_t mbs;
2704
2715 mbreg_t mbs;
2716
2705 if (fcp->isp_fwstate < FW_READY ||
2706 fcp->isp_loopstate < LOOP_PDB_RCVD) {
2707 return (wwn);
2708 }
2709 MBSINIT(&mbs, MBOX_GET_PORT_NAME,
2710 MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_PARAM_ERROR), 500000);
2711 if (ISP_CAP_2KLOGIN(isp)) {
2712 mbs.param[1] = loopid;
2713 if (nodename) {
2714 mbs.param[10] = 1;
2715 }
2716 mbs.param[9] = chan;

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

2753 * Make sure we have good FC link.
2754 */
2755
2756static int
2757isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
2758{
2759 mbreg_t mbs;
2760 int check_for_fabric, r;
2717 MBSINIT(&mbs, MBOX_GET_PORT_NAME,
2718 MBLOGALL & ~MBLOGMASK(MBOX_COMMAND_PARAM_ERROR), 500000);
2719 if (ISP_CAP_2KLOGIN(isp)) {
2720 mbs.param[1] = loopid;
2721 if (nodename) {
2722 mbs.param[10] = 1;
2723 }
2724 mbs.param[9] = chan;

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

2761 * Make sure we have good FC link.
2762 */
2763
2764static int
2765isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
2766{
2767 mbreg_t mbs;
2768 int check_for_fabric, r;
2761 uint8_t lwfs;
2762 int loopid;
2763 fcparam *fcp;
2764 fcportdb_t *lp;
2765 isp_pdb_t pdb;
2766 NANOTIME_T hra, hrb;
2767
2768 fcp = FCPARAM(isp, chan);
2769
2769 int loopid;
2770 fcparam *fcp;
2771 fcportdb_t *lp;
2772 isp_pdb_t pdb;
2773 NANOTIME_T hra, hrb;
2774
2775 fcp = FCPARAM(isp, chan);
2776
2770 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Link Test Entry", chan);
2771 ISP_MARK_PORTDB(isp, chan, 1);
2777 /* Mark port database entries for following scan. */
2778 isp_mark_portdb(isp, chan, 1);
2772
2779
2780 if (fcp->isp_loopstate >= LOOP_LTEST_DONE)
2781 return (0);
2782
2783 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC link test", chan);
2784 fcp->isp_loopstate = LOOP_TESTING_LINK;
2785
2773 /*
2774 * Wait up to N microseconds for F/W to go to a ready state.
2775 */
2786 /*
2787 * Wait up to N microseconds for F/W to go to a ready state.
2788 */
2776 lwfs = FW_CONFIG_WAIT;
2777 GET_NANOTIME(&hra);
2778 while (1) {
2789 GET_NANOTIME(&hra);
2790 while (1) {
2779 isp_fw_state(isp, chan);
2780 if (lwfs != fcp->isp_fwstate) {
2781 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));
2782 lwfs = fcp->isp_fwstate;
2783 }
2791 isp_change_fw_state(isp, chan, isp_fw_state(isp, chan));
2784 if (fcp->isp_fwstate == FW_READY) {
2785 break;
2786 }
2787 GET_NANOTIME(&hrb);
2788 if ((NANOTIME_SUB(&hrb, &hra) / 1000 + 1000 >= usdelay))
2789 break;
2790 ISP_SLEEP(isp, 1000);
2791 }

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

2855 int i;
2856 for (i = 0; alpa_map[i]; i++) {
2857 if (alpa_map[i] == alpa) {
2858 break;
2859 }
2860 }
2861 if (alpa_map[i] && fcp->isp_loopid != i) {
2862 isp_prt(isp, ISP_LOG_SANCFG,
2792 if (fcp->isp_fwstate == FW_READY) {
2793 break;
2794 }
2795 GET_NANOTIME(&hrb);
2796 if ((NANOTIME_SUB(&hrb, &hra) / 1000 + 1000 >= usdelay))
2797 break;
2798 ISP_SLEEP(isp, 1000);
2799 }

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

2863 int i;
2864 for (i = 0; alpa_map[i]; i++) {
2865 if (alpa_map[i] == alpa) {
2866 break;
2867 }
2868 }
2869 if (alpa_map[i] && fcp->isp_loopid != i) {
2870 isp_prt(isp, ISP_LOG_SANCFG,
2863 "Chan %d deriving loopid %d from AL_PA map (AL_PA 0x%x) and ignoring returned value %d (AL_PA 0x%x)",
2871 "Chan %d Deriving loopid %d from AL_PA map (AL_PA 0x%x) and ignoring returned value %d (AL_PA 0x%x)",
2864 chan, i, alpa_map[i], fcp->isp_loopid, alpa);
2865 fcp->isp_loopid = i;
2866 }
2867 }
2868 }
2869
2870
2871 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE FOR 2K F/W? XXX */

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

2948 fcp->isp_gbspeed = 2;
2949 } else if (mbs.param[1] == MBGSD_ONEGB) {
2950 isp_prt(isp, ISP_LOGINFO, "Chan %d 1Gb link speed", chan);
2951 fcp->isp_gbspeed = 1;
2952 }
2953 }
2954 }
2955
2872 chan, i, alpa_map[i], fcp->isp_loopid, alpa);
2873 fcp->isp_loopid = i;
2874 }
2875 }
2876 }
2877
2878
2879 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE FOR 2K F/W? XXX */

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

2956 fcp->isp_gbspeed = 2;
2957 } else if (mbs.param[1] == MBGSD_ONEGB) {
2958 isp_prt(isp, ISP_LOGINFO, "Chan %d 1Gb link speed", chan);
2959 fcp->isp_gbspeed = 1;
2960 }
2961 }
2962 }
2963
2964 fcp->isp_loopstate = LOOP_LTEST_DONE;
2956 /*
2957 * Announce ourselves, too.
2958 */
2959 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));
2965 /*
2966 * Announce ourselves, too.
2967 */
2968 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));
2960 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Link Test Complete", chan);
2969 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC link test done", chan);
2961 return (0);
2962}
2963
2964/*
2965 * Complete the synchronization of our Port Database.
2966 *
2967 * At this point, we've scanned the local loop (if any) and the fabric
2968 * and performed fabric logins on all new devices.
2969 *
2970 return (0);
2971}
2972
2973/*
2974 * Complete the synchronization of our Port Database.
2975 *
2976 * At this point, we've scanned the local loop (if any) and the fabric
2977 * and performed fabric logins on all new devices.
2978 *
2970 * Our task here is to go through our port database and remove any entities
2979 * Our task here is to go through our port database removing any entities
2971 * that are still marked probational (issuing PLOGO for ones which we had
2980 * that are still marked probational (issuing PLOGO for ones which we had
2972 * PLOGI'd into) or are dead.
2973 *
2974 * Our task here is to also check policy to decide whether devices which
2975 * have *changed* in some way should still be kept active. For example,
2976 * if a device has just changed PortID, we can either elect to treat it
2977 * as an old device or as a newly arrived device (and notify the outer
2978 * layer appropriately).
2979 *
2980 * We also do initiator map target id assignment here for new initiator
2981 * devices and refresh old ones ot make sure that they point to the correct
2982 * entities.
2981 * PLOGI'd into) or are dead, and notifying upper layers about new/changed
2982 * devices.
2983 */
2984static int
2985isp_pdb_sync(ispsoftc_t *isp, int chan)
2986{
2987 fcparam *fcp = FCPARAM(isp, chan);
2988 fcportdb_t *lp;
2989 uint16_t dbidx;
2990
2983 */
2984static int
2985isp_pdb_sync(ispsoftc_t *isp, int chan)
2986{
2987 fcparam *fcp = FCPARAM(isp, chan);
2988 fcportdb_t *lp;
2989 uint16_t dbidx;
2990
2991 if (fcp->isp_loopstate == LOOP_READY) {
2992 return (0);
2993 }
2994
2995 /*
2996 * Make sure we're okay for doing this right now.
2997 */
2998 if (fcp->isp_loopstate != LOOP_PDB_RCVD &&
2999 fcp->isp_loopstate != LOOP_FSCAN_DONE &&
3000 fcp->isp_loopstate != LOOP_LSCAN_DONE) {
3001 isp_prt(isp, ISP_LOGWARN, "isp_pdb_sync: bad loopstate %d",
3002 fcp->isp_loopstate);
2991 if (fcp->isp_loopstate < LOOP_FSCAN_DONE) {
3003 return (-1);
3004 }
2992 return (-1);
2993 }
3005
3006 if (fcp->isp_topo == TOPO_FL_PORT ||
3007 fcp->isp_topo == TOPO_NL_PORT ||
3008 fcp->isp_topo == TOPO_N_PORT) {
3009 if (fcp->isp_loopstate < LOOP_LSCAN_DONE) {
3010 if (isp_scan_loop(isp, chan) != 0) {
3011 isp_prt(isp, ISP_LOGWARN,
3012 "isp_pdb_sync: isp_scan_loop failed");
3013 return (-1);
3014 }
3015 }
2994 if (fcp->isp_loopstate > LOOP_SYNCING_PDB) {
2995 return (0);
3016 }
3017
2996 }
2997
3018 if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) {
3019 if (fcp->isp_loopstate < LOOP_FSCAN_DONE) {
3020 if (isp_scan_fabric(isp, chan) != 0) {
3021 isp_prt(isp, ISP_LOGWARN,
3022 "isp_pdb_sync: isp_scan_fabric failed");
3023 return (-1);
3024 }
3025 }
3026 }
2998 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC PDB sync", chan);
3027
2999
3028 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Synchronizing PDBs", chan);
3029
3030 fcp->isp_loopstate = LOOP_SYNCING_PDB;
3031
3032 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3033 lp = &fcp->portdb[dbidx];
3034
3035 if (lp->state == FC_PORTDB_STATE_NIL ||
3036 lp->state == FC_PORTDB_STATE_VALID) {
3037 continue;

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

3096
3097 /*
3098 * If we get here, we've for sure seen not only a valid loop
3099 * but know what is or isn't on it, so mark this for usage
3100 * in isp_start.
3101 */
3102 fcp->loop_seen_once = 1;
3103 fcp->isp_loopstate = LOOP_READY;
3000 fcp->isp_loopstate = LOOP_SYNCING_PDB;
3001
3002 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3003 lp = &fcp->portdb[dbidx];
3004
3005 if (lp->state == FC_PORTDB_STATE_NIL ||
3006 lp->state == FC_PORTDB_STATE_VALID) {
3007 continue;

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

3066
3067 /*
3068 * If we get here, we've for sure seen not only a valid loop
3069 * but know what is or isn't on it, so mark this for usage
3070 * in isp_start.
3071 */
3072 fcp->loop_seen_once = 1;
3073 fcp->isp_loopstate = LOOP_READY;
3074 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC PDB sync done", chan);
3104 return (0);
3105}
3106
3107/*
3108 * Scan local loop for devices.
3109 */
3110static int
3111isp_scan_loop(ispsoftc_t *isp, int chan)
3112{
3113 fcportdb_t *lp, tmp;
3114 fcparam *fcp = FCPARAM(isp, chan);
3115 int i, idx, lim, r;
3116 isp_pdb_t pdb;
3117 uint16_t handles[LOCAL_LOOP_LIM];
3118 uint16_t handle;
3119
3075 return (0);
3076}
3077
3078/*
3079 * Scan local loop for devices.
3080 */
3081static int
3082isp_scan_loop(ispsoftc_t *isp, int chan)
3083{
3084 fcportdb_t *lp, tmp;
3085 fcparam *fcp = FCPARAM(isp, chan);
3086 int i, idx, lim, r;
3087 isp_pdb_t pdb;
3088 uint16_t handles[LOCAL_LOOP_LIM];
3089 uint16_t handle;
3090
3120 if (fcp->isp_fwstate < FW_READY ||
3121 fcp->isp_loopstate < LOOP_PDB_RCVD) {
3091 if (fcp->isp_loopstate < LOOP_LTEST_DONE) {
3122 return (-1);
3123 }
3124 if (fcp->isp_loopstate > LOOP_SCANNING_LOOP) {
3125 return (0);
3126 }
3092 return (-1);
3093 }
3094 if (fcp->isp_loopstate > LOOP_SCANNING_LOOP) {
3095 return (0);
3096 }
3097 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan", chan);
3127 if (fcp->isp_topo != TOPO_NL_PORT && fcp->isp_topo != TOPO_FL_PORT &&
3128 fcp->isp_topo != TOPO_N_PORT) {
3129 isp_prt(isp, ISP_LOG_SANCFG,
3098 if (fcp->isp_topo != TOPO_NL_PORT && fcp->isp_topo != TOPO_FL_PORT &&
3099 fcp->isp_topo != TOPO_N_PORT) {
3100 isp_prt(isp, ISP_LOG_SANCFG,
3130 "Chan %d no loop topology to scan", chan);
3101 "Chan %d FC loop scan done (no loop)", chan);
3131 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3132 return (0);
3133 }
3102 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3103 return (0);
3104 }
3134
3135 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
3136
3137 lim = LOCAL_LOOP_LIM;
3138 r = isp_gethandles(isp, chan, handles, &lim, 1, 1);
3139 if (r != 0) {
3140 isp_prt(isp, ISP_LOG_SANCFG,
3105 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
3106
3107 lim = LOCAL_LOOP_LIM;
3108 r = isp_gethandles(isp, chan, handles, &lim, 1, 1);
3109 if (r != 0) {
3110 isp_prt(isp, ISP_LOG_SANCFG,
3141 "Chan %d getting list of handles failed with %x", chan, r);
3111 "Chan %d Getting list of handles failed with %x", chan, r);
3142fail:
3112fail:
3143 ISP_MARK_PORTDB(isp, chan, 1);
3144 isp_prt(isp, ISP_LOG_SANCFG,
3113 isp_prt(isp, ISP_LOG_SANCFG,
3145 "Chan %d FC scan loop DONE (bad)", chan);
3114 "Chan %d FC loop scan done (bad)", chan);
3146 return (-1);
3147 }
3148
3115 return (-1);
3116 }
3117
3149 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop -- %d ports",
3118 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Got %d handles",
3150 chan, lim);
3151
3152 /*
3153 * Run through the list and get the port database info for each one.
3154 */
3155 for (idx = 0; idx < lim; idx++) {
3156 handle = handles[idx];
3157

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

3167 }
3168
3169 /*
3170 * In older cards with older f/w GET_PORT_DATABASE has been
3171 * known to hang. This trick gets around that problem.
3172 */
3173 if (IS_2100(isp) || IS_2200(isp)) {
3174 uint64_t node_wwn = isp_get_wwn(isp, chan, handle, 1);
3119 chan, lim);
3120
3121 /*
3122 * Run through the list and get the port database info for each one.
3123 */
3124 for (idx = 0; idx < lim; idx++) {
3125 handle = handles[idx];
3126

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

3136 }
3137
3138 /*
3139 * In older cards with older f/w GET_PORT_DATABASE has been
3140 * known to hang. This trick gets around that problem.
3141 */
3142 if (IS_2100(isp) || IS_2200(isp)) {
3143 uint64_t node_wwn = isp_get_wwn(isp, chan, handle, 1);
3175 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3176 goto fail;
3144 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3145abort:
3146 isp_prt(isp, ISP_LOG_SANCFG,
3147 "Chan %d FC loop scan done (abort)", chan);
3148 return (-1);
3149 }
3177 if (node_wwn == INI_NONE) {
3178 continue;
3179 }
3180 }
3181
3182 /*
3183 * Get the port database entity for this index.
3184 */
3185 r = isp_getpdb(isp, chan, handle, &pdb, 1);
3186 if (r != 0) {
3187 isp_prt(isp, ISP_LOGDEBUG1,
3150 if (node_wwn == INI_NONE) {
3151 continue;
3152 }
3153 }
3154
3155 /*
3156 * Get the port database entity for this index.
3157 */
3158 r = isp_getpdb(isp, chan, handle, &pdb, 1);
3159 if (r != 0) {
3160 isp_prt(isp, ISP_LOGDEBUG1,
3188 "Chan %d FC scan loop handle %d returned %x",
3161 "Chan %d FC Scan Loop handle %d returned %x",
3189 chan, handle, r);
3190 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3162 chan, handle, r);
3163 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3191 goto fail;
3164 goto abort;
3192 continue;
3193 }
3194
3195 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3165 continue;
3166 }
3167
3168 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3196 goto fail;
3169 goto abort;
3197
3198 /*
3199 * On *very* old 2100 firmware we would end up sometimes
3200 * with the firmware returning the port database entry
3201 * for something else. We used to restart this, but
3202 * now we just punt.
3203 */
3204 if (IS_2100(isp) && pdb.handle != handle) {

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

3274 /*
3275 * Check to make see if really still the same
3276 * device. If it is, we mark it pending valid.
3277 */
3278 if (lp->portid == tmp.portid && lp->handle == tmp.handle && lp->prli_word3 == tmp.prli_word3) {
3279 lp->new_portid = tmp.portid;
3280 lp->new_prli_word3 = tmp.prli_word3;
3281 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3170
3171 /*
3172 * On *very* old 2100 firmware we would end up sometimes
3173 * with the firmware returning the port database entry
3174 * for something else. We used to restart this, but
3175 * now we just punt.
3176 */
3177 if (IS_2100(isp) && pdb.handle != handle) {

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

3247 /*
3248 * Check to make see if really still the same
3249 * device. If it is, we mark it pending valid.
3250 */
3251 if (lp->portid == tmp.portid && lp->handle == tmp.handle && lp->prli_word3 == tmp.prli_word3) {
3252 lp->new_portid = tmp.portid;
3253 lp->new_prli_word3 = tmp.prli_word3;
3254 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3282 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x Pending Valid", chan, tmp.portid, tmp.handle);
3255 isp_prt(isp, ISP_LOG_SANCFG,
3256 "Chan %d Loop port 0x%06x@0x%04x now pending valid",
3257 chan, tmp.portid, tmp.handle);
3283 continue;
3284 }
3285
3286 /*
3287 * We can wipe out the old handle value
3288 * here because it's no longer valid.
3289 */
3290 lp->handle = tmp.handle;
3291
3292 /*
3293 * Claim that this has changed and let somebody else
3294 * decide what to do.
3295 */
3258 continue;
3259 }
3260
3261 /*
3262 * We can wipe out the old handle value
3263 * here because it's no longer valid.
3264 */
3265 lp->handle = tmp.handle;
3266
3267 /*
3268 * Claim that this has changed and let somebody else
3269 * decide what to do.
3270 */
3296 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x changed", chan, tmp.portid, tmp.handle);
3271 isp_prt(isp, ISP_LOG_SANCFG,
3272 "Chan %d Loop port 0x%06x@0x%04x changed",
3273 chan, tmp.portid, tmp.handle);
3297 lp->state = FC_PORTDB_STATE_CHANGED;
3298 lp->new_portid = tmp.portid;
3299 lp->new_prli_word3 = tmp.prli_word3;
3300 continue;
3301 }
3302
3303 /*
3304 * Ah. A new device entry. Find an empty slot

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

3319 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3320 lp->autologin = 1;
3321 lp->state = FC_PORTDB_STATE_NEW;
3322 lp->new_portid = tmp.portid;
3323 lp->new_prli_word3 = tmp.prli_word3;
3324 lp->handle = tmp.handle;
3325 lp->port_wwn = tmp.port_wwn;
3326 lp->node_wwn = tmp.node_wwn;
3274 lp->state = FC_PORTDB_STATE_CHANGED;
3275 lp->new_portid = tmp.portid;
3276 lp->new_prli_word3 = tmp.prli_word3;
3277 continue;
3278 }
3279
3280 /*
3281 * Ah. A new device entry. Find an empty slot

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

3296 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3297 lp->autologin = 1;
3298 lp->state = FC_PORTDB_STATE_NEW;
3299 lp->new_portid = tmp.portid;
3300 lp->new_prli_word3 = tmp.prli_word3;
3301 lp->handle = tmp.handle;
3302 lp->port_wwn = tmp.port_wwn;
3303 lp->node_wwn = tmp.node_wwn;
3327 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Loop Port 0x%06x@0x%04x is New Entry", chan, tmp.portid, tmp.handle);
3304 isp_prt(isp, ISP_LOG_SANCFG,
3305 "Chan %d Loop port 0x%06x@0x%04x is a new entry",
3306 chan, tmp.portid, tmp.handle);
3328 }
3307 }
3308 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP)
3309 goto abort;
3329 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3310 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3330 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC scan loop DONE", chan);
3311 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC loop scan done", chan);
3331 return (0);
3332}
3333
3334/*
3335 * Scan the fabric for devices and add them to our port database.
3336 *
3337 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows.
3338 *

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

3508{
3509 fcparam *fcp = FCPARAM(isp, chan);
3510 uint32_t portid;
3511 uint16_t handle, loopid;
3512 isp_pdb_t pdb;
3513 int portidx, portlim, r;
3514 sns_gid_ft_rsp_t *rs0, *rs1;
3515
3312 return (0);
3313}
3314
3315/*
3316 * Scan the fabric for devices and add them to our port database.
3317 *
3318 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows.
3319 *

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

3489{
3490 fcparam *fcp = FCPARAM(isp, chan);
3491 uint32_t portid;
3492 uint16_t handle, loopid;
3493 isp_pdb_t pdb;
3494 int portidx, portlim, r;
3495 sns_gid_ft_rsp_t *rs0, *rs1;
3496
3516 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Scan Fabric", chan);
3517 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate < LOOP_LSCAN_DONE) {
3497 if (fcp->isp_loopstate < LOOP_LSCAN_DONE) {
3518 return (-1);
3519 }
3520 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) {
3521 return (0);
3522 }
3498 return (-1);
3499 }
3500 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) {
3501 return (0);
3502 }
3503 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC fabric scan", chan);
3523 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) {
3524 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3504 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) {
3505 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3525 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Scan Fabric Done (no fabric)", chan);
3506 isp_prt(isp, ISP_LOG_SANCFG,
3507 "Chan %d FC fabric scan done (no fabric)", chan);
3526 return (0);
3527 }
3508 return (0);
3509 }
3528
3529 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
3510 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
3511
3530 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
3531 isp_prt(isp, ISP_LOGERR, sacq);
3512 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
3513 isp_prt(isp, ISP_LOGERR, sacq);
3532 ISP_MARK_PORTDB(isp, chan, 1);
3514fail:
3515 isp_prt(isp, ISP_LOG_SANCFG,
3516 "Chan %d FC fabric scan done (bad)", chan);
3533 return (-1);
3534 }
3535 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3517 return (-1);
3518 }
3519 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3520abort:
3536 FC_SCRATCH_RELEASE(isp, chan);
3521 FC_SCRATCH_RELEASE(isp, chan);
3537 ISP_MARK_PORTDB(isp, chan, 1);
3522 isp_prt(isp, ISP_LOG_SANCFG,
3523 "Chan %d FC fabric scan done (abort)", chan);
3538 return (-1);
3539 }
3540
3541 /*
3542 * Make sure we still are logged into the fabric controller.
3543 */
3544 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE TRUE FOR 2K F/W? XXX */
3545 loopid = NPH_FL_ID;
3546 } else {
3547 loopid = FL_ID;
3548 }
3549 r = isp_getpdb(isp, chan, loopid, &pdb, 0);
3550 if ((r & 0xffff) == MBOX_NOT_LOGGED_IN) {
3551 isp_dump_chip_portdb(isp, chan, 0);
3552 }
3553 if (r) {
3524 return (-1);
3525 }
3526
3527 /*
3528 * Make sure we still are logged into the fabric controller.
3529 */
3530 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE TRUE FOR 2K F/W? XXX */
3531 loopid = NPH_FL_ID;
3532 } else {
3533 loopid = FL_ID;
3534 }
3535 r = isp_getpdb(isp, chan, loopid, &pdb, 0);
3536 if ((r & 0xffff) == MBOX_NOT_LOGGED_IN) {
3537 isp_dump_chip_portdb(isp, chan, 0);
3538 }
3539 if (r) {
3554 fcp->isp_loopstate = LOOP_PDB_RCVD;
3540 fcp->isp_loopstate = LOOP_LTEST_DONE;
3555 FC_SCRATCH_RELEASE(isp, chan);
3541 FC_SCRATCH_RELEASE(isp, chan);
3556 ISP_MARK_PORTDB(isp, chan, 1);
3557 return (-1);
3542 goto fail;
3558 }
3559
3560 if (IS_24XX(isp)) {
3561 r = isp_gid_ft_ct_passthru(isp, chan);
3562 } else {
3563 r = isp_gid_ft_sns(isp, chan);
3564 }
3565
3566 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3543 }
3544
3545 if (IS_24XX(isp)) {
3546 r = isp_gid_ft_ct_passthru(isp, chan);
3547 } else {
3548 r = isp_gid_ft_sns(isp, chan);
3549 }
3550
3551 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3567 FC_SCRATCH_RELEASE(isp, chan);
3568 ISP_MARK_PORTDB(isp, chan, 1);
3569 return (-1);
3552 goto abort;
3570 }
3571
3572 if (r > 0) {
3573 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3574 FC_SCRATCH_RELEASE(isp, chan);
3575 return (0);
3576 } else if (r < 0) {
3553 }
3554
3555 if (r > 0) {
3556 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3557 FC_SCRATCH_RELEASE(isp, chan);
3558 return (0);
3559 } else if (r < 0) {
3577 fcp->isp_loopstate = LOOP_PDB_RCVD; /* try again */
3560 fcp->isp_loopstate = LOOP_LTEST_DONE; /* try again */
3578 FC_SCRATCH_RELEASE(isp, chan);
3579 return (0);
3580 }
3581
3582 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN, chan);
3583 rs0 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+IGPOFF);
3584 rs1 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+OGPOFF);
3585 isp_get_gid_ft_response(isp, rs0, rs1, NGENT);
3586 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3561 FC_SCRATCH_RELEASE(isp, chan);
3562 return (0);
3563 }
3564
3565 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN, chan);
3566 rs0 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+IGPOFF);
3567 rs1 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+OGPOFF);
3568 isp_get_gid_ft_response(isp, rs0, rs1, NGENT);
3569 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3587 FC_SCRATCH_RELEASE(isp, chan);
3588 ISP_MARK_PORTDB(isp, chan, 1);
3589 return (-1);
3570 goto abort;
3590 }
3591 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) {
3592 int level;
3593 if (rs1->snscb_cthdr.ct_reason == 9 && rs1->snscb_cthdr.ct_explanation == 7) {
3594 level = ISP_LOG_SANCFG;
3595 } else {
3596 level = ISP_LOGWARN;
3597 }

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

3626 * If we're not at the last entry, our list wasn't big enough.
3627 */
3628 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) {
3629 isp_prt(isp, ISP_LOGWARN,
3630 "fabric too big for scratch area: increase ISP_FC_SCRLEN");
3631 }
3632 portlim = portidx + 1;
3633 isp_prt(isp, ISP_LOG_SANCFG,
3571 }
3572 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) {
3573 int level;
3574 if (rs1->snscb_cthdr.ct_reason == 9 && rs1->snscb_cthdr.ct_explanation == 7) {
3575 level = ISP_LOG_SANCFG;
3576 } else {
3577 level = ISP_LOGWARN;
3578 }

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

3607 * If we're not at the last entry, our list wasn't big enough.
3608 */
3609 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) {
3610 isp_prt(isp, ISP_LOGWARN,
3611 "fabric too big for scratch area: increase ISP_FC_SCRLEN");
3612 }
3613 portlim = portidx + 1;
3614 isp_prt(isp, ISP_LOG_SANCFG,
3634 "Chan %d got %d ports back from name server", chan, portlim);
3615 "Chan %d Got %d ports back from name server", chan, portlim);
3635
3636 for (portidx = 0; portidx < portlim; portidx++) {
3637 int npidx;
3638
3639 portid =
3640 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3641 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3642 ((rs1->snscb_ports[portidx].portid[2]));

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

3681
3682 portid =
3683 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3684 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3685 ((rs1->snscb_ports[portidx].portid[2]));
3686
3687 if (portid == 0) {
3688 isp_prt(isp, ISP_LOG_SANCFG,
3616
3617 for (portidx = 0; portidx < portlim; portidx++) {
3618 int npidx;
3619
3620 portid =
3621 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3622 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3623 ((rs1->snscb_ports[portidx].portid[2]));

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

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

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

3754 * reason it isn't, mark it as a changed device
3755 * and leave the new portid and role in the
3756 * database entry for somebody further along to
3757 * decide what to do (policy choice).
3758 *
3759 */
3760
3761 r = isp_getpdb(isp, chan, lp->handle, &pdb, 0);
3683
3684 /*
3685 * We now search our Port Database for any
3686 * probational entries with this PortID. We don't
3687 * look for zombies here- only probational
3688 * entries (we've already logged out of zombies).
3689 */
3690 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {

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

3719 * reason it isn't, mark it as a changed device
3720 * and leave the new portid and role in the
3721 * database entry for somebody further along to
3722 * decide what to do (policy choice).
3723 *
3724 */
3725
3726 r = isp_getpdb(isp, chan, lp->handle, &pdb, 0);
3762 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3763 FC_SCRATCH_RELEASE(isp, chan);
3764 ISP_MARK_PORTDB(isp, chan, 1);
3765 return (-1);
3727 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3728 goto abort;
3766 }
3767 if (r != 0) {
3768 lp->new_portid = portid;
3769 lp->state = FC_PORTDB_STATE_DEAD;
3770 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric PortID 0x%06x handle 0x%x is dead (%d)", chan, portid, lp->handle, r);
3771 continue;
3772 }
3773

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

3801 * portid consistency after re-login.
3802 *
3803 */
3804 if ((fcp->role & ISP_ROLE_INITIATOR) == 0 ||
3805 isp_login_device(isp, chan, portid, &pdb,
3806 &FCPARAM(isp, 0)->isp_lasthdl)) {
3807 lp->new_portid = portid;
3808 lp->state = FC_PORTDB_STATE_DEAD;
3729 }
3730 if (r != 0) {
3731 lp->new_portid = portid;
3732 lp->state = FC_PORTDB_STATE_DEAD;
3733 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric PortID 0x%06x handle 0x%x is dead (%d)", chan, portid, lp->handle, r);
3734 continue;
3735 }
3736

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

3764 * portid consistency after re-login.
3765 *
3766 */
3767 if ((fcp->role & ISP_ROLE_INITIATOR) == 0 ||
3768 isp_login_device(isp, chan, portid, &pdb,
3769 &FCPARAM(isp, 0)->isp_lasthdl)) {
3770 lp->new_portid = portid;
3771 lp->state = FC_PORTDB_STATE_DEAD;
3809 if (fcp->isp_loopstate !=
3772 if (fcp->isp_loopstate <
3810 LOOP_SCANNING_FABRIC) {
3773 LOOP_SCANNING_FABRIC) {
3811 FC_SCRATCH_RELEASE(isp, chan);
3812 ISP_MARK_PORTDB(isp, chan, 1);
3813 return (-1);
3774 goto abort;
3814 }
3815 continue;
3816 }
3775 }
3776 continue;
3777 }
3817 if (fcp->isp_loopstate !=
3818 LOOP_SCANNING_FABRIC) {
3819 FC_SCRATCH_RELEASE(isp, chan);
3820 ISP_MARK_PORTDB(isp, chan, 1);
3821 return (-1);
3778 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3779 goto abort;
3822 }
3823 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3824 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3825 if (wwpn != lp->port_wwn ||
3826 (lp->node_wwn != 0 && wwnn != lp->node_wwn)) {
3827 isp_prt(isp, ISP_LOGWARN, "changed WWN"
3828 " after relogin");
3829 lp->new_portid = portid;

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

3847 * If they aren't the same, mark the device as a
3848 * changed device and save the new port id and role
3849 * and let somebody else decide.
3850 */
3851
3852 lp->new_portid = portid;
3853 lp->new_prli_word3 = nr;
3854 if (pdb.portid != lp->portid || nr != lp->prli_word3 || handle_changed) {
3780 }
3781 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3782 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3783 if (wwpn != lp->port_wwn ||
3784 (lp->node_wwn != 0 && wwnn != lp->node_wwn)) {
3785 isp_prt(isp, ISP_LOGWARN, "changed WWN"
3786 " after relogin");
3787 lp->new_portid = portid;

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

3805 * If they aren't the same, mark the device as a
3806 * changed device and save the new port id and role
3807 * and let somebody else decide.
3808 */
3809
3810 lp->new_portid = portid;
3811 lp->new_prli_word3 = nr;
3812 if (pdb.portid != lp->portid || nr != lp->prli_word3 || handle_changed) {
3855 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x changed", chan, portid);
3813 isp_prt(isp, ISP_LOG_SANCFG,
3814 "Chan %d Fabric port 0x%06x changed",
3815 chan, portid);
3856 lp->state = FC_PORTDB_STATE_CHANGED;
3857 } else {
3816 lp->state = FC_PORTDB_STATE_CHANGED;
3817 } else {
3858 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x Now Pending Valid", chan, portid);
3818 isp_prt(isp, ISP_LOG_SANCFG,
3819 "Chan %d Fabric port 0x%06x now pending valid",
3820 chan, portid);
3859 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3860 }
3861 continue;
3862 }
3863
3864 if ((fcp->role & ISP_ROLE_INITIATOR) == 0)
3865 continue;
3866

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

3917 * Try to see if we are logged into this device,
3918 * and maybe log into it.
3919 *
3920 * isp_login_device will check for handle and
3921 * portid consistency after login.
3922 */
3923 if (isp_login_device(isp, chan, portid, &pdb,
3924 &FCPARAM(isp, 0)->isp_lasthdl)) {
3821 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3822 }
3823 continue;
3824 }
3825
3826 if ((fcp->role & ISP_ROLE_INITIATOR) == 0)
3827 continue;
3828

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

3879 * Try to see if we are logged into this device,
3880 * and maybe log into it.
3881 *
3882 * isp_login_device will check for handle and
3883 * portid consistency after login.
3884 */
3885 if (isp_login_device(isp, chan, portid, &pdb,
3886 &FCPARAM(isp, 0)->isp_lasthdl)) {
3925 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3926 FC_SCRATCH_RELEASE(isp, chan);
3927 ISP_MARK_PORTDB(isp, chan, 1);
3928 return (-1);
3887 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3888 goto abort;
3929 }
3930 continue;
3931 }
3889 }
3890 continue;
3891 }
3932 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3933 FC_SCRATCH_RELEASE(isp, chan);
3934 ISP_MARK_PORTDB(isp, chan, 1);
3935 return (-1);
3892 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3893 goto abort;
3936 }
3937
3938 handle = pdb.handle;
3939 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3940 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3941 nr = pdb.prli_word3;
3942
3943 /*

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

3959 if (dbidx == MAX_FC_TARG) {
3960 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3961 lp->handle = handle;
3962 lp->node_wwn = wwnn;
3963 lp->port_wwn = wwpn;
3964 lp->new_portid = portid;
3965 lp->new_prli_word3 = nr;
3966 lp->state = FC_PORTDB_STATE_NEW;
3894 }
3895
3896 handle = pdb.handle;
3897 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3898 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3899 nr = pdb.prli_word3;
3900
3901 /*

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

3917 if (dbidx == MAX_FC_TARG) {
3918 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3919 lp->handle = handle;
3920 lp->node_wwn = wwnn;
3921 lp->port_wwn = wwpn;
3922 lp->new_portid = portid;
3923 lp->new_prli_word3 = nr;
3924 lp->state = FC_PORTDB_STATE_NEW;
3967 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric Port 0x%06x is a New Entry", chan, portid);
3925 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Fabric port 0x%06x is a new entry", chan, portid);
3968 continue;
3969 }
3970
3971 if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) {
3972 isp_prt(isp, ISP_LOGWARN,
3973 "Chan %d PortID 0x%x 0x%08x%08x/0x%08x%08x %ld "
3974 "already at idx %d, state 0x%x", chan, portid,
3975 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,

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

3988 * are different, it maybe a changed device.
3989 */
3990 lp = &fcp->portdb[dbidx];
3991 lp->handle = handle;
3992 lp->node_wwn = wwnn;
3993 lp->new_portid = portid;
3994 lp->new_prli_word3 = nr;
3995 if (lp->portid != portid || lp->prli_word3 != nr) {
3926 continue;
3927 }
3928
3929 if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) {
3930 isp_prt(isp, ISP_LOGWARN,
3931 "Chan %d PortID 0x%x 0x%08x%08x/0x%08x%08x %ld "
3932 "already at idx %d, state 0x%x", chan, portid,
3933 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,

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

3946 * are different, it maybe a changed device.
3947 */
3948 lp = &fcp->portdb[dbidx];
3949 lp->handle = handle;
3950 lp->node_wwn = wwnn;
3951 lp->new_portid = portid;
3952 lp->new_prli_word3 = nr;
3953 if (lp->portid != portid || lp->prli_word3 != nr) {
3996 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Changed", chan, portid);
3954 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie fabric port 0x%06x now changed", chan, portid);
3997 lp->state = FC_PORTDB_STATE_CHANGED;
3998 } else {
3955 lp->state = FC_PORTDB_STATE_CHANGED;
3956 } else {
3999 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie Fabric Port 0x%06x Now Pending Valid", chan, portid);
3957 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d Zombie fabric port 0x%06x now pending valid", chan, portid);
4000 lp->state = FC_PORTDB_STATE_PENDING_VALID;
4001 }
4002 }
4003
3958 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3959 }
3960 }
3961
4004 FC_SCRATCH_RELEASE(isp, chan);
4005 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
4006 ISP_MARK_PORTDB(isp, chan, 1);
4007 return (-1);
3962 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3963 goto abort;
4008 }
3964 }
3965 FC_SCRATCH_RELEASE(isp, chan);
4009 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3966 fcp->isp_loopstate = LOOP_FSCAN_DONE;
4010 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC Scan Fabric Done", chan);
3967 isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC fabric scan done", chan);
4011 return (0);
4012}
4013
4014/*
4015 * Find an unused handle and try and use to login to a port.
4016 */
4017static int
4018isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)

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

4354 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
4355 XS_SETERR(xs, HBA_BOTCH);
4356 return (CMD_COMPLETE);
4357 }
4358
4359 /*
4360 * Try again later.
4361 */
3968 return (0);
3969}
3970
3971/*
3972 * Find an unused handle and try and use to login to a port.
3973 */
3974static int
3975isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)

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

4311 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
4312 XS_SETERR(xs, HBA_BOTCH);
4313 return (CMD_COMPLETE);
4314 }
4315
4316 /*
4317 * Try again later.
4318 */
4362 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {
4319 if (fcp->isp_loopstate != LOOP_READY) {
4363 return (CMD_RQLATER);
4364 }
4365
4366 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d", target);
4367 lp = &fcp->portdb[target];
4368 if (target < 0 || target >= MAX_FC_TARG ||
4369 lp->is_target == 0) {
4370 XS_SETERR(xs, HBA_SELTIMEOUT);

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

5845 }
5846 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
5847
5848 switch (mbox) {
5849 case ASYNC_SYSTEM_ERROR:
5850 isp->isp_dead = 1;
5851 isp->isp_state = ISP_CRASHED;
5852 FCPARAM(isp, chan)->isp_loopstate = LOOP_NIL;
4320 return (CMD_RQLATER);
4321 }
4322
4323 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d", target);
4324 lp = &fcp->portdb[target];
4325 if (target < 0 || target >= MAX_FC_TARG ||
4326 lp->is_target == 0) {
4327 XS_SETERR(xs, HBA_SELTIMEOUT);

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

5802 }
5803 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
5804
5805 switch (mbox) {
5806 case ASYNC_SYSTEM_ERROR:
5807 isp->isp_dead = 1;
5808 isp->isp_state = ISP_CRASHED;
5809 FCPARAM(isp, chan)->isp_loopstate = LOOP_NIL;
5853 FCPARAM(isp, chan)->isp_fwstate = FW_CONFIG_WAIT;
5810 isp_change_fw_state(isp, chan, FW_CONFIG_WAIT);
5854 /*
5855 * Were we waiting for a mailbox command to complete?
5856 * If so, it's dead, so wake up the waiter.
5857 */
5858 if (isp->isp_mboxbsy) {
5859 isp->isp_obits = 1;
5860 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
5861 MBOX_NOTIFY_COMPLETE(isp);

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

5918 for (chan = 0; chan < isp->isp_nchan; chan++) {
5919 fcparam *fcp = FCPARAM(isp, chan);
5920 int topo = fcp->isp_topo;
5921
5922 if (fcp->role == ISP_ROLE_NONE) {
5923 continue;
5924 }
5925
5811 /*
5812 * Were we waiting for a mailbox command to complete?
5813 * If so, it's dead, so wake up the waiter.
5814 */
5815 if (isp->isp_mboxbsy) {
5816 isp->isp_obits = 1;
5817 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
5818 MBOX_NOTIFY_COMPLETE(isp);

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

5875 for (chan = 0; chan < isp->isp_nchan; chan++) {
5876 fcparam *fcp = FCPARAM(isp, chan);
5877 int topo = fcp->isp_topo;
5878
5879 if (fcp->role == ISP_ROLE_NONE) {
5880 continue;
5881 }
5882
5926 fcp->isp_fwstate = FW_CONFIG_WAIT;
5927 fcp->isp_loopstate = LOOP_LIP_RCVD;
5883 fcp->isp_loopstate = LOOP_NIL;
5928 ISP_SET_SENDMARKER(isp, chan, 1);
5884 ISP_SET_SENDMARKER(isp, chan, 1);
5929 ISP_MARK_PORTDB(isp, chan, 1);
5930 isp_async(isp, ISPASYNC_LIP, chan);
5931#ifdef ISP_TARGET_MODE
5932 if (isp_target_async(isp, chan, mbox)) {
5933 acked = 1;
5934 }
5935#endif
5936 /*
5937 * We've had problems with data corruption occuring on

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

5977 for (chan = 0; chan < isp->isp_nchan; chan++) {
5978 fcparam *fcp = FCPARAM(isp, chan);
5979
5980 if (fcp->role == ISP_ROLE_NONE) {
5981 continue;
5982 }
5983
5984 ISP_SET_SENDMARKER(isp, chan, 1);
5885 isp_async(isp, ISPASYNC_LIP, chan);
5886#ifdef ISP_TARGET_MODE
5887 if (isp_target_async(isp, chan, mbox)) {
5888 acked = 1;
5889 }
5890#endif
5891 /*
5892 * We've had problems with data corruption occuring on

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

5932 for (chan = 0; chan < isp->isp_nchan; chan++) {
5933 fcparam *fcp = FCPARAM(isp, chan);
5934
5935 if (fcp->role == ISP_ROLE_NONE) {
5936 continue;
5937 }
5938
5939 ISP_SET_SENDMARKER(isp, chan, 1);
5985
5986 fcp->isp_fwstate = FW_CONFIG_WAIT;
5987 fcp->isp_loopstate = LOOP_LIP_RCVD;
5988 ISP_MARK_PORTDB(isp, chan, 1);
5989 isp_async(isp, ISPASYNC_LOOP_UP, chan);
5990#ifdef ISP_TARGET_MODE
5991 if (isp_target_async(isp, chan, mbox)) {
5992 acked = 1;
5993 }
5994#endif
5995 }
5996 break;

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

6003 for (chan = 0; chan < isp->isp_nchan; chan++) {
6004 fcparam *fcp = FCPARAM(isp, chan);
6005
6006 if (fcp->role == ISP_ROLE_NONE) {
6007 continue;
6008 }
6009
6010 ISP_SET_SENDMARKER(isp, chan, 1);
5940 isp_async(isp, ISPASYNC_LOOP_UP, chan);
5941#ifdef ISP_TARGET_MODE
5942 if (isp_target_async(isp, chan, mbox)) {
5943 acked = 1;
5944 }
5945#endif
5946 }
5947 break;

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

5954 for (chan = 0; chan < isp->isp_nchan; chan++) {
5955 fcparam *fcp = FCPARAM(isp, chan);
5956
5957 if (fcp->role == ISP_ROLE_NONE) {
5958 continue;
5959 }
5960
5961 ISP_SET_SENDMARKER(isp, chan, 1);
6011 fcp->isp_fwstate = FW_CONFIG_WAIT;
6012 fcp->isp_loopstate = LOOP_NIL;
5962 fcp->isp_loopstate = LOOP_NIL;
6013 ISP_MARK_PORTDB(isp, chan, 1);
6014 isp_async(isp, ISPASYNC_LOOP_DOWN, chan);
5963 isp_async(isp, ISPASYNC_LOOP_DOWN, chan);
5964
6015#ifdef ISP_TARGET_MODE
6016 if (isp_target_async(isp, chan, mbox)) {
6017 acked = 1;
6018 }
6019#endif
6020 }
6021 break;
6022

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

6028 for (chan = 0; chan < isp->isp_nchan; chan++) {
6029 fcparam *fcp = FCPARAM(isp, chan);
6030
6031 if (fcp->role == ISP_ROLE_NONE) {
6032 continue;
6033 }
6034
6035 ISP_SET_SENDMARKER(isp, chan, 1);
5965#ifdef ISP_TARGET_MODE
5966 if (isp_target_async(isp, chan, mbox)) {
5967 acked = 1;
5968 }
5969#endif
5970 }
5971 break;
5972

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

5978 for (chan = 0; chan < isp->isp_nchan; chan++) {
5979 fcparam *fcp = FCPARAM(isp, chan);
5980
5981 if (fcp->role == ISP_ROLE_NONE) {
5982 continue;
5983 }
5984
5985 ISP_SET_SENDMARKER(isp, chan, 1);
6036 fcp->isp_fwstate = FW_CONFIG_WAIT;
6037 fcp->isp_loopstate = LOOP_NIL;
5986 fcp->isp_loopstate = LOOP_NIL;
6038 ISP_MARK_PORTDB(isp, chan, 1);
6039 isp_async(isp, ISPASYNC_LOOP_RESET, chan);
6040#ifdef ISP_TARGET_MODE
6041 if (isp_target_async(isp, chan, mbox)) {
6042 acked = 1;
6043 }
6044#endif
6045 }
6046 break;

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

6062 chan = echan = 0;
6063 }
6064 for (; chan <= echan; chan++) {
6065 fcparam *fcp = FCPARAM(isp, chan);
6066
6067 if (fcp->role == ISP_ROLE_NONE) {
6068 continue;
6069 }
5987 isp_async(isp, ISPASYNC_LOOP_RESET, chan);
5988#ifdef ISP_TARGET_MODE
5989 if (isp_target_async(isp, chan, mbox)) {
5990 acked = 1;
5991 }
5992#endif
5993 }
5994 break;

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

6010 chan = echan = 0;
6011 }
6012 for (; chan <= echan; chan++) {
6013 fcparam *fcp = FCPARAM(isp, chan);
6014
6015 if (fcp->role == ISP_ROLE_NONE) {
6016 continue;
6017 }
6070 ISP_SET_SENDMARKER(isp, chan, 1);
6071 fcp->isp_loopstate = LOOP_PDB_RCVD;
6072 ISP_MARK_PORTDB(isp, chan, 1);
6018 if (fcp->isp_loopstate > LOOP_LTEST_DONE)
6019 fcp->isp_loopstate = LOOP_LTEST_DONE;
6073 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan, ISPASYNC_CHANGE_PDB, nphdl, nlstate, reason);
6074 }
6075 break;
6076 }
6077 case ASYNC_CHANGE_NOTIFY:
6078 {
6079 int lochan, hichan;
6080

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

6088 }
6089 for (chan = lochan; chan < hichan; chan++) {
6090 fcparam *fcp = FCPARAM(isp, chan);
6091
6092 if (fcp->role == ISP_ROLE_NONE) {
6093 continue;
6094 }
6095
6020 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan, ISPASYNC_CHANGE_PDB, nphdl, nlstate, reason);
6021 }
6022 break;
6023 }
6024 case ASYNC_CHANGE_NOTIFY:
6025 {
6026 int lochan, hichan;
6027

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

6035 }
6036 for (chan = lochan; chan < hichan; chan++) {
6037 fcparam *fcp = FCPARAM(isp, chan);
6038
6039 if (fcp->role == ISP_ROLE_NONE) {
6040 continue;
6041 }
6042
6096 if (fcp->isp_topo == TOPO_F_PORT) {
6043 if (fcp->isp_loopstate > LOOP_LSCAN_DONE)
6097 fcp->isp_loopstate = LOOP_LSCAN_DONE;
6044 fcp->isp_loopstate = LOOP_LSCAN_DONE;
6098 } else {
6099 fcp->isp_loopstate = LOOP_PDB_RCVD;
6100 }
6101 ISP_MARK_PORTDB(isp, chan, 1);
6102 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan, ISPASYNC_CHANGE_SNS);
6103 }
6104 break;
6105 }
6106
6107 case ASYNC_CONNMODE:
6108 /*
6109 * This only applies to 2100 amd 2200 cards
6110 */
6111 if (!IS_2200(isp) && !IS_2100(isp)) {
6112 isp_prt(isp, ISP_LOGWARN, "bad card for ASYNC_CONNMODE event");
6113 break;
6114 }
6115 chan = 0;
6116 mbox = ISP_READ(isp, OUTMAILBOX1);
6045 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan, ISPASYNC_CHANGE_SNS);
6046 }
6047 break;
6048 }
6049
6050 case ASYNC_CONNMODE:
6051 /*
6052 * This only applies to 2100 amd 2200 cards
6053 */
6054 if (!IS_2200(isp) && !IS_2100(isp)) {
6055 isp_prt(isp, ISP_LOGWARN, "bad card for ASYNC_CONNMODE event");
6056 break;
6057 }
6058 chan = 0;
6059 mbox = ISP_READ(isp, OUTMAILBOX1);
6117 ISP_MARK_PORTDB(isp, chan, 1);
6118 switch (mbox) {
6119 case ISP_CONN_LOOP:
6120 isp_prt(isp, ISP_LOGINFO,
6121 "Point-to-Point -> Loop mode");
6122 break;
6123 case ISP_CONN_PTP:
6124 isp_prt(isp, ISP_LOGINFO,
6125 "Loop -> Point-to-Point mode");

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

6138 isp_prt(isp, ISP_LOGWARN,
6139 "Looped Back in Point-to-Point mode");
6140 break;
6141 default:
6142 isp_prt(isp, ISP_LOGWARN,
6143 "Unknown connection mode (0x%x)", mbox);
6144 break;
6145 }
6060 switch (mbox) {
6061 case ISP_CONN_LOOP:
6062 isp_prt(isp, ISP_LOGINFO,
6063 "Point-to-Point -> Loop mode");
6064 break;
6065 case ISP_CONN_PTP:
6066 isp_prt(isp, ISP_LOGINFO,
6067 "Loop -> Point-to-Point mode");

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

6080 isp_prt(isp, ISP_LOGWARN,
6081 "Looped Back in Point-to-Point mode");
6082 break;
6083 default:
6084 isp_prt(isp, ISP_LOGWARN,
6085 "Unknown connection mode (0x%x)", mbox);
6086 break;
6087 }
6088 ISP_SET_SENDMARKER(isp, chan, 1);
6089 FCPARAM(isp, chan)->isp_loopstate = LOOP_NIL;
6146 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan, ISPASYNC_CHANGE_OTHER);
6090 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan, ISPASYNC_CHANGE_OTHER);
6147 FCPARAM(isp, chan)->sendmarker = 1;
6148 FCPARAM(isp, chan)->isp_fwstate = FW_CONFIG_WAIT;
6149 FCPARAM(isp, chan)->isp_loopstate = LOOP_LIP_RCVD;
6150 break;
6151
6152 case ASYNC_RCV_ERR:
6153 if (IS_24XX(isp)) {
6154 isp_prt(isp, ISP_LOGWARN, "Receive Error");
6155 } else {
6156 isp_prt(isp, ISP_LOGWARN, "unexpected ASYNC_RCV_ERR");
6157 }

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

7552 break;
7553 }
7554 if (xname) {
7555 isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s%s)",
7556 cname, xname, sname);
7557 }
7558}
7559
6091 break;
6092
6093 case ASYNC_RCV_ERR:
6094 if (IS_24XX(isp)) {
6095 isp_prt(isp, ISP_LOGWARN, "Receive Error");
6096 } else {
6097 isp_prt(isp, ISP_LOGWARN, "unexpected ASYNC_RCV_ERR");
6098 }

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

7493 break;
7494 }
7495 if (xname) {
7496 isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s%s)",
7497 cname, xname, sname);
7498 }
7499}
7500
7560static void
7501static int
7561isp_fw_state(ispsoftc_t *isp, int chan)
7562{
7563 if (IS_FC(isp)) {
7564 mbreg_t mbs;
7502isp_fw_state(ispsoftc_t *isp, int chan)
7503{
7504 if (IS_FC(isp)) {
7505 mbreg_t mbs;
7565 fcparam *fcp = FCPARAM(isp, chan);
7566
7567 MBSINIT(&mbs, MBOX_GET_FW_STATE, MBLOGALL, 0);
7568 isp_mboxcmd(isp, &mbs);
7569 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
7506
7507 MBSINIT(&mbs, MBOX_GET_FW_STATE, MBLOGALL, 0);
7508 isp_mboxcmd(isp, &mbs);
7509 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
7570 fcp->isp_fwstate = mbs.param[1];
7510 return (mbs.param[1]);
7571 }
7572 }
7511 }
7512 }
7513 return (FW_ERROR);
7573}
7574
7575static void
7576isp_spi_update(ispsoftc_t *isp, int chan)
7577{
7578 int tgt;
7579 mbreg_t mbs;
7580 sdparam *sdp;

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

7934 }
7935 }
7936
7937 cleanup:
7938 isp->isp_nactive = 0;
7939 isp_clear_commands(isp);
7940 if (IS_FC(isp)) {
7941 for (i = 0; i < isp->isp_nchan; i++)
7514}
7515
7516static void
7517isp_spi_update(ispsoftc_t *isp, int chan)
7518{
7519 int tgt;
7520 mbreg_t mbs;
7521 sdparam *sdp;

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

7875 }
7876 }
7877
7878 cleanup:
7879 isp->isp_nactive = 0;
7880 isp_clear_commands(isp);
7881 if (IS_FC(isp)) {
7882 for (i = 0; i < isp->isp_nchan; i++)
7942 ISP_MARK_PORTDB(isp, i, -1);
7883 isp_mark_portdb(isp, i, -1);
7943 }
7944 return (res);
7945}
7946
7947/*
7948 * NVRAM Routines
7949 */
7950static int

--- 603 unchanged lines hidden ---
7884 }
7885 return (res);
7886}
7887
7888/*
7889 * NVRAM Routines
7890 */
7891static int

--- 603 unchanged lines hidden ---