Deleted Added
full compact
isp.c (186140) isp.c (196008)
1/*-
1/*-
2 * Copyright (c) 1997-2007 by Matthew Jacob
2 * Copyright (c) 1997-2009 by Matthew Jacob
3 * All rights reserved.
3 * All rights reserved.
4 *
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:
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 *
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
14 *
15 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
15 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
26 */
27
28/*
29 * Machine and OS Independent (well, as best as possible)
30 * code for the Qlogic ISP SCSI and FC-SCSI adapters.
31 */
32
33/*

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

41 */
42#ifdef __NetBSD__
43#include <sys/cdefs.h>
44__KERNEL_RCSID(0, "$NetBSD$");
45#include <dev/ic/isp_netbsd.h>
46#endif
47#ifdef __FreeBSD__
48#include <sys/cdefs.h>
27 */
28
29/*
30 * Machine and OS Independent (well, as best as possible)
31 * code for the Qlogic ISP SCSI and FC-SCSI adapters.
32 */
33
34/*

--- 7 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>
49__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 186140 2008-12-15 21:42:38Z marius $");
50__FBSDID("$FreeBSD: head/sys/dev/isp/isp.c 196008 2009-08-01 01:04:26Z mjacob $");
50#include <dev/isp/isp_freebsd.h>
51#endif
52#ifdef __OpenBSD__
53#include <dev/ic/isp_openbsd.h>
54#endif
55#ifdef __linux__
56#include "isp_linux.h"
57#endif
58#ifdef __svr4__
59#include "isp_solaris.h"
60#endif
61
62/*
63 * General defines
64 */
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
67#define MBOX_DELAY_COUNT 1000000 / 100
67#define ISP_MARK_PORTDB(a, b) \
68 isp_prt(isp, ISP_LOGSANCFG, "line %d: markportdb", __LINE__); \
69 isp_mark_portdb(a, b)
68#define ISP_MARK_PORTDB(a, b, c) \
69 isp_prt(isp, ISP_LOGSANCFG, \
70 "Chan %d ISP_MARK_PORTDB@LINE %d", b, __LINE__); \
71 isp_mark_portdb(a, b, c)
70
71/*
72 * Local static data
73 */
72
73/*
74 * Local static data
75 */
74static const char fconf[] =
75 "PortDB[%d] changed:\n current =(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)\n"
76 " database=(0x%x@0x%06x 0x%08x%08x 0x%08x%08x)";
77static const char notresp[] =
78 "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
79static const char xact1[] =
80 "HBA attempted queued transaction with disconnect not set for %d.%d.%d";
81static const char xact2[] =
82 "HBA attempted queued transaction to target routine %d on target %d bus %d";
83static const char xact3[] =
84 "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
85static const char pskip[] =
86 "SCSI phase skipped for target %d.%d.%d";
87static const char topology[] =
88 "HBA PortID 0x%06x N-Port Handle %d, Connection Topology '%s'";
89static const char ourwwn[] =
90 "HBA WWNN 0x%08x%08x HBA WWPN 0x%08x%08x";
91static const char finmsg[] =
92 "%d.%d.%d: FIN dl%d resid %d STS 0x%x SKEY %c XS_ERR=0x%x";
93static const char sc0[] =
94 "%s CHAN %d FTHRSH %d IID %d RESETD %d RETRYC %d RETRYD %d ASD 0x%x";
95static const char sc1[] =
96 "%s RAAN 0x%x DLAN 0x%x DDMAB 0x%x CDMAB 0x%x SELTIME %d MQD %d";
97static const char sc2[] = "%s CHAN %d TGT %d FLAGS 0x%x 0x%x/0x%x";
98static const char sc3[] = "Generated";
76static 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)";
77static const char notresp[] = "Not RESPONSE in RESPONSE Queue (type 0x%x) @ idx %d (next %d) nlooked %d";
78static const char xact1[] = "HBA attempted queued transaction with disconnect not set for %d.%d.%d";
79static const char xact2[] = "HBA attempted queued transaction to target routine %d on target %d bus %d";
80static const char xact3[] = "HBA attempted queued cmd for %d.%d.%d when queueing disabled";
81static const char pskip[] = "SCSI phase skipped for target %d.%d.%d";
82static const char topology[] = "Chan %d WWPN 0x%08x%08x PortID 0x%06x N-Port Handle %d, Connection '%s'";
83static const char finmsg[] = "%d.%d.%d: FIN dl%d resid %ld STS 0x%x SKEY %c XS_ERR=0x%x";
99static const char sc4[] = "NVRAM";
84static const char sc4[] = "NVRAM";
100static const char bun[] =
101 "bad underrun for %d.%d (count %d, resid %d, status %s)";
85static const char bun[] = "bad underrun for %d.%d (count %d, resid %d, status %s)";
86static const char lipd[] = "Chan %d LIP destroyed %d active commands";
87static const char sacq[] = "unable to acquire scratch area";
102
88
89static const uint8_t alpa_map[] = {
90 0xef, 0xe8, 0xe4, 0xe2, 0xe1, 0xe0, 0xdc, 0xda,
91 0xd9, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xce,
92 0xcd, 0xcc, 0xcb, 0xca, 0xc9, 0xc7, 0xc6, 0xc5,
93 0xc3, 0xbc, 0xba, 0xb9, 0xb6, 0xb5, 0xb4, 0xb3,
94 0xb2, 0xb1, 0xae, 0xad, 0xac, 0xab, 0xaa, 0xa9,
95 0xa7, 0xa6, 0xa5, 0xa3, 0x9f, 0x9e, 0x9d, 0x9b,
96 0x98, 0x97, 0x90, 0x8f, 0x88, 0x84, 0x82, 0x81,
97 0x80, 0x7c, 0x7a, 0x79, 0x76, 0x75, 0x74, 0x73,
98 0x72, 0x71, 0x6e, 0x6d, 0x6c, 0x6b, 0x6a, 0x69,
99 0x67, 0x66, 0x65, 0x63, 0x5c, 0x5a, 0x59, 0x56,
100 0x55, 0x54, 0x53, 0x52, 0x51, 0x4e, 0x4d, 0x4c,
101 0x4b, 0x4a, 0x49, 0x47, 0x46, 0x45, 0x43, 0x3c,
102 0x3a, 0x39, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31,
103 0x2e, 0x2d, 0x2c, 0x2b, 0x2a, 0x29, 0x27, 0x26,
104 0x25, 0x23, 0x1f, 0x1e, 0x1d, 0x1b, 0x18, 0x17,
105 0x10, 0x0f, 0x08, 0x04, 0x02, 0x01, 0x00
106};
107
103/*
104 * Local function prototypes.
105 */
106static int isp_parse_async(ispsoftc_t *, uint16_t);
108/*
109 * Local function prototypes.
110 */
111static int isp_parse_async(ispsoftc_t *, uint16_t);
107static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *,
108 uint32_t *);
109static void
110isp_parse_status(ispsoftc_t *, ispstatusreq_t *, XS_T *, long *);
111static void
112static int isp_handle_other_response(ispsoftc_t *, int, isphdr_t *, uint32_t *);
113static void isp_parse_status(ispsoftc_t *, ispstatusreq_t *, XS_T *, long *); static void
112isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, long *);
113static void isp_fastpost_complete(ispsoftc_t *, uint16_t);
114static int isp_mbox_continue(ispsoftc_t *);
115static void isp_scsi_init(ispsoftc_t *);
116static void isp_scsi_channel_init(ispsoftc_t *, int);
117static void isp_fibre_init(ispsoftc_t *);
118static void isp_fibre_init_2400(ispsoftc_t *);
114isp_parse_status_24xx(ispsoftc_t *, isp24xx_statusreq_t *, XS_T *, long *);
115static void isp_fastpost_complete(ispsoftc_t *, uint16_t);
116static int isp_mbox_continue(ispsoftc_t *);
117static void isp_scsi_init(ispsoftc_t *);
118static void isp_scsi_channel_init(ispsoftc_t *, int);
119static void isp_fibre_init(ispsoftc_t *);
120static void isp_fibre_init_2400(ispsoftc_t *);
119static void isp_mark_portdb(ispsoftc_t *, int);
120static int isp_plogx(ispsoftc_t *, uint16_t, uint32_t, int, int);
121static void isp_mark_portdb(ispsoftc_t *, int, int);
122static int isp_plogx(ispsoftc_t *, int, uint16_t, uint32_t, int, int);
121static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t);
122static int isp_port_logout(ispsoftc_t *, uint16_t, uint32_t);
123static int isp_port_login(ispsoftc_t *, uint16_t, uint32_t);
124static int isp_port_logout(ispsoftc_t *, uint16_t, uint32_t);
123static int isp_getpdb(ispsoftc_t *, uint16_t, isp_pdb_t *, int);
124static uint64_t isp_get_portname(ispsoftc_t *, int, int);
125static int isp_fclink_test(ispsoftc_t *, int);
126static const char *ispfc_fw_statename(int);
127static int isp_pdb_sync(ispsoftc_t *);
128static int isp_scan_loop(ispsoftc_t *);
129static int isp_gid_ft_sns(ispsoftc_t *);
130static int isp_gid_ft_ct_passthru(ispsoftc_t *);
131static int isp_scan_fabric(ispsoftc_t *);
132static int isp_login_device(ispsoftc_t *, uint32_t, isp_pdb_t *, uint16_t *);
133static int isp_register_fc4_type(ispsoftc_t *);
134static int isp_register_fc4_type_24xx(ispsoftc_t *);
135static uint16_t isp_nxt_handle(ispsoftc_t *, uint16_t);
136static void isp_fw_state(ispsoftc_t *);
125static int isp_getpdb(ispsoftc_t *, int, uint16_t, isp_pdb_t *, int);
126static void isp_dump_chip_portdb(ispsoftc_t *, int, int);
127static uint64_t isp_get_wwn(ispsoftc_t *, int, int, int);
128static int isp_fclink_test(ispsoftc_t *, int, int);
129static int isp_pdb_sync(ispsoftc_t *, int);
130static int isp_scan_loop(ispsoftc_t *, int);
131static int isp_gid_ft_sns(ispsoftc_t *, int);
132static int isp_gid_ft_ct_passthru(ispsoftc_t *, int);
133static int isp_scan_fabric(ispsoftc_t *, int);
134static int isp_login_device(ispsoftc_t *, int, uint32_t, isp_pdb_t *, uint16_t *);
135static int isp_register_fc4_type(ispsoftc_t *, int);
136static int isp_register_fc4_type_24xx(ispsoftc_t *, int);
137static uint16_t isp_nxt_handle(ispsoftc_t *, int, uint16_t);
138static void isp_fw_state(ispsoftc_t *, int);
137static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
138static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
139
139static void isp_mboxcmd_qnw(ispsoftc_t *, mbreg_t *, int);
140static void isp_mboxcmd(ispsoftc_t *, mbreg_t *);
141
140static void isp_update(ispsoftc_t *);
141static void isp_update_bus(ispsoftc_t *, int);
142static void isp_setdfltparm(ispsoftc_t *, int);
143static void isp_setdfltfcparm(ispsoftc_t *);
144static int isp_read_nvram(ispsoftc_t *);
145static int isp_read_nvram_2400(ispsoftc_t *);
142static void isp_spi_update(ispsoftc_t *, int);
143static void isp_setdfltsdparm(ispsoftc_t *);
144static void isp_setdfltfcparm(ispsoftc_t *, int);
145static int isp_read_nvram(ispsoftc_t *, int);
146static int isp_read_nvram_2400(ispsoftc_t *, uint8_t *);
146static void isp_rdnvram_word(ispsoftc_t *, int, uint16_t *);
147static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *);
148static void isp_parse_nvram_1020(ispsoftc_t *, uint8_t *);
149static void isp_parse_nvram_1080(ispsoftc_t *, int, uint8_t *);
150static void isp_parse_nvram_12160(ispsoftc_t *, int, uint8_t *);
147static void isp_rdnvram_word(ispsoftc_t *, int, uint16_t *);
148static void isp_rd_2400_nvram(ispsoftc_t *, uint32_t, uint32_t *);
149static void isp_parse_nvram_1020(ispsoftc_t *, uint8_t *);
150static void isp_parse_nvram_1080(ispsoftc_t *, int, uint8_t *);
151static void isp_parse_nvram_12160(ispsoftc_t *, int, uint8_t *);
151static void isp_fix_nvram_wwns(ispsoftc_t *);
152static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *);
153static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
154
155/*
156 * Reset Hardware.
157 *
158 * Hit the chip over the head, download new f/w if available and set it running.
159 *
160 * Locking done elsewhere.
161 */
162
163void
152static void isp_parse_nvram_2100(ispsoftc_t *, uint8_t *);
153static void isp_parse_nvram_2400(ispsoftc_t *, uint8_t *);
154
155/*
156 * Reset Hardware.
157 *
158 * Hit the chip over the head, download new f/w if available and set it running.
159 *
160 * Locking done elsewhere.
161 */
162
163void
164isp_reset(ispsoftc_t *isp)
164isp_reset(ispsoftc_t *isp, int do_load_defaults)
165{
166 mbreg_t mbs;
167 uint32_t code_org, val;
168 int loops, i, dodnld = 1;
165{
166 mbreg_t mbs;
167 uint32_t code_org, val;
168 int loops, i, dodnld = 1;
169 static const char *btype = "????";
169 const char *btype = "????";
170 static const char dcrc[] = "Downloaded RISC Code Checksum Failure";
171
172 isp->isp_state = ISP_NILSTATE;
170 static const char dcrc[] = "Downloaded RISC Code Checksum Failure";
171
172 isp->isp_state = ISP_NILSTATE;
173 if (isp->isp_dead) {
174 isp_shutdown(isp);
175 ISP_DISABLE_INTS(isp);
176 return;
177 }
173
174 /*
175 * Basic types (SCSI, FibreChannel and PCI or SBus)
176 * have been set in the MD code. We figure out more
177 * here. Possibly more refined types based upon PCI
178 * identification. Chip revision has been gathered.
179 *
180 * After we've fired this chip up, zero out the conf1 register
181 * for SCSI adapters and do other settings for the 2100.
182 */
183
178
179 /*
180 * Basic types (SCSI, FibreChannel and PCI or SBus)
181 * have been set in the MD code. We figure out more
182 * here. Possibly more refined types based upon PCI
183 * identification. Chip revision has been gathered.
184 *
185 * After we've fired this chip up, zero out the conf1 register
186 * for SCSI adapters and do other settings for the 2100.
187 */
188
184 /*
185 * Get the current running firmware revision out of the
186 * chip before we hit it over the head (if this is our
187 * first time through). Note that we store this as the
188 * 'ROM' firmware revision- which it may not be. In any
189 * case, we don't really use this yet, but we may in
190 * the future.
191 */
192 if (isp->isp_touched == 0) {
193 /*
194 * First see whether or not we're sitting in the ISP PROM.
195 * If we've just been reset, we'll have the string "ISP "
196 * spread through outgoing mailbox registers 1-3. We do
197 * this for PCI cards because otherwise we really don't
198 * know what state the card is in and we could hang if
199 * we try this command otherwise.
200 *
201 * For SBus cards, we just do this because they almost
202 * certainly will be running firmware by now.
203 */
204 if (ISP_READ(isp, OUTMAILBOX1) != 0x4953 ||
205 ISP_READ(isp, OUTMAILBOX2) != 0x5020 ||
206 ISP_READ(isp, OUTMAILBOX3) != 0x2020) {
207 /*
208 * Just in case it was paused...
209 */
210 if (IS_24XX(isp)) {
211 ISP_WRITE(isp, BIU2400_HCCR,
212 HCCR_2400_CMD_RELEASE);
213 } else {
214 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
215 }
216 MEMZERO(&mbs, sizeof (mbs));
217 mbs.param[0] = MBOX_ABOUT_FIRMWARE;
218 mbs.logval = MBLOGNONE;
219 isp_mboxcmd(isp, &mbs);
220 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
221 isp->isp_romfw_rev[0] = mbs.param[1];
222 isp->isp_romfw_rev[1] = mbs.param[2];
223 isp->isp_romfw_rev[2] = mbs.param[3];
224 }
225 }
226 isp->isp_touched = 1;
227 }
228
229 ISP_DISABLE_INTS(isp);
230
231 /*
232 * Pick an initial maxcmds value which will be used
233 * to allocate xflist pointer space. It may be changed
234 * later by the firmware.
235 */
236 if (IS_24XX(isp)) {
237 isp->isp_maxcmds = 4096;
238 } else if (IS_2322(isp)) {
239 isp->isp_maxcmds = 2048;
240 } else if (IS_23XX(isp) || IS_2200(isp)) {
241 isp->isp_maxcmds = 1024;
242 } else {
243 isp->isp_maxcmds = 512;
244 }
245
246 /*
189 ISP_DISABLE_INTS(isp);
190
191 /*
192 * Pick an initial maxcmds value which will be used
193 * to allocate xflist pointer space. It may be changed
194 * later by the firmware.
195 */
196 if (IS_24XX(isp)) {
197 isp->isp_maxcmds = 4096;
198 } else if (IS_2322(isp)) {
199 isp->isp_maxcmds = 2048;
200 } else if (IS_23XX(isp) || IS_2200(isp)) {
201 isp->isp_maxcmds = 1024;
202 } else {
203 isp->isp_maxcmds = 512;
204 }
205
206 /*
247 * Set up DMA for the request and result queues.
207 * Set up DMA for the request and response queues.
248 *
249 * We do this now so we can use the request queue
208 *
209 * We do this now so we can use the request queue
250 * for a dma
210 * for dma to load firmware from.
251 */
252 if (ISP_MBOXDMASETUP(isp) != 0) {
253 isp_prt(isp, ISP_LOGERR, "Cannot setup DMA");
254 return;
255 }
256
211 */
212 if (ISP_MBOXDMASETUP(isp) != 0) {
213 isp_prt(isp, ISP_LOGERR, "Cannot setup DMA");
214 return;
215 }
216
257
258 /*
259 * Set up default request/response queue in-pointer/out-pointer
260 * register indices.
261 */
262 if (IS_24XX(isp)) {
263 isp->isp_rqstinrp = BIU2400_REQINP;
264 isp->isp_rqstoutrp = BIU2400_REQOUTP;
265 isp->isp_respinrp = BIU2400_RSPINP;
266 isp->isp_respoutrp = BIU2400_RSPOUTP;
217 /*
218 * Set up default request/response queue in-pointer/out-pointer
219 * register indices.
220 */
221 if (IS_24XX(isp)) {
222 isp->isp_rqstinrp = BIU2400_REQINP;
223 isp->isp_rqstoutrp = BIU2400_REQOUTP;
224 isp->isp_respinrp = BIU2400_RSPINP;
225 isp->isp_respoutrp = BIU2400_RSPOUTP;
267 isp->isp_atioinrp = BIU2400_ATIO_RSPINP;
268 isp->isp_atiooutrp = BIU2400_ATIO_REQINP;
269 } else if (IS_23XX(isp)) {
270 isp->isp_rqstinrp = BIU_REQINP;
271 isp->isp_rqstoutrp = BIU_REQOUTP;
272 isp->isp_respinrp = BIU_RSPINP;
273 isp->isp_respoutrp = BIU_RSPOUTP;
274 } else {
275 isp->isp_rqstinrp = INMAILBOX4;
276 isp->isp_rqstoutrp = OUTMAILBOX4;

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

305 btype = "2312";
306 break;
307 case ISP_HA_FC_2322:
308 btype = "2322";
309 break;
310 case ISP_HA_FC_2400:
311 btype = "2422";
312 break;
226 } else if (IS_23XX(isp)) {
227 isp->isp_rqstinrp = BIU_REQINP;
228 isp->isp_rqstoutrp = BIU_REQOUTP;
229 isp->isp_respinrp = BIU_RSPINP;
230 isp->isp_respoutrp = BIU_RSPOUTP;
231 } else {
232 isp->isp_rqstinrp = INMAILBOX4;
233 isp->isp_rqstoutrp = OUTMAILBOX4;

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

262 btype = "2312";
263 break;
264 case ISP_HA_FC_2322:
265 btype = "2322";
266 break;
267 case ISP_HA_FC_2400:
268 btype = "2422";
269 break;
270 case ISP_HA_FC_2500:
271 btype = "2532";
272 break;
313 default:
314 break;
315 }
316
317 if (!IS_24XX(isp)) {
318 /*
319 * While we're paused, reset the FPM module and FBM
320 * fifos.
321 */
322 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
323 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
324 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
325 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
326 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
327 }
328 } else if (IS_1240(isp)) {
273 default:
274 break;
275 }
276
277 if (!IS_24XX(isp)) {
278 /*
279 * While we're paused, reset the FPM module and FBM
280 * fifos.
281 */
282 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
283 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
284 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
285 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
286 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
287 }
288 } else if (IS_1240(isp)) {
329 sdparam *sdp = isp->isp_param;
289 sdparam *sdp;
290
330 btype = "1240";
331 isp->isp_clock = 60;
291 btype = "1240";
292 isp->isp_clock = 60;
293 sdp = SDPARAM(isp, 0);
332 sdp->isp_ultramode = 1;
294 sdp->isp_ultramode = 1;
333 sdp++;
295 sdp = SDPARAM(isp, 1);
334 sdp->isp_ultramode = 1;
335 /*
336 * XXX: Should probably do some bus sensing.
337 */
338 } else if (IS_ULTRA3(isp)) {
339 sdparam *sdp = isp->isp_param;
340
341 isp->isp_clock = 100;

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

350
351 if (IS_DUALBUS(isp)) {
352 sdp++;
353 sdp->isp_lvdmode = 1;
354 }
355 } else if (IS_ULTRA2(isp)) {
356 static const char m[] = "bus %d is in %s Mode";
357 uint16_t l;
296 sdp->isp_ultramode = 1;
297 /*
298 * XXX: Should probably do some bus sensing.
299 */
300 } else if (IS_ULTRA3(isp)) {
301 sdparam *sdp = isp->isp_param;
302
303 isp->isp_clock = 100;

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

312
313 if (IS_DUALBUS(isp)) {
314 sdp++;
315 sdp->isp_lvdmode = 1;
316 }
317 } else if (IS_ULTRA2(isp)) {
318 static const char m[] = "bus %d is in %s Mode";
319 uint16_t l;
358 sdparam *sdp = isp->isp_param;
320 sdparam *sdp = SDPARAM(isp, 0);
359
360 isp->isp_clock = 100;
361
362 if (IS_1280(isp))
363 btype = "1280";
364 else if (IS_1080(isp))
365 btype = "1080";
366 else

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

382 break;
383 default:
384 isp_prt(isp, ISP_LOGERR,
385 "unknown mode on bus %d (0x%x)", 0, l);
386 break;
387 }
388
389 if (IS_DUALBUS(isp)) {
321
322 isp->isp_clock = 100;
323
324 if (IS_1280(isp))
325 btype = "1280";
326 else if (IS_1080(isp))
327 btype = "1080";
328 else

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

344 break;
345 default:
346 isp_prt(isp, ISP_LOGERR,
347 "unknown mode on bus %d (0x%x)", 0, l);
348 break;
349 }
350
351 if (IS_DUALBUS(isp)) {
390 sdp++;
352 sdp = SDPARAM(isp, 1);
391 l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT);
392 l &= ISP1080_MODE_MASK;
353 l = ISP_READ(isp, SXP_PINS_DIFF|SXP_BANK1_SELECT);
354 l &= ISP1080_MODE_MASK;
393 switch(l) {
355 switch (l) {
394 case ISP1080_LVD_MODE:
395 sdp->isp_lvdmode = 1;
396 isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD");
397 break;
398 case ISP1080_HVD_MODE:
399 sdp->isp_diffmode = 1;
400 isp_prt(isp, ISP_LOGCONFIG,
401 m, 1, "Differential");

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

407 break;
408 default:
409 isp_prt(isp, ISP_LOGERR,
410 "unknown mode on bus %d (0x%x)", 1, l);
411 break;
412 }
413 }
414 } else {
356 case ISP1080_LVD_MODE:
357 sdp->isp_lvdmode = 1;
358 isp_prt(isp, ISP_LOGCONFIG, m, 1, "LVD");
359 break;
360 case ISP1080_HVD_MODE:
361 sdp->isp_diffmode = 1;
362 isp_prt(isp, ISP_LOGCONFIG,
363 m, 1, "Differential");

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

369 break;
370 default:
371 isp_prt(isp, ISP_LOGERR,
372 "unknown mode on bus %d (0x%x)", 1, l);
373 break;
374 }
375 }
376 } else {
415 sdparam *sdp = isp->isp_param;
377 sdparam *sdp = SDPARAM(isp, 0);
416 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK;
417 switch (i) {
418 default:
419 isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i);
420 /* FALLTHROUGH */
421 case 1:
422 btype = "1020";
423 isp->isp_type = ISP_HA_SCSI_1020;

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

504
505 /*
506 * Do MD specific pre initialization
507 */
508 ISP_RESET0(isp);
509
510 /*
511 * Hit the chip over the head with hammer,
378 i = ISP_READ(isp, BIU_CONF0) & BIU_CONF0_HW_MASK;
379 switch (i) {
380 default:
381 isp_prt(isp, ISP_LOGALL, "Unknown Chip Type 0x%x", i);
382 /* FALLTHROUGH */
383 case 1:
384 btype = "1020";
385 isp->isp_type = ISP_HA_SCSI_1020;

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

466
467 /*
468 * Do MD specific pre initialization
469 */
470 ISP_RESET0(isp);
471
472 /*
473 * Hit the chip over the head with hammer,
512 * and give the ISP a chance to recover.
474 * and give it a chance to recover.
513 */
514
515 if (IS_SCSI(isp)) {
516 ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET);
517 /*
518 * A slight delay...
519 */
475 */
476
477 if (IS_SCSI(isp)) {
478 ISP_WRITE(isp, BIU_ICR, BIU_ICR_SOFT_RESET);
479 /*
480 * A slight delay...
481 */
520 USEC_DELAY(100);
482 ISP_DELAY(100);
521
522 /*
523 * Clear data && control DMA engines.
524 */
483
484 /*
485 * Clear data && control DMA engines.
486 */
525 ISP_WRITE(isp, CDMA_CONTROL,
526 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
527 ISP_WRITE(isp, DDMA_CONTROL,
528 DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
487 ISP_WRITE(isp, CDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
488 ISP_WRITE(isp, DDMA_CONTROL, DMA_CNTRL_CLEAR_CHAN | DMA_CNTRL_RESET_INT);
529
530
531 } else if (IS_24XX(isp)) {
532 /*
533 * Stop DMA and wait for it to stop.
534 */
535 ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4));
536 for (val = loops = 0; loops < 30000; loops++) {
489
490
491 } else if (IS_24XX(isp)) {
492 /*
493 * Stop DMA and wait for it to stop.
494 */
495 ISP_WRITE(isp, BIU2400_CSR, BIU2400_DMA_STOP|(3 << 4));
496 for (val = loops = 0; loops < 30000; loops++) {
537 USEC_DELAY(10);
497 ISP_DELAY(10);
538 val = ISP_READ(isp, BIU2400_CSR);
539 if ((val & BIU2400_DMA_ACTIVE) == 0) {
540 break;
541 }
498 val = ISP_READ(isp, BIU2400_CSR);
499 if ((val & BIU2400_DMA_ACTIVE) == 0) {
500 break;
501 }
542 }
502 }
543 if (val & BIU2400_DMA_ACTIVE) {
544 ISP_RESET0(isp);
545 isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset");
546 return;
547 }
548 /*
549 * Hold it in SOFT_RESET and STOP state for 100us.
550 */
503 if (val & BIU2400_DMA_ACTIVE) {
504 ISP_RESET0(isp);
505 isp_prt(isp, ISP_LOGERR, "DMA Failed to Stop on Reset");
506 return;
507 }
508 /*
509 * Hold it in SOFT_RESET and STOP state for 100us.
510 */
551 ISP_WRITE(isp, BIU2400_CSR,
552 BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4));
553 USEC_DELAY(100);
511 ISP_WRITE(isp, BIU2400_CSR, BIU2400_SOFT_RESET|BIU2400_DMA_STOP|(3 << 4));
512 ISP_DELAY(100);
554 for (loops = 0; loops < 10000; loops++) {
513 for (loops = 0; loops < 10000; loops++) {
555 USEC_DELAY(5);
514 ISP_DELAY(5);
556 val = ISP_READ(isp, OUTMAILBOX0);
557 }
558 for (val = loops = 0; loops < 500000; loops ++) {
559 val = ISP_READ(isp, BIU2400_CSR);
560 if ((val & BIU2400_SOFT_RESET) == 0) {
561 break;
562 }
563 }
564 if (val & BIU2400_SOFT_RESET) {
565 ISP_RESET0(isp);
566 isp_prt(isp, ISP_LOGERR, "Failed to come out of reset");
567 return;
568 }
569 } else {
570 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
571 /*
572 * A slight delay...
573 */
515 val = ISP_READ(isp, OUTMAILBOX0);
516 }
517 for (val = loops = 0; loops < 500000; loops ++) {
518 val = ISP_READ(isp, BIU2400_CSR);
519 if ((val & BIU2400_SOFT_RESET) == 0) {
520 break;
521 }
522 }
523 if (val & BIU2400_SOFT_RESET) {
524 ISP_RESET0(isp);
525 isp_prt(isp, ISP_LOGERR, "Failed to come out of reset");
526 return;
527 }
528 } else {
529 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
530 /*
531 * A slight delay...
532 */
574 USEC_DELAY(100);
533 ISP_DELAY(100);
575
576 /*
577 * Clear data && control DMA engines.
578 */
534
535 /*
536 * Clear data && control DMA engines.
537 */
579 ISP_WRITE(isp, CDMA2100_CONTROL,
580 DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
581 ISP_WRITE(isp, TDMA2100_CONTROL,
582 DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
583 ISP_WRITE(isp, RDMA2100_CONTROL,
584 DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
538 ISP_WRITE(isp, CDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
539 ISP_WRITE(isp, TDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
540 ISP_WRITE(isp, RDMA2100_CONTROL, DMA_CNTRL2100_CLEAR_CHAN | DMA_CNTRL2100_RESET_INT);
585 }
586
587 /*
588 * Wait for ISP to be ready to go...
589 */
590 loops = MBOX_DELAY_COUNT;
591 for (;;) {
592 if (IS_SCSI(isp)) {
593 if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET)) {
594 break;
595 }
596 } else if (IS_24XX(isp)) {
597 if (ISP_READ(isp, OUTMAILBOX0) == 0) {
598 break;
599 }
600 } else {
601 if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET))
602 break;
603 }
541 }
542
543 /*
544 * Wait for ISP to be ready to go...
545 */
546 loops = MBOX_DELAY_COUNT;
547 for (;;) {
548 if (IS_SCSI(isp)) {
549 if (!(ISP_READ(isp, BIU_ICR) & BIU_ICR_SOFT_RESET)) {
550 break;
551 }
552 } else if (IS_24XX(isp)) {
553 if (ISP_READ(isp, OUTMAILBOX0) == 0) {
554 break;
555 }
556 } else {
557 if (!(ISP_READ(isp, BIU2100_CSR) & BIU2100_SOFT_RESET))
558 break;
559 }
604 USEC_DELAY(100);
560 ISP_DELAY(100);
605 if (--loops < 0) {
606 ISP_DUMPREGS(isp, "chip reset timed out");
607 ISP_RESET0(isp);
608 return;
609 }
610 }
611
612 /*

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

624 * Reset RISC Processor
625 */
626 if (IS_24XX(isp)) {
627 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET);
628 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE);
629 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET);
630 } else {
631 ISP_WRITE(isp, HCCR, HCCR_CMD_RESET);
561 if (--loops < 0) {
562 ISP_DUMPREGS(isp, "chip reset timed out");
563 ISP_RESET0(isp);
564 return;
565 }
566 }
567
568 /*

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

580 * Reset RISC Processor
581 */
582 if (IS_24XX(isp)) {
583 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RESET);
584 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_RELEASE);
585 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RESET);
586 } else {
587 ISP_WRITE(isp, HCCR, HCCR_CMD_RESET);
632 USEC_DELAY(100);
588 ISP_DELAY(100);
633 ISP_WRITE(isp, BIU_SEMA, 0);
634 }
635
589 ISP_WRITE(isp, BIU_SEMA, 0);
590 }
591
636
637 /*
638 * Post-RISC Reset stuff.
639 */
640 if (IS_24XX(isp)) {
641 for (val = loops = 0; loops < 5000000; loops++) {
592 /*
593 * Post-RISC Reset stuff.
594 */
595 if (IS_24XX(isp)) {
596 for (val = loops = 0; loops < 5000000; loops++) {
642 USEC_DELAY(5);
597 ISP_DELAY(5);
643 val = ISP_READ(isp, OUTMAILBOX0);
644 if (val == 0) {
645 break;
646 }
647 }
648 if (val != 0) {
649 ISP_RESET0(isp);
650 isp_prt(isp, ISP_LOGERR, "reset didn't clear");

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

658 if (isp->isp_type == ISP_HA_SCSI_1040A) {
659 tmp &= BIU_BURST_ENABLE;
660 }
661 ISP_SETBITS(isp, BIU_CONF1, tmp);
662 if (tmp & BIU_BURST_ENABLE) {
663 ISP_SETBITS(isp, CDMA_CONF, DMA_ENABLE_BURST);
664 ISP_SETBITS(isp, DDMA_CONF, DMA_ENABLE_BURST);
665 }
598 val = ISP_READ(isp, OUTMAILBOX0);
599 if (val == 0) {
600 break;
601 }
602 }
603 if (val != 0) {
604 ISP_RESET0(isp);
605 isp_prt(isp, ISP_LOGERR, "reset didn't clear");

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

613 if (isp->isp_type == ISP_HA_SCSI_1040A) {
614 tmp &= BIU_BURST_ENABLE;
615 }
616 ISP_SETBITS(isp, BIU_CONF1, tmp);
617 if (tmp & BIU_BURST_ENABLE) {
618 ISP_SETBITS(isp, CDMA_CONF, DMA_ENABLE_BURST);
619 ISP_SETBITS(isp, DDMA_CONF, DMA_ENABLE_BURST);
620 }
666 if (SDPARAM(isp)->isp_ptisp) {
667 if (SDPARAM(isp)->isp_ultramode) {
621 if (SDPARAM(isp, 0)->isp_ptisp) {
622 if (SDPARAM(isp, 0)->isp_ultramode) {
668 while (ISP_READ(isp, RISC_MTR) != 0x1313) {
669 ISP_WRITE(isp, RISC_MTR, 0x1313);
670 ISP_WRITE(isp, HCCR, HCCR_CMD_STEP);
671 }
672 } else {
673 ISP_WRITE(isp, RISC_MTR, 0x1212);
674 }
675 /*

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

687 }
688 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
689 }
690
691 ISP_WRITE(isp, isp->isp_rqstinrp, 0);
692 ISP_WRITE(isp, isp->isp_rqstoutrp, 0);
693 ISP_WRITE(isp, isp->isp_respinrp, 0);
694 ISP_WRITE(isp, isp->isp_respoutrp, 0);
623 while (ISP_READ(isp, RISC_MTR) != 0x1313) {
624 ISP_WRITE(isp, RISC_MTR, 0x1313);
625 ISP_WRITE(isp, HCCR, HCCR_CMD_STEP);
626 }
627 } else {
628 ISP_WRITE(isp, RISC_MTR, 0x1212);
629 }
630 /*

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

642 }
643 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
644 }
645
646 ISP_WRITE(isp, isp->isp_rqstinrp, 0);
647 ISP_WRITE(isp, isp->isp_rqstoutrp, 0);
648 ISP_WRITE(isp, isp->isp_respinrp, 0);
649 ISP_WRITE(isp, isp->isp_respoutrp, 0);
650 if (IS_24XX(isp)) {
651 ISP_WRITE(isp, BIU2400_PRI_REQINP, 0);
652 ISP_WRITE(isp, BIU2400_PRI_REQOUTP, 0);
653 ISP_WRITE(isp, BIU2400_ATIO_RSPINP, 0);
654 ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, 0);
655 }
695
656
696
697 /*
698 * Do MD specific post initialization
699 */
700 ISP_RESET1(isp);
701
702 /*
703 * Wait for everything to finish firing up.
704 *
657 /*
658 * Do MD specific post initialization
659 */
660 ISP_RESET1(isp);
661
662 /*
663 * Wait for everything to finish firing up.
664 *
705 * Avoid doing this on the 2312 because you can generate a PCI
665 * Avoid doing this on early 2312s because you can generate a PCI
706 * parity error (chip breakage).
707 */
666 * parity error (chip breakage).
667 */
708 if (IS_2312(isp)) {
709 USEC_DELAY(100);
668 if (IS_2312(isp) && isp->isp_revision < 2) {
669 ISP_DELAY(100);
710 } else {
711 loops = MBOX_DELAY_COUNT;
712 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
670 } else {
671 loops = MBOX_DELAY_COUNT;
672 while (ISP_READ(isp, OUTMAILBOX0) == MBOX_BUSY) {
713 USEC_DELAY(100);
673 ISP_DELAY(100);
714 if (--loops < 0) {
715 ISP_RESET0(isp);
716 isp_prt(isp, ISP_LOGERR,
717 "MBOX_BUSY never cleared on reset");
718 return;
719 }
720 }
721 }
722
723 /*
724 * Up until this point we've done everything by just reading or
725 * setting registers. From this point on we rely on at least *some*
726 * kind of firmware running in the card.
727 */
728
729 /*
674 if (--loops < 0) {
675 ISP_RESET0(isp);
676 isp_prt(isp, ISP_LOGERR,
677 "MBOX_BUSY never cleared on reset");
678 return;
679 }
680 }
681 }
682
683 /*
684 * Up until this point we've done everything by just reading or
685 * setting registers. From this point on we rely on at least *some*
686 * kind of firmware running in the card.
687 */
688
689 /*
730 * Do some sanity checking.
690 * Do some sanity checking by running a NOP command.
691 * If it succeeds, the ROM firmware is now running.
731 */
692 */
732 MEMZERO(&mbs, sizeof (mbs));
693 ISP_MEMZERO(&mbs, sizeof (mbs));
733 mbs.param[0] = MBOX_NO_OP;
734 mbs.logval = MBLOGALL;
735 isp_mboxcmd(isp, &mbs);
736 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
694 mbs.param[0] = MBOX_NO_OP;
695 mbs.logval = MBLOGALL;
696 isp_mboxcmd(isp, &mbs);
697 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
698 isp_prt(isp, ISP_LOGERR, "NOP ommand failed (%x)", mbs.param[0]);
737 ISP_RESET0(isp);
738 return;
739 }
740
699 ISP_RESET0(isp);
700 return;
701 }
702
703 /*
704 * Do some operational tests
705 */
706
741 if (IS_SCSI(isp) || IS_24XX(isp)) {
707 if (IS_SCSI(isp) || IS_24XX(isp)) {
742 MEMZERO(&mbs, sizeof (mbs));
708 ISP_MEMZERO(&mbs, sizeof (mbs));
743 mbs.param[0] = MBOX_MAILBOX_REG_TEST;
744 mbs.param[1] = 0xdead;
745 mbs.param[2] = 0xbeef;
746 mbs.param[3] = 0xffff;
747 mbs.param[4] = 0x1111;
748 mbs.param[5] = 0xa5a5;
749 mbs.param[6] = 0x0000;
750 mbs.param[7] = 0x0000;
751 mbs.logval = MBLOGALL;
752 isp_mboxcmd(isp, &mbs);
753 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
754 ISP_RESET0(isp);
755 return;
756 }
757 if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef ||
758 mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 ||
759 mbs.param[5] != 0xa5a5) {
760 ISP_RESET0(isp);
709 mbs.param[0] = MBOX_MAILBOX_REG_TEST;
710 mbs.param[1] = 0xdead;
711 mbs.param[2] = 0xbeef;
712 mbs.param[3] = 0xffff;
713 mbs.param[4] = 0x1111;
714 mbs.param[5] = 0xa5a5;
715 mbs.param[6] = 0x0000;
716 mbs.param[7] = 0x0000;
717 mbs.logval = MBLOGALL;
718 isp_mboxcmd(isp, &mbs);
719 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
720 ISP_RESET0(isp);
721 return;
722 }
723 if (mbs.param[1] != 0xdead || mbs.param[2] != 0xbeef ||
724 mbs.param[3] != 0xffff || mbs.param[4] != 0x1111 ||
725 mbs.param[5] != 0xa5a5) {
726 ISP_RESET0(isp);
761 isp_prt(isp, ISP_LOGERR,
762 "Register Test Failed (0x%x 0x%x 0x%x 0x%x 0x%x)",
763 mbs.param[1], mbs.param[2], mbs.param[3],
764 mbs.param[4], mbs.param[5]);
727 isp_prt(isp, ISP_LOGERR, "Register Test Failed (0x%x 0x%x 0x%x 0x%x 0x%x)", mbs.param[1], mbs.param[2], mbs.param[3], mbs.param[4], mbs.param[5]);
765 return;
766 }
767
768 }
769
770 /*
771 * Download new Firmware, unless requested not to do so.
772 * This is made slightly trickier in some cases where the
773 * firmware of the ROM revision is newer than the revision
774 * compiled into the driver. So, where we used to compare
775 * versions of our f/w and the ROM f/w, now we just see
776 * whether we have f/w at all and whether a config flag
777 * has disabled our download.
778 */
728 return;
729 }
730
731 }
732
733 /*
734 * Download new Firmware, unless requested not to do so.
735 * This is made slightly trickier in some cases where the
736 * firmware of the ROM revision is newer than the revision
737 * compiled into the driver. So, where we used to compare
738 * versions of our f/w and the ROM f/w, now we just see
739 * whether we have f/w at all and whether a config flag
740 * has disabled our download.
741 */
779 if ((isp->isp_mdvec->dv_ispfw == NULL) ||
780 (isp->isp_confopts & ISP_CFG_NORELOAD)) {
742 if ((isp->isp_mdvec->dv_ispfw == NULL) || (isp->isp_confopts & ISP_CFG_NORELOAD)) {
781 dodnld = 0;
782 }
783
784 if (IS_24XX(isp)) {
785 code_org = ISP_CODE_ORG_2400;
786 } else if (IS_23XX(isp)) {
787 code_org = ISP_CODE_ORG_2300;
788 } else {
789 code_org = ISP_CODE_ORG;
790 }
791
792 if (dodnld && IS_24XX(isp)) {
793 const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
794
795 /*
743 dodnld = 0;
744 }
745
746 if (IS_24XX(isp)) {
747 code_org = ISP_CODE_ORG_2400;
748 } else if (IS_23XX(isp)) {
749 code_org = ISP_CODE_ORG_2300;
750 } else {
751 code_org = ISP_CODE_ORG;
752 }
753
754 if (dodnld && IS_24XX(isp)) {
755 const uint32_t *ptr = isp->isp_mdvec->dv_ispfw;
756
757 /*
796 * NB: Whatever you do do, do *not* issue the VERIFY FIRMWARE
797 * NB: command to the 2400 while loading new firmware. This
798 * NB: causes the new f/w to start and immediately crash back
799 * NB: to the ROM.
800 */
801
802 /*
803 * Keep loading until we run out of f/w.
804 */
805 code_org = ptr[2]; /* 1st load address is our start addr */
806
807 for (;;) {
808 uint32_t la, wi, wl;
809
758 * Keep loading until we run out of f/w.
759 */
760 code_org = ptr[2]; /* 1st load address is our start addr */
761
762 for (;;) {
763 uint32_t la, wi, wl;
764
810 isp_prt(isp, ISP_LOGDEBUG0,
811 "load 0x%x words of code at load address 0x%x",
812 ptr[3], ptr[2]);
765 isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], ptr[2]);
813
814 wi = 0;
815 la = ptr[2];
816 wl = ptr[3];
817
818 while (wi < ptr[3]) {
819 uint32_t *cp;
820 uint32_t nw;
821
822 nw = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) >> 2;
823 if (nw > wl) {
824 nw = wl;
825 }
826 cp = isp->isp_rquest;
827 for (i = 0; i < nw; i++) {
828 ISP_IOXPUT_32(isp, ptr[wi++], &cp[i]);
829 wl--;
830 }
766
767 wi = 0;
768 la = ptr[2];
769 wl = ptr[3];
770
771 while (wi < ptr[3]) {
772 uint32_t *cp;
773 uint32_t nw;
774
775 nw = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) >> 2;
776 if (nw > wl) {
777 nw = wl;
778 }
779 cp = isp->isp_rquest;
780 for (i = 0; i < nw; i++) {
781 ISP_IOXPUT_32(isp, ptr[wi++], &cp[i]);
782 wl--;
783 }
831 MEMORYBARRIER(isp, SYNC_REQUEST,
832 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)));
833 MEMZERO(&mbs, sizeof (mbs));
834 mbs.param[0] = MBOX_LOAD_RISC_RAM;
835 mbs.param[1] = la;
836 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
837 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
838 mbs.param[4] = nw >> 16;
839 mbs.param[5] = nw;
840 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
841 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
842 mbs.param[8] = la >> 16;
784 MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)));
785 ISP_MEMZERO(&mbs, sizeof (mbs));
786 if (la < 0x10000 && nw < 0x10000) {
787 mbs.param[0] = MBOX_LOAD_RISC_RAM_2100;
788 mbs.param[1] = la;
789 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
790 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
791 mbs.param[4] = nw;
792 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
793 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
794 } else {
795 mbs.param[0] = MBOX_LOAD_RISC_RAM;
796 mbs.param[1] = la;
797 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
798 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
799 mbs.param[4] = nw >> 16;
800 mbs.param[5] = nw;
801 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
802 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
803 mbs.param[8] = la >> 16;
804 }
843 mbs.logval = MBLOGALL;
844 isp_mboxcmd(isp, &mbs);
845 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
805 mbs.logval = MBLOGALL;
806 isp_mboxcmd(isp, &mbs);
807 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
846 isp_prt(isp, ISP_LOGERR,
847 "F/W Risc Ram Load Failed");
808 isp_prt(isp, ISP_LOGERR, "F/W Risc Ram Load Failed");
848 ISP_RESET0(isp);
849 return;
850 }
851 la += nw;
852 }
853
854 if (ptr[1] == 0) {
855 break;
856 }
857 ptr += ptr[3];
809 ISP_RESET0(isp);
810 return;
811 }
812 la += nw;
813 }
814
815 if (ptr[1] == 0) {
816 break;
817 }
818 ptr += ptr[3];
858 }
819 }
859 isp->isp_loaded_fw = 1;
860 } else if (dodnld && IS_23XX(isp)) {
861 const uint16_t *ptr = isp->isp_mdvec->dv_ispfw;
862 uint16_t wi, wl, segno;
863 uint32_t la;
864
865 la = code_org;
866 segno = 0;
867
868 for (;;) {
869 uint32_t nxtaddr;
870
820 isp->isp_loaded_fw = 1;
821 } else if (dodnld && IS_23XX(isp)) {
822 const uint16_t *ptr = isp->isp_mdvec->dv_ispfw;
823 uint16_t wi, wl, segno;
824 uint32_t la;
825
826 la = code_org;
827 segno = 0;
828
829 for (;;) {
830 uint32_t nxtaddr;
831
871 isp_prt(isp, ISP_LOGDEBUG0,
872 "load 0x%x words of code at load address 0x%x",
873 ptr[3], la);
832 isp_prt(isp, ISP_LOGDEBUG0, "load 0x%x words of code at load address 0x%x", ptr[3], la);
874
875 wi = 0;
876 wl = ptr[3];
877
878 while (wi < ptr[3]) {
879 uint16_t *cp;
833
834 wi = 0;
835 wl = ptr[3];
836
837 while (wi < ptr[3]) {
838 uint16_t *cp;
880 uint32_t nw;
881
839 uint16_t nw;
840
882 nw = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) >> 1;
883 if (nw > wl) {
884 nw = wl;
885 }
886 if (nw > (1 << 15)) {
887 nw = 1 << 15;
888 }
889 cp = isp->isp_rquest;
890 for (i = 0; i < nw; i++) {
891 ISP_IOXPUT_16(isp, ptr[wi++], &cp[i]);
892 wl--;
893 }
841 nw = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)) >> 1;
842 if (nw > wl) {
843 nw = wl;
844 }
845 if (nw > (1 << 15)) {
846 nw = 1 << 15;
847 }
848 cp = isp->isp_rquest;
849 for (i = 0; i < nw; i++) {
850 ISP_IOXPUT_16(isp, ptr[wi++], &cp[i]);
851 wl--;
852 }
894 MEMORYBARRIER(isp, SYNC_REQUEST,
895 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)));
896 MEMZERO(&mbs, sizeof (mbs));
897 mbs.param[0] = MBOX_LOAD_RISC_RAM;
898 mbs.param[1] = la;
899 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
900 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
901 mbs.param[4] = nw;
902 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
903 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
904 mbs.param[8] = la >> 16;
853 MEMORYBARRIER(isp, SYNC_REQUEST, 0, ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN(isp)));
854 ISP_MEMZERO(&mbs, sizeof (mbs));
855 if (la < 0x10000) {
856 mbs.param[0] = MBOX_LOAD_RISC_RAM_2100;
857 mbs.param[1] = la;
858 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
859 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
860 mbs.param[4] = nw;
861 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
862 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
863 } else {
864 mbs.param[0] = MBOX_LOAD_RISC_RAM;
865 mbs.param[1] = la;
866 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
867 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
868 mbs.param[4] = nw;
869 mbs.param[6] = DMA_WD3(isp->isp_rquest_dma);
870 mbs.param[7] = DMA_WD2(isp->isp_rquest_dma);
871 mbs.param[8] = la >> 16;
872 }
905 mbs.logval = MBLOGALL;
906 isp_mboxcmd(isp, &mbs);
907 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
873 mbs.logval = MBLOGALL;
874 isp_mboxcmd(isp, &mbs);
875 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
908 isp_prt(isp, ISP_LOGERR,
909 "F/W Risc Ram Load Failed");
876 isp_prt(isp, ISP_LOGERR, "F/W Risc Ram Load Failed");
910 ISP_RESET0(isp);
911 return;
912 }
913 la += nw;
914 }
915
916 if (!IS_2322(isp)) {
877 ISP_RESET0(isp);
878 return;
879 }
880 la += nw;
881 }
882
883 if (!IS_2322(isp)) {
917 /*
918 * Verify that it downloaded correctly.
919 */
920 MEMZERO(&mbs, sizeof (mbs));
921 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
922 mbs.param[1] = code_org;
923 mbs.logval = MBLOGNONE;
924 isp_mboxcmd(isp, &mbs);
925 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
926 isp_prt(isp, ISP_LOGERR, dcrc);
927 ISP_RESET0(isp);
928 return;
929 }
930 break;
931 }
932
933 if (++segno == 3) {
934 break;
935 }
936
937 /*

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

946 ptr = &ptr[nxtaddr];
947 la = ptr[5] | ((ptr[4] & 0x3f) << 16);
948 }
949 isp->isp_loaded_fw = 1;
950 } else if (dodnld) {
951 union {
952 const uint16_t *cp;
953 uint16_t *np;
884 break;
885 }
886
887 if (++segno == 3) {
888 break;
889 }
890
891 /*

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

900 ptr = &ptr[nxtaddr];
901 la = ptr[5] | ((ptr[4] & 0x3f) << 16);
902 }
903 isp->isp_loaded_fw = 1;
904 } else if (dodnld) {
905 union {
906 const uint16_t *cp;
907 uint16_t *np;
954 } u;
955 u.cp = isp->isp_mdvec->dv_ispfw;
956 isp->isp_mbxworkp = &u.np[1];
957 isp->isp_mbxwrk0 = u.np[3] - 1;
908 } ucd;
909 ucd.cp = isp->isp_mdvec->dv_ispfw;
910 isp->isp_mbxworkp = &ucd.np[1];
911 isp->isp_mbxwrk0 = ucd.np[3] - 1;
958 isp->isp_mbxwrk1 = code_org + 1;
912 isp->isp_mbxwrk1 = code_org + 1;
959 MEMZERO(&mbs, sizeof (mbs));
913 ISP_MEMZERO(&mbs, sizeof (mbs));
960 mbs.param[0] = MBOX_WRITE_RAM_WORD;
961 mbs.param[1] = code_org;
914 mbs.param[0] = MBOX_WRITE_RAM_WORD;
915 mbs.param[1] = code_org;
962 mbs.param[2] = u.np[0];
916 mbs.param[2] = ucd.np[0];
963 mbs.logval = MBLOGNONE;
964 isp_mboxcmd(isp, &mbs);
965 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
917 mbs.logval = MBLOGNONE;
918 isp_mboxcmd(isp, &mbs);
919 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
966 isp_prt(isp, ISP_LOGERR,
967 "F/W download failed at word %d",
968 isp->isp_mbxwrk1 - code_org);
920 isp_prt(isp, ISP_LOGERR, "F/W download failed at word %d", isp->isp_mbxwrk1 - code_org);
969 ISP_RESET0(isp);
970 return;
971 }
921 ISP_RESET0(isp);
922 return;
923 }
972 /*
973 * Verify that it downloaded correctly.
974 */
975 MEMZERO(&mbs, sizeof (mbs));
924 } else {
925 isp->isp_loaded_fw = 0;
926 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
927 }
928
929 /*
930 * If we loaded firmware, verify its checksum
931 */
932 if (isp->isp_loaded_fw) {
933 ISP_MEMZERO(&mbs, sizeof (mbs));
976 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
934 mbs.param[0] = MBOX_VERIFY_CHECKSUM;
977 mbs.param[1] = code_org;
978 mbs.logval = MBLOGNONE;
935 if (IS_24XX(isp)) {
936 mbs.param[1] = code_org >> 16;
937 mbs.param[2] = code_org;
938 } else {
939 mbs.param[1] = code_org;
940 }
979 isp_mboxcmd(isp, &mbs);
980 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
981 isp_prt(isp, ISP_LOGERR, dcrc);
982 ISP_RESET0(isp);
983 return;
984 }
941 isp_mboxcmd(isp, &mbs);
942 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
943 isp_prt(isp, ISP_LOGERR, dcrc);
944 ISP_RESET0(isp);
945 return;
946 }
985 isp->isp_loaded_fw = 1;
986 } else {
987 isp->isp_loaded_fw = 0;
988 isp_prt(isp, ISP_LOGDEBUG2, "skipping f/w download");
989 }
990
991 /*
992 * Now start it rolling.
993 *
994 * If we didn't actually download f/w,
995 * we still need to (re)start it.
996 */
997
998
947 }
948
949 /*
950 * Now start it rolling.
951 *
952 * If we didn't actually download f/w,
953 * we still need to (re)start it.
954 */
955
956
999 MEMZERO(&mbs, sizeof (mbs));
1000 mbs.timeout = 1000000;
1001 mbs.param[0] = MBOX_EXEC_FIRMWARE;
957 MBSINIT(&mbs, MBOX_EXEC_FIRMWARE, MBLOGALL, 1000000);
1002 if (IS_24XX(isp)) {
1003 mbs.param[1] = code_org >> 16;
1004 mbs.param[2] = code_org;
1005 if (isp->isp_loaded_fw) {
1006 mbs.param[3] = 0;
1007 } else {
1008 mbs.param[3] = 1;
1009 }
958 if (IS_24XX(isp)) {
959 mbs.param[1] = code_org >> 16;
960 mbs.param[2] = code_org;
961 if (isp->isp_loaded_fw) {
962 mbs.param[3] = 0;
963 } else {
964 mbs.param[3] = 1;
965 }
966 if (IS_25XX(isp)) {
967 mbs.ibits |= 0x10;
968 }
1010 } else if (IS_2322(isp)) {
1011 mbs.param[1] = code_org;
1012 if (isp->isp_loaded_fw) {
1013 mbs.param[2] = 0;
1014 } else {
1015 mbs.param[2] = 1;
1016 }
1017 } else {
1018 mbs.param[1] = code_org;
1019 }
969 } else if (IS_2322(isp)) {
970 mbs.param[1] = code_org;
971 if (isp->isp_loaded_fw) {
972 mbs.param[2] = 0;
973 } else {
974 mbs.param[2] = 1;
975 }
976 } else {
977 mbs.param[1] = code_org;
978 }
1020
1021 mbs.logval = MBLOGALL;
1022 isp_mboxcmd(isp, &mbs);
1023 if (IS_2322(isp) || IS_24XX(isp)) {
1024 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1025 ISP_RESET0(isp);
1026 return;
1027 }
1028 }
1029
1030 /*
1031 * Give it a chance to finish starting up.
979 isp_mboxcmd(isp, &mbs);
980 if (IS_2322(isp) || IS_24XX(isp)) {
981 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
982 ISP_RESET0(isp);
983 return;
984 }
985 }
986
987 /*
988 * Give it a chance to finish starting up.
989 * Give the 24XX more time.
1032 */
990 */
1033 USEC_DELAY(250000);
1034
1035 if (IS_SCSI(isp)) {
991 if (IS_24XX(isp)) {
992 ISP_DELAY(500000);
1036 /*
993 /*
1037 * Set CLOCK RATE, but only if asked to.
994 * Check to see if the 24XX firmware really started.
1038 */
995 */
1039 if (isp->isp_clock) {
1040 mbs.param[0] = MBOX_SET_CLOCK_RATE;
1041 mbs.param[1] = isp->isp_clock;
1042 mbs.logval = MBLOGNONE;
1043 isp_mboxcmd(isp, &mbs);
1044 /* we will try not to care if this fails */
996 if (mbs.param[1] == 0xdead) {
997 isp_prt(isp, ISP_LOGERR, "f/w didn't *really* start");
998 ISP_RESET0(isp);
999 return;
1045 }
1000 }
1001 } else {
1002 ISP_DELAY(250000);
1003 if (IS_SCSI(isp)) {
1004 /*
1005 * Set CLOCK RATE, but only if asked to.
1006 */
1007 if (isp->isp_clock) {
1008 mbs.param[0] = MBOX_SET_CLOCK_RATE;
1009 mbs.param[1] = isp->isp_clock;
1010 mbs.logval = MBLOGNONE;
1011 isp_mboxcmd(isp, &mbs);
1012 /* we will try not to care if this fails */
1013 }
1014 }
1046 }
1047
1015 }
1016
1048 MEMZERO(&mbs, sizeof (mbs));
1049 mbs.param[0] = MBOX_ABOUT_FIRMWARE;
1050 mbs.logval = MBLOGALL;
1017 /*
1018 * Ask the chip for the current firmware version.
1019 * This should prove that the new firmware is working.
1020 */
1021 MBSINIT(&mbs, MBOX_ABOUT_FIRMWARE, MBLOGALL, 0);
1051 isp_mboxcmd(isp, &mbs);
1052 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1053 ISP_RESET0(isp);
1054 return;
1055 }
1056
1022 isp_mboxcmd(isp, &mbs);
1023 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1024 ISP_RESET0(isp);
1025 return;
1026 }
1027
1057 if (IS_24XX(isp) && mbs.param[1] == 0xdead) {
1058 isp_prt(isp, ISP_LOGERR, "f/w didn't *really* start");
1059 ISP_RESET0(isp);
1060 return;
1061 }
1062
1063 /*
1064 * The SBus firmware that we are using apparently does not return
1065 * major, minor, micro revisions in the mailbox registers, which
1066 * is really, really, annoying.
1067 */
1068 if (ISP_SBUS_SUPPORTED && isp->isp_bustype == ISP_BT_SBUS) {
1069 if (dodnld) {
1070#ifdef ISP_TARGET_MODE
1071 isp->isp_fwrev[0] = 7;
1072 isp->isp_fwrev[1] = 55;
1073#else
1074 isp->isp_fwrev[0] = 1;
1075 isp->isp_fwrev[1] = 37;
1076#endif
1077 isp->isp_fwrev[2] = 0;
1028 /*
1029 * The SBus firmware that we are using apparently does not return
1030 * major, minor, micro revisions in the mailbox registers, which
1031 * is really, really, annoying.
1032 */
1033 if (ISP_SBUS_SUPPORTED && isp->isp_bustype == ISP_BT_SBUS) {
1034 if (dodnld) {
1035#ifdef ISP_TARGET_MODE
1036 isp->isp_fwrev[0] = 7;
1037 isp->isp_fwrev[1] = 55;
1038#else
1039 isp->isp_fwrev[0] = 1;
1040 isp->isp_fwrev[1] = 37;
1041#endif
1042 isp->isp_fwrev[2] = 0;
1078 }
1043 }
1079 } else {
1080 isp->isp_fwrev[0] = mbs.param[1];
1081 isp->isp_fwrev[1] = mbs.param[2];
1082 isp->isp_fwrev[2] = mbs.param[3];
1083 }
1084
1044 } else {
1045 isp->isp_fwrev[0] = mbs.param[1];
1046 isp->isp_fwrev[1] = mbs.param[2];
1047 isp->isp_fwrev[2] = mbs.param[3];
1048 }
1049
1085 isp_prt(isp, ISP_LOGALL,
1086 "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d",
1087 btype, isp->isp_revision, dodnld? "loaded" : "resident",
1088 isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]);
1050 isp_prt(isp, ISP_LOGCONFIG, "Board Type %s, Chip Revision 0x%x, %s F/W Revision %d.%d.%d",
1051 btype, isp->isp_revision, dodnld? "loaded" : "resident", isp->isp_fwrev[0], isp->isp_fwrev[1], isp->isp_fwrev[2]);
1089
1090 if (IS_FC(isp)) {
1091 /*
1092 * We do not believe firmware attributes for 2100 code less
1093 * than 1.17.0, unless it's the firmware we specifically
1094 * are loading.
1095 *
1096 * Note that all 22XX and later f/w is greater than 1.X.0.
1097 */
1098 if ((ISP_FW_OLDER_THAN(isp, 1, 17, 1))) {
1099#ifdef USE_SMALLER_2100_FIRMWARE
1052
1053 if (IS_FC(isp)) {
1054 /*
1055 * We do not believe firmware attributes for 2100 code less
1056 * than 1.17.0, unless it's the firmware we specifically
1057 * are loading.
1058 *
1059 * Note that all 22XX and later f/w is greater than 1.X.0.
1060 */
1061 if ((ISP_FW_OLDER_THAN(isp, 1, 17, 1))) {
1062#ifdef USE_SMALLER_2100_FIRMWARE
1100 FCPARAM(isp)->isp_fwattr = ISP_FW_ATTR_SCCLUN;
1063 isp->isp_fwattr = ISP_FW_ATTR_SCCLUN;
1101#else
1064#else
1102 FCPARAM(isp)->isp_fwattr = 0;
1065 isp->isp_fwattr = 0;
1103#endif
1104 } else {
1066#endif
1067 } else {
1105 FCPARAM(isp)->isp_fwattr = mbs.param[6];
1106 isp_prt(isp, ISP_LOGDEBUG0,
1107 "Firmware Attributes = 0x%x", mbs.param[6]);
1068 isp->isp_fwattr = mbs.param[6];
1069 isp_prt(isp, ISP_LOGDEBUG0, "Firmware Attributes = 0x%x", mbs.param[6]);
1108 }
1070 }
1109 FCPARAM(isp)->isp_2klogin = 0;
1110 FCPARAM(isp)->isp_sccfw = 0;
1111 FCPARAM(isp)->isp_tmode = 0;
1112 if (IS_24XX(isp)) {
1113 FCPARAM(isp)->isp_2klogin = 1;
1114 FCPARAM(isp)->isp_sccfw = 1;
1115 FCPARAM(isp)->isp_tmode = 1;
1116 } else {
1117 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) {
1118 FCPARAM(isp)->isp_sccfw = 1;
1119 }
1120 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_2KLOGINS) {
1121 FCPARAM(isp)->isp_2klogin = 1;
1122 FCPARAM(isp)->isp_sccfw = 1;
1123 }
1124 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_TMODE) {
1125 FCPARAM(isp)->isp_tmode = 1;
1126 }
1127 }
1128 if (FCPARAM(isp)->isp_2klogin) {
1129 isp_prt(isp, ISP_LOGCONFIG, "2K Logins Supported");
1130 }
1071 } else {
1072#ifndef ISP_TARGET_MODE
1073 isp->isp_fwattr = ISP_FW_ATTR_TMODE;
1074#else
1075 isp->isp_fwattr = 0;
1076#endif
1131 }
1132
1077 }
1078
1133 if (isp->isp_romfw_rev[0] || isp->isp_romfw_rev[1] ||
1134 isp->isp_romfw_rev[2]) {
1135 isp_prt(isp, ISP_LOGCONFIG, "Last F/W revision was %d.%d.%d",
1136 isp->isp_romfw_rev[0], isp->isp_romfw_rev[1],
1137 isp->isp_romfw_rev[2]);
1138 }
1139
1140 if (!IS_24XX(isp)) {
1079 if (!IS_24XX(isp)) {
1141 MEMZERO(&mbs, sizeof (mbs));
1142 mbs.param[0] = MBOX_GET_FIRMWARE_STATUS;
1143 mbs.logval = MBLOGALL;
1080 MBSINIT(&mbs, MBOX_GET_FIRMWARE_STATUS, MBLOGALL, 0);
1144 isp_mboxcmd(isp, &mbs);
1145 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1146 ISP_RESET0(isp);
1147 return;
1148 }
1149 if (isp->isp_maxcmds >= mbs.param[2]) {
1150 isp->isp_maxcmds = mbs.param[2];
1151 }
1152 }
1081 isp_mboxcmd(isp, &mbs);
1082 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1083 ISP_RESET0(isp);
1084 return;
1085 }
1086 if (isp->isp_maxcmds >= mbs.param[2]) {
1087 isp->isp_maxcmds = mbs.param[2];
1088 }
1089 }
1153 isp_prt(isp, ISP_LOGCONFIG,
1154 "%d max I/O command limit set", isp->isp_maxcmds);
1155 isp_fw_state(isp);
1090 isp_prt(isp, ISP_LOGCONFIG, "%d max I/O command limit set", isp->isp_maxcmds);
1156
1091
1092 /*
1093 * If we don't have Multi-ID f/w loaded, we need to restrict channels to one.
1094 * Only make this check for non-SCSI cards (I'm not sure firmware attributes
1095 * work for them).
1096 */
1097 if (IS_FC(isp) && ISP_CAP_MULTI_ID(isp) == 0 && isp->isp_nchan > 1) {
1098 isp_prt(isp, ISP_LOGWARN, "non-MULTIID f/w loaded, only can enable 1 of %d channels", isp->isp_nchan);
1099 isp->isp_nchan = 1;
1100 }
1101
1102 for (i = 0; i < isp->isp_nchan; i++) {
1103 isp_fw_state(isp, i);
1104 }
1105 if (isp->isp_dead) {
1106 isp_shutdown(isp);
1107 ISP_DISABLE_INTS(isp);
1108 return;
1109 }
1110
1157 isp->isp_state = ISP_RESETSTATE;
1158
1159 /*
1160 * Okay- now that we have new firmware running, we now (re)set our
1161 * notion of how many luns we support. This is somewhat tricky because
1162 * if we haven't loaded firmware, we sometimes do not have an easy way
1163 * of knowing how many luns we support.
1164 *

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

1179 isp->isp_maxluns = 32;
1180 } else {
1181 isp->isp_maxluns = 8;
1182 }
1183 } else {
1184 isp->isp_maxluns = 8;
1185 }
1186 } else {
1111 isp->isp_state = ISP_RESETSTATE;
1112
1113 /*
1114 * Okay- now that we have new firmware running, we now (re)set our
1115 * notion of how many luns we support. This is somewhat tricky because
1116 * if we haven't loaded firmware, we sometimes do not have an easy way
1117 * of knowing how many luns we support.
1118 *

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

1133 isp->isp_maxluns = 32;
1134 } else {
1135 isp->isp_maxluns = 8;
1136 }
1137 } else {
1138 isp->isp_maxluns = 8;
1139 }
1140 } else {
1187 if (FCPARAM(isp)->isp_sccfw) {
1141 if (ISP_CAP_SCCFW(isp)) {
1188 isp->isp_maxluns = 16384;
1189 } else {
1190 isp->isp_maxluns = 16;
1191 }
1192 }
1142 isp->isp_maxluns = 16384;
1143 } else {
1144 isp->isp_maxluns = 16;
1145 }
1146 }
1147
1193 /*
1148 /*
1194 * Must do this first to get defaults established.
1149 * We get some default values established. As a side
1150 * effect, NVRAM is read here (unless overriden by
1151 * a configuration flag).
1195 */
1152 */
1196 if (IS_SCSI(isp)) {
1197 isp_setdfltparm(isp, 0);
1198 if (IS_DUALBUS(isp)) {
1199 isp_setdfltparm(isp, 1);
1153 if (do_load_defaults) {
1154 if (IS_SCSI(isp)) {
1155 isp_setdfltsdparm(isp);
1156 } else {
1157 for (i = 0; i < isp->isp_nchan; i++) {
1158 isp_setdfltfcparm(isp, i);
1159 }
1200 }
1160 }
1201 } else {
1202 isp_setdfltfcparm(isp);
1203 }
1161 }
1204
1205}
1206
1207/*
1208 * Initialize Parameters of Hardware to a known state.
1209 *
1210 * Locks are held before coming here.
1211 */
1212
1213void
1214isp_init(ispsoftc_t *isp)
1215{
1216 if (IS_FC(isp)) {
1162}
1163
1164/*
1165 * Initialize Parameters of Hardware to a known state.
1166 *
1167 * Locks are held before coming here.
1168 */
1169
1170void
1171isp_init(ispsoftc_t *isp)
1172{
1173 if (IS_FC(isp)) {
1217 /*
1218 * Do this *before* initializing the firmware.
1219 */
1220 ISP_MARK_PORTDB(isp, 0);
1221 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
1222 FCPARAM(isp)->isp_loopstate = LOOP_NIL;
1223
1224 if (isp->isp_role != ISP_ROLE_NONE) {
1225 if (IS_24XX(isp)) {
1226 isp_fibre_init_2400(isp);
1227 } else {
1228 isp_fibre_init(isp);
1229 }
1174 if (IS_24XX(isp)) {
1175 isp_fibre_init_2400(isp);
1176 } else {
1177 isp_fibre_init(isp);
1230 }
1231 } else {
1232 isp_scsi_init(isp);
1233 }
1178 }
1179 } else {
1180 isp_scsi_init(isp);
1181 }
1182 GET_NANOTIME(&isp->isp_init_time);
1234}
1235
1236static void
1237isp_scsi_init(ispsoftc_t *isp)
1238{
1239 sdparam *sdp_chan0, *sdp_chan1;
1240 mbreg_t mbs;
1241
1183}
1184
1185static void
1186isp_scsi_init(ispsoftc_t *isp)
1187{
1188 sdparam *sdp_chan0, *sdp_chan1;
1189 mbreg_t mbs;
1190
1242 sdp_chan0 = isp->isp_param;
1191 sdp_chan0 = SDPARAM(isp, 0);
1243 sdp_chan1 = sdp_chan0;
1244 if (IS_DUALBUS(isp)) {
1192 sdp_chan1 = sdp_chan0;
1193 if (IS_DUALBUS(isp)) {
1245 sdp_chan1++;
1194 sdp_chan1 = SDPARAM(isp, 1);
1246 }
1247
1195 }
1196
1248 /*
1249 * If we have no role (neither target nor initiator), return.
1250 */
1251 if (isp->isp_role == ISP_ROLE_NONE) {
1252 return;
1253 }
1254
1255 /* First do overall per-card settings. */
1256
1257 /*
1258 * If we have fast memory timing enabled, turn it on.
1259 */
1260 if (sdp_chan0->isp_fast_mttr) {
1261 ISP_WRITE(isp, RISC_MTR, 0x1313);
1262 }
1263
1264 /*
1265 * Set Retry Delay and Count.
1266 * You set both channels at the same time.
1267 */
1197 /* First do overall per-card settings. */
1198
1199 /*
1200 * If we have fast memory timing enabled, turn it on.
1201 */
1202 if (sdp_chan0->isp_fast_mttr) {
1203 ISP_WRITE(isp, RISC_MTR, 0x1313);
1204 }
1205
1206 /*
1207 * Set Retry Delay and Count.
1208 * You set both channels at the same time.
1209 */
1268 MEMZERO(&mbs, sizeof (mbs));
1269 mbs.param[0] = MBOX_SET_RETRY_COUNT;
1210 MBSINIT(&mbs, MBOX_SET_RETRY_COUNT, MBLOGALL, 0);
1270 mbs.param[1] = sdp_chan0->isp_retry_count;
1271 mbs.param[2] = sdp_chan0->isp_retry_delay;
1272 mbs.param[6] = sdp_chan1->isp_retry_count;
1273 mbs.param[7] = sdp_chan1->isp_retry_delay;
1211 mbs.param[1] = sdp_chan0->isp_retry_count;
1212 mbs.param[2] = sdp_chan0->isp_retry_delay;
1213 mbs.param[6] = sdp_chan1->isp_retry_count;
1214 mbs.param[7] = sdp_chan1->isp_retry_delay;
1274 mbs.logval = MBLOGALL;
1275 isp_mboxcmd(isp, &mbs);
1276 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1277 return;
1278 }
1279
1280 /*
1281 * Set ASYNC DATA SETUP time. This is very important.
1282 */
1215 isp_mboxcmd(isp, &mbs);
1216 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1217 return;
1218 }
1219
1220 /*
1221 * Set ASYNC DATA SETUP time. This is very important.
1222 */
1283 MEMZERO(&mbs, sizeof (mbs));
1284 mbs.param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME;
1223 MBSINIT(&mbs, MBOX_SET_ASYNC_DATA_SETUP_TIME, MBLOGALL, 0);
1285 mbs.param[1] = sdp_chan0->isp_async_data_setup;
1286 mbs.param[2] = sdp_chan1->isp_async_data_setup;
1224 mbs.param[1] = sdp_chan0->isp_async_data_setup;
1225 mbs.param[2] = sdp_chan1->isp_async_data_setup;
1287 mbs.logval = MBLOGALL;
1288 isp_mboxcmd(isp, &mbs);
1289 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1290 return;
1291 }
1292
1293 /*
1294 * Set ACTIVE Negation State.
1295 */
1226 isp_mboxcmd(isp, &mbs);
1227 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1228 return;
1229 }
1230
1231 /*
1232 * Set ACTIVE Negation State.
1233 */
1296 MEMZERO(&mbs, sizeof (mbs));
1297 mbs.param[0] = MBOX_SET_ACT_NEG_STATE;
1234 MBSINIT(&mbs, MBOX_SET_ACT_NEG_STATE, MBLOGNONE, 0);
1298 mbs.param[1] =
1299 (sdp_chan0->isp_req_ack_active_neg << 4) |
1300 (sdp_chan0->isp_data_line_active_neg << 5);
1301 mbs.param[2] =
1302 (sdp_chan1->isp_req_ack_active_neg << 4) |
1303 (sdp_chan1->isp_data_line_active_neg << 5);
1235 mbs.param[1] =
1236 (sdp_chan0->isp_req_ack_active_neg << 4) |
1237 (sdp_chan0->isp_data_line_active_neg << 5);
1238 mbs.param[2] =
1239 (sdp_chan1->isp_req_ack_active_neg << 4) |
1240 (sdp_chan1->isp_data_line_active_neg << 5);
1304 mbs.logval = MBLOGNONE;
1305 isp_mboxcmd(isp, &mbs);
1306 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1307 isp_prt(isp, ISP_LOGERR,
1308 "failed to set active negation state (%d,%d), (%d,%d)",
1309 sdp_chan0->isp_req_ack_active_neg,
1310 sdp_chan0->isp_data_line_active_neg,
1311 sdp_chan1->isp_req_ack_active_neg,
1312 sdp_chan1->isp_data_line_active_neg);
1313 /*
1314 * But don't return.
1315 */
1316 }
1317
1318 /*
1319 * Set the Tag Aging limit
1320 */
1241 isp_mboxcmd(isp, &mbs);
1242 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1243 isp_prt(isp, ISP_LOGERR,
1244 "failed to set active negation state (%d,%d), (%d,%d)",
1245 sdp_chan0->isp_req_ack_active_neg,
1246 sdp_chan0->isp_data_line_active_neg,
1247 sdp_chan1->isp_req_ack_active_neg,
1248 sdp_chan1->isp_data_line_active_neg);
1249 /*
1250 * But don't return.
1251 */
1252 }
1253
1254 /*
1255 * Set the Tag Aging limit
1256 */
1321 MEMZERO(&mbs, sizeof (mbs));
1322 mbs.param[0] = MBOX_SET_TAG_AGE_LIMIT;
1257 MBSINIT(&mbs, MBOX_SET_TAG_AGE_LIMIT, MBLOGALL, 0);
1323 mbs.param[1] = sdp_chan0->isp_tag_aging;
1324 mbs.param[2] = sdp_chan1->isp_tag_aging;
1258 mbs.param[1] = sdp_chan0->isp_tag_aging;
1259 mbs.param[2] = sdp_chan1->isp_tag_aging;
1325 mbs.logval = MBLOGALL;
1326 isp_mboxcmd(isp, &mbs);
1327 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1328 isp_prt(isp, ISP_LOGERR, "failed to set tag age limit (%d,%d)",
1329 sdp_chan0->isp_tag_aging, sdp_chan1->isp_tag_aging);
1330 return;
1331 }
1332
1333 /*
1334 * Set selection timeout.
1335 */
1260 isp_mboxcmd(isp, &mbs);
1261 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1262 isp_prt(isp, ISP_LOGERR, "failed to set tag age limit (%d,%d)",
1263 sdp_chan0->isp_tag_aging, sdp_chan1->isp_tag_aging);
1264 return;
1265 }
1266
1267 /*
1268 * Set selection timeout.
1269 */
1336 MEMZERO(&mbs, sizeof (mbs));
1337 mbs.param[0] = MBOX_SET_SELECT_TIMEOUT;
1270 MBSINIT(&mbs, MBOX_SET_SELECT_TIMEOUT, MBLOGALL, 0);
1338 mbs.param[1] = sdp_chan0->isp_selection_timeout;
1339 mbs.param[2] = sdp_chan1->isp_selection_timeout;
1271 mbs.param[1] = sdp_chan0->isp_selection_timeout;
1272 mbs.param[2] = sdp_chan1->isp_selection_timeout;
1340 mbs.logval = MBLOGALL;
1341 isp_mboxcmd(isp, &mbs);
1342 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1343 return;
1344 }
1345
1346 /* now do per-channel settings */
1347 isp_scsi_channel_init(isp, 0);
1348 if (IS_DUALBUS(isp))
1349 isp_scsi_channel_init(isp, 1);
1350
1351 /*
1352 * Now enable request/response queues
1353 */
1354
1355 if (IS_ULTRA2(isp) || IS_1240(isp)) {
1273 isp_mboxcmd(isp, &mbs);
1274 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1275 return;
1276 }
1277
1278 /* now do per-channel settings */
1279 isp_scsi_channel_init(isp, 0);
1280 if (IS_DUALBUS(isp))
1281 isp_scsi_channel_init(isp, 1);
1282
1283 /*
1284 * Now enable request/response queues
1285 */
1286
1287 if (IS_ULTRA2(isp) || IS_1240(isp)) {
1356 MEMZERO(&mbs, sizeof (mbs));
1357 mbs.param[0] = MBOX_INIT_RES_QUEUE_A64;
1288 MBSINIT(&mbs, MBOX_INIT_RES_QUEUE_A64, MBLOGALL, 0);
1358 mbs.param[1] = RESULT_QUEUE_LEN(isp);
1359 mbs.param[2] = DMA_WD1(isp->isp_result_dma);
1360 mbs.param[3] = DMA_WD0(isp->isp_result_dma);
1361 mbs.param[4] = 0;
1362 mbs.param[6] = DMA_WD3(isp->isp_result_dma);
1363 mbs.param[7] = DMA_WD2(isp->isp_result_dma);
1289 mbs.param[1] = RESULT_QUEUE_LEN(isp);
1290 mbs.param[2] = DMA_WD1(isp->isp_result_dma);
1291 mbs.param[3] = DMA_WD0(isp->isp_result_dma);
1292 mbs.param[4] = 0;
1293 mbs.param[6] = DMA_WD3(isp->isp_result_dma);
1294 mbs.param[7] = DMA_WD2(isp->isp_result_dma);
1364 mbs.logval = MBLOGALL;
1365 isp_mboxcmd(isp, &mbs);
1366 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1367 return;
1368 }
1369 isp->isp_residx = mbs.param[5];
1370
1295 isp_mboxcmd(isp, &mbs);
1296 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1297 return;
1298 }
1299 isp->isp_residx = mbs.param[5];
1300
1371 MEMZERO(&mbs, sizeof (mbs));
1372 mbs.param[0] = MBOX_INIT_REQ_QUEUE_A64;
1301 MBSINIT(&mbs, MBOX_INIT_REQ_QUEUE_A64, MBLOGALL, 0);
1373 mbs.param[1] = RQUEST_QUEUE_LEN(isp);
1374 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
1375 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
1376 mbs.param[5] = 0;
1377 mbs.param[6] = DMA_WD3(isp->isp_result_dma);
1378 mbs.param[7] = DMA_WD2(isp->isp_result_dma);
1302 mbs.param[1] = RQUEST_QUEUE_LEN(isp);
1303 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
1304 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
1305 mbs.param[5] = 0;
1306 mbs.param[6] = DMA_WD3(isp->isp_result_dma);
1307 mbs.param[7] = DMA_WD2(isp->isp_result_dma);
1379 mbs.logval = MBLOGALL;
1380 isp_mboxcmd(isp, &mbs);
1381 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1382 return;
1383 }
1384 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4];
1385 } else {
1308 isp_mboxcmd(isp, &mbs);
1309 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1310 return;
1311 }
1312 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4];
1313 } else {
1386 MEMZERO(&mbs, sizeof (mbs));
1387 mbs.param[0] = MBOX_INIT_RES_QUEUE;
1314 MBSINIT(&mbs, MBOX_INIT_RES_QUEUE, MBLOGALL, 0);
1388 mbs.param[1] = RESULT_QUEUE_LEN(isp);
1389 mbs.param[2] = DMA_WD1(isp->isp_result_dma);
1390 mbs.param[3] = DMA_WD0(isp->isp_result_dma);
1391 mbs.param[4] = 0;
1315 mbs.param[1] = RESULT_QUEUE_LEN(isp);
1316 mbs.param[2] = DMA_WD1(isp->isp_result_dma);
1317 mbs.param[3] = DMA_WD0(isp->isp_result_dma);
1318 mbs.param[4] = 0;
1392 mbs.logval = MBLOGALL;
1393 isp_mboxcmd(isp, &mbs);
1394 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1395 return;
1396 }
1397 isp->isp_residx = mbs.param[5];
1398
1319 isp_mboxcmd(isp, &mbs);
1320 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1321 return;
1322 }
1323 isp->isp_residx = mbs.param[5];
1324
1399 MEMZERO(&mbs, sizeof (mbs));
1400 mbs.param[0] = MBOX_INIT_REQ_QUEUE;
1325 MBSINIT(&mbs, MBOX_INIT_REQ_QUEUE, MBLOGALL, 0);
1401 mbs.param[1] = RQUEST_QUEUE_LEN(isp);
1402 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
1403 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
1404 mbs.param[5] = 0;
1326 mbs.param[1] = RQUEST_QUEUE_LEN(isp);
1327 mbs.param[2] = DMA_WD1(isp->isp_rquest_dma);
1328 mbs.param[3] = DMA_WD0(isp->isp_rquest_dma);
1329 mbs.param[5] = 0;
1405 mbs.logval = MBLOGALL;
1406 isp_mboxcmd(isp, &mbs);
1407 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1408 return;
1409 }
1410 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4];
1411 }
1412
1413 /*
1414 * Turn on Fast Posting, LVD transitions
1415 *
1416 * Ultra2 F/W always has had fast posting (and LVD transitions)
1417 *
1418 * Ultra and older (i.e., SBus) cards may not. It's just safer
1419 * to assume not for them.
1420 */
1421
1330 isp_mboxcmd(isp, &mbs);
1331 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1332 return;
1333 }
1334 isp->isp_reqidx = isp->isp_reqodx = mbs.param[4];
1335 }
1336
1337 /*
1338 * Turn on Fast Posting, LVD transitions
1339 *
1340 * Ultra2 F/W always has had fast posting (and LVD transitions)
1341 *
1342 * Ultra and older (i.e., SBus) cards may not. It's just safer
1343 * to assume not for them.
1344 */
1345
1422 MEMZERO(&mbs, sizeof (mbs));
1423 mbs.param[0] = MBOX_SET_FW_FEATURES;
1424 mbs.param[1] = 0;
1346 MBSINIT(&mbs, MBOX_SET_FW_FEATURES, MBLOGALL, 0);
1425 if (IS_ULTRA2(isp))
1426 mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
1427#ifndef ISP_NO_RIO
1428 if (IS_ULTRA2(isp) || IS_1240(isp))
1429 mbs.param[1] |= FW_FEATURE_RIO_16BIT;
1430#else
1431 if (IS_ULTRA2(isp) || IS_1240(isp))
1432 mbs.param[1] |= FW_FEATURE_FAST_POST;
1433#endif
1434 if (mbs.param[1] != 0) {
1435 uint16_t sfeat = mbs.param[1];
1347 if (IS_ULTRA2(isp))
1348 mbs.param[1] |= FW_FEATURE_LVD_NOTIFY;
1349#ifndef ISP_NO_RIO
1350 if (IS_ULTRA2(isp) || IS_1240(isp))
1351 mbs.param[1] |= FW_FEATURE_RIO_16BIT;
1352#else
1353 if (IS_ULTRA2(isp) || IS_1240(isp))
1354 mbs.param[1] |= FW_FEATURE_FAST_POST;
1355#endif
1356 if (mbs.param[1] != 0) {
1357 uint16_t sfeat = mbs.param[1];
1436 mbs.logval = MBLOGALL;
1437 isp_mboxcmd(isp, &mbs);
1438 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1439 isp_prt(isp, ISP_LOGINFO,
1440 "Enabled FW features (0x%x)", sfeat);
1441 }
1442 }
1443
1358 isp_mboxcmd(isp, &mbs);
1359 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
1360 isp_prt(isp, ISP_LOGINFO,
1361 "Enabled FW features (0x%x)", sfeat);
1362 }
1363 }
1364
1444 /*
1445 * Let the outer layers decide whether to issue a SCSI bus reset.
1446 */
1447 isp->isp_state = ISP_INITSTATE;
1448}
1449
1450static void
1365 isp->isp_state = ISP_INITSTATE;
1366}
1367
1368static void
1451isp_scsi_channel_init(ispsoftc_t *isp, int channel)
1369isp_scsi_channel_init(ispsoftc_t *isp, int chan)
1452{
1453 sdparam *sdp;
1454 mbreg_t mbs;
1455 int tgt;
1456
1370{
1371 sdparam *sdp;
1372 mbreg_t mbs;
1373 int tgt;
1374
1457 sdp = isp->isp_param;
1458 sdp += channel;
1375 sdp = SDPARAM(isp, chan);
1459
1460 /*
1461 * Set (possibly new) Initiator ID.
1462 */
1376
1377 /*
1378 * Set (possibly new) Initiator ID.
1379 */
1463 MEMZERO(&mbs, sizeof (mbs));
1464 mbs.param[0] = MBOX_SET_INIT_SCSI_ID;
1465 mbs.param[1] = (channel << 7) | sdp->isp_initiator_id;
1466 mbs.logval = MBLOGALL;
1380 MBSINIT(&mbs, MBOX_SET_INIT_SCSI_ID, MBLOGALL, 0);
1381 mbs.param[1] = (chan << 7) | sdp->isp_initiator_id;
1467 isp_mboxcmd(isp, &mbs);
1468 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1469 return;
1470 }
1382 isp_mboxcmd(isp, &mbs);
1383 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1384 return;
1385 }
1471 isp_prt(isp, ISP_LOGINFO, "Initiator ID is %d on Channel %d",
1472 sdp->isp_initiator_id, channel);
1386 isp_prt(isp, ISP_LOGINFO, "Chan %d Initiator ID is %d",
1387 chan, sdp->isp_initiator_id);
1473
1474
1475 /*
1476 * Set current per-target parameters to an initial safe minimum.
1477 */
1478 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
1479 int lun;
1480 uint16_t sdf;

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

1500 * internal table to decide how to respond to negotiations,
1501 * so if we've said "let's be safe" for ID X, and ID X
1502 * selects *us*, the negotiations will back to 'safe'
1503 * (as in narrow/async). What the f/w *should* do is
1504 * use the initiator id settings to decide how to respond.
1505 */
1506 sdp->isp_devparam[tgt].goal_flags = sdf = DPARM_DEFAULT;
1507#endif
1388
1389
1390 /*
1391 * Set current per-target parameters to an initial safe minimum.
1392 */
1393 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
1394 int lun;
1395 uint16_t sdf;

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

1415 * internal table to decide how to respond to negotiations,
1416 * so if we've said "let's be safe" for ID X, and ID X
1417 * selects *us*, the negotiations will back to 'safe'
1418 * (as in narrow/async). What the f/w *should* do is
1419 * use the initiator id settings to decide how to respond.
1420 */
1421 sdp->isp_devparam[tgt].goal_flags = sdf = DPARM_DEFAULT;
1422#endif
1508 MEMZERO(&mbs, sizeof (mbs));
1509 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
1510 mbs.param[1] = (channel << 15) | (tgt << 8);
1423 MBSINIT(&mbs, MBOX_SET_TARGET_PARAMS, MBLOGNONE, 0);
1424 mbs.param[1] = (chan << 15) | (tgt << 8);
1511 mbs.param[2] = sdf;
1512 if ((sdf & DPARM_SYNC) == 0) {
1513 mbs.param[3] = 0;
1514 } else {
1515 mbs.param[3] =
1516 (sdp->isp_devparam[tgt].goal_offset << 8) |
1517 (sdp->isp_devparam[tgt].goal_period);
1518 }
1519 isp_prt(isp, ISP_LOGDEBUG0,
1520 "Initial Settings bus%d tgt%d flags 0x%x off 0x%x per 0x%x",
1425 mbs.param[2] = sdf;
1426 if ((sdf & DPARM_SYNC) == 0) {
1427 mbs.param[3] = 0;
1428 } else {
1429 mbs.param[3] =
1430 (sdp->isp_devparam[tgt].goal_offset << 8) |
1431 (sdp->isp_devparam[tgt].goal_period);
1432 }
1433 isp_prt(isp, ISP_LOGDEBUG0,
1434 "Initial Settings bus%d tgt%d flags 0x%x off 0x%x per 0x%x",
1521 channel, tgt, mbs.param[2], mbs.param[3] >> 8,
1435 chan, tgt, mbs.param[2], mbs.param[3] >> 8,
1522 mbs.param[3] & 0xff);
1436 mbs.param[3] & 0xff);
1523 mbs.logval = MBLOGNONE;
1524 isp_mboxcmd(isp, &mbs);
1525 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1526 sdf = DPARM_SAFE_DFLT;
1437 isp_mboxcmd(isp, &mbs);
1438 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1439 sdf = DPARM_SAFE_DFLT;
1527 MEMZERO(&mbs, sizeof (mbs));
1528 mbs.param[0] = MBOX_SET_TARGET_PARAMS;
1529 mbs.param[1] = (tgt << 8) | (channel << 15);
1440 MBSINIT(&mbs, MBOX_SET_TARGET_PARAMS, MBLOGALL, 0);
1441 mbs.param[1] = (tgt << 8) | (chan << 15);
1530 mbs.param[2] = sdf;
1531 mbs.param[3] = 0;
1442 mbs.param[2] = sdf;
1443 mbs.param[3] = 0;
1532 mbs.logval = MBLOGALL;
1533 isp_mboxcmd(isp, &mbs);
1534 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1535 continue;
1536 }
1537 }
1538
1539 /*
1540 * We don't update any information directly from the f/w
1541 * because we need to run at least one command to cause a
1542 * new state to be latched up. So, we just assume that we
1543 * converge to the values we just had set.
1544 *
1545 * Ensure that we don't believe tagged queuing is enabled yet.
1546 * It turns out that sometimes the ISP just ignores our
1547 * attempts to set parameters for devices that it hasn't
1548 * seen yet.
1549 */
1550 sdp->isp_devparam[tgt].actv_flags = sdf & ~DPARM_TQING;
1551 for (lun = 0; lun < (int) isp->isp_maxluns; lun++) {
1444 isp_mboxcmd(isp, &mbs);
1445 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1446 continue;
1447 }
1448 }
1449
1450 /*
1451 * We don't update any information directly from the f/w
1452 * because we need to run at least one command to cause a
1453 * new state to be latched up. So, we just assume that we
1454 * converge to the values we just had set.
1455 *
1456 * Ensure that we don't believe tagged queuing is enabled yet.
1457 * It turns out that sometimes the ISP just ignores our
1458 * attempts to set parameters for devices that it hasn't
1459 * seen yet.
1460 */
1461 sdp->isp_devparam[tgt].actv_flags = sdf & ~DPARM_TQING;
1462 for (lun = 0; lun < (int) isp->isp_maxluns; lun++) {
1552 MEMZERO(&mbs, sizeof (mbs));
1553 mbs.param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
1554 mbs.param[1] = (channel << 15) | (tgt << 8) | lun;
1463 MBSINIT(&mbs, MBOX_SET_DEV_QUEUE_PARAMS, MBLOGALL, 0);
1464 mbs.param[1] = (chan << 15) | (tgt << 8) | lun;
1555 mbs.param[2] = sdp->isp_max_queue_depth;
1556 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle;
1465 mbs.param[2] = sdp->isp_max_queue_depth;
1466 mbs.param[3] = sdp->isp_devparam[tgt].exc_throttle;
1557 mbs.logval = MBLOGALL;
1558 isp_mboxcmd(isp, &mbs);
1559 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1560 break;
1561 }
1562 }
1563 }
1564 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
1565 if (sdp->isp_devparam[tgt].dev_refresh) {
1467 isp_mboxcmd(isp, &mbs);
1468 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1469 break;
1470 }
1471 }
1472 }
1473 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
1474 if (sdp->isp_devparam[tgt].dev_refresh) {
1566 isp->isp_sendmarker |= (1 << channel);
1567 isp->isp_update |= (1 << channel);
1475 sdp->sendmarker = 1;
1476 sdp->update = 1;
1568 break;
1569 }
1570 }
1571}
1572
1573/*
1574 * Fibre Channel specific initialization.
1575 */
1576static void
1577isp_fibre_init(ispsoftc_t *isp)
1578{
1579 fcparam *fcp;
1580 isp_icb_t local, *icbp = &local;
1581 mbreg_t mbs;
1582 int ownloopid;
1477 break;
1478 }
1479 }
1480}
1481
1482/*
1483 * Fibre Channel specific initialization.
1484 */
1485static void
1486isp_fibre_init(ispsoftc_t *isp)
1487{
1488 fcparam *fcp;
1489 isp_icb_t local, *icbp = &local;
1490 mbreg_t mbs;
1491 int ownloopid;
1583 uint64_t nwwn, pwwn;
1584
1492
1585 fcp = isp->isp_param;
1493 /*
1494 * We only support one channel on non-24XX cards
1495 */
1496 fcp = FCPARAM(isp, 0);
1497 if (fcp->role == ISP_ROLE_NONE) {
1498 isp->isp_state = ISP_INITSTATE;
1499 return;
1500 }
1586
1501
1587 MEMZERO(icbp, sizeof (*icbp));
1502 ISP_MEMZERO(icbp, sizeof (*icbp));
1588 icbp->icb_version = ICB_VERSION1;
1589 icbp->icb_fwoptions = fcp->isp_fwoptions;
1590
1591 /*
1592 * Firmware Options are either retrieved from NVRAM or
1593 * are patched elsewhere. We check them for sanity here
1594 * and make changes based on board revision, but otherwise
1595 * let others decide policy.

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

1614 /*
1615 * Insist on Port Database Update Async notifications
1616 */
1617 icbp->icb_fwoptions |= ICBOPT_PDBCHANGE_AE;
1618
1619 /*
1620 * Make sure that target role reflects into fwoptions.
1621 */
1503 icbp->icb_version = ICB_VERSION1;
1504 icbp->icb_fwoptions = fcp->isp_fwoptions;
1505
1506 /*
1507 * Firmware Options are either retrieved from NVRAM or
1508 * are patched elsewhere. We check them for sanity here
1509 * and make changes based on board revision, but otherwise
1510 * let others decide policy.

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

1529 /*
1530 * Insist on Port Database Update Async notifications
1531 */
1532 icbp->icb_fwoptions |= ICBOPT_PDBCHANGE_AE;
1533
1534 /*
1535 * Make sure that target role reflects into fwoptions.
1536 */
1622 if (isp->isp_role & ISP_ROLE_TARGET) {
1537 if (fcp->role & ISP_ROLE_TARGET) {
1623 icbp->icb_fwoptions |= ICBOPT_TGT_ENABLE;
1624 } else {
1625 icbp->icb_fwoptions &= ~ICBOPT_TGT_ENABLE;
1626 }
1627
1538 icbp->icb_fwoptions |= ICBOPT_TGT_ENABLE;
1539 } else {
1540 icbp->icb_fwoptions &= ~ICBOPT_TGT_ENABLE;
1541 }
1542
1628 if (isp->isp_role & ISP_ROLE_INITIATOR) {
1543 if (fcp->role & ISP_ROLE_INITIATOR) {
1629 icbp->icb_fwoptions &= ~ICBOPT_INI_DISABLE;
1630 } else {
1631 icbp->icb_fwoptions |= ICBOPT_INI_DISABLE;
1632 }
1633
1544 icbp->icb_fwoptions &= ~ICBOPT_INI_DISABLE;
1545 } else {
1546 icbp->icb_fwoptions |= ICBOPT_INI_DISABLE;
1547 }
1548
1634 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen;
1549 icbp->icb_maxfrmlen = DEFAULT_FRAMESIZE(isp);
1635 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN ||
1636 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
1637 isp_prt(isp, ISP_LOGERR,
1638 "bad frame length (%d) from NVRAM- using %d",
1550 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN ||
1551 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
1552 isp_prt(isp, ISP_LOGERR,
1553 "bad frame length (%d) from NVRAM- using %d",
1639 fcp->isp_maxfrmlen, ICB_DFLT_FRMLEN);
1554 DEFAULT_FRAMESIZE(isp), ICB_DFLT_FRMLEN);
1640 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
1641 }
1642 icbp->icb_maxalloc = fcp->isp_maxalloc;
1643 if (icbp->icb_maxalloc < 1) {
1644 isp_prt(isp, ISP_LOGERR,
1645 "bad maximum allocation (%d)- using 16", fcp->isp_maxalloc);
1646 icbp->icb_maxalloc = 16;
1647 }
1555 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
1556 }
1557 icbp->icb_maxalloc = fcp->isp_maxalloc;
1558 if (icbp->icb_maxalloc < 1) {
1559 isp_prt(isp, ISP_LOGERR,
1560 "bad maximum allocation (%d)- using 16", fcp->isp_maxalloc);
1561 icbp->icb_maxalloc = 16;
1562 }
1648 icbp->icb_execthrottle = fcp->isp_execthrottle;
1563 icbp->icb_execthrottle = DEFAULT_EXEC_THROTTLE(isp);
1649 if (icbp->icb_execthrottle < 1) {
1650 isp_prt(isp, ISP_LOGERR,
1564 if (icbp->icb_execthrottle < 1) {
1565 isp_prt(isp, ISP_LOGERR,
1651 "bad execution throttle of %d- using 16",
1652 fcp->isp_execthrottle);
1566 "bad execution throttle of %d- using %d",
1567 DEFAULT_EXEC_THROTTLE(isp), ICB_DFLT_THROTTLE);
1653 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1654 }
1655 icbp->icb_retry_delay = fcp->isp_retry_delay;
1656 icbp->icb_retry_count = fcp->isp_retry_count;
1657 icbp->icb_hardaddr = fcp->isp_loopid;
1658 ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0;
1568 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1569 }
1570 icbp->icb_retry_delay = fcp->isp_retry_delay;
1571 icbp->icb_retry_count = fcp->isp_retry_count;
1572 icbp->icb_hardaddr = fcp->isp_loopid;
1573 ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0;
1659 if (icbp->icb_hardaddr > 125) {
1574 if (icbp->icb_hardaddr >= LOCAL_LOOP_LIM) {
1660 icbp->icb_hardaddr = 0;
1661 ownloopid = 0;
1662 }
1663
1664 /*
1665 * Our life seems so much better with 2200s and later with
1666 * the latest f/w if we set Hard Address.
1667 */
1668 if (ownloopid || ISP_FW_NEWER_THAN(isp, 2, 2, 5)) {
1669 icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS;
1670 }
1671
1672 /*
1673 * Right now we just set extended options to prefer point-to-point
1674 * over loop based upon some soft config options.
1575 icbp->icb_hardaddr = 0;
1576 ownloopid = 0;
1577 }
1578
1579 /*
1580 * Our life seems so much better with 2200s and later with
1581 * the latest f/w if we set Hard Address.
1582 */
1583 if (ownloopid || ISP_FW_NEWER_THAN(isp, 2, 2, 5)) {
1584 icbp->icb_fwoptions |= ICBOPT_HARD_ADDRESS;
1585 }
1586
1587 /*
1588 * Right now we just set extended options to prefer point-to-point
1589 * over loop based upon some soft config options.
1675 *
1590 *
1676 * NB: for the 2300, ICBOPT_EXTENDED is required.
1677 */
1678 if (IS_2200(isp) || IS_23XX(isp)) {
1679 icbp->icb_fwoptions |= ICBOPT_EXTENDED;
1680 /*
1681 * Prefer or force Point-To-Point instead Loop?
1682 */
1591 * NB: for the 2300, ICBOPT_EXTENDED is required.
1592 */
1593 if (IS_2200(isp) || IS_23XX(isp)) {
1594 icbp->icb_fwoptions |= ICBOPT_EXTENDED;
1595 /*
1596 * Prefer or force Point-To-Point instead Loop?
1597 */
1683 switch(isp->isp_confopts & ISP_CFG_PORT_PREF) {
1598 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
1684 case ISP_CFG_NPORT:
1685 icbp->icb_xfwoptions |= ICBXOPT_PTP_2_LOOP;
1686 break;
1687 case ISP_CFG_NPORT_ONLY:
1688 icbp->icb_xfwoptions |= ICBXOPT_PTP_ONLY;
1689 break;
1690 case ISP_CFG_LPORT_ONLY:
1691 icbp->icb_xfwoptions |= ICBXOPT_LOOP_ONLY;
1692 break;
1693 default:
1694 icbp->icb_xfwoptions |= ICBXOPT_LOOP_2_PTP;
1695 break;
1696 }
1697 if (IS_2200(isp)) {
1599 case ISP_CFG_NPORT:
1600 icbp->icb_xfwoptions |= ICBXOPT_PTP_2_LOOP;
1601 break;
1602 case ISP_CFG_NPORT_ONLY:
1603 icbp->icb_xfwoptions |= ICBXOPT_PTP_ONLY;
1604 break;
1605 case ISP_CFG_LPORT_ONLY:
1606 icbp->icb_xfwoptions |= ICBXOPT_LOOP_ONLY;
1607 break;
1608 default:
1609 icbp->icb_xfwoptions |= ICBXOPT_LOOP_2_PTP;
1610 break;
1611 }
1612 if (IS_2200(isp)) {
1613 /*
1614 * There seems to just be too much breakage here
1615 * with RIO and Fast Posting- it probably actually
1616 * works okay but this driver is messing it up.
1617 * This card is really ancient by now, so let's
1618 * just opt for safety and not use the feature.
1619 */
1620#if 0
1621 if (ISP_FW_NEWER_THAN(isp, 1, 17, 0)) {
1622 icbp->icb_xfwoptions |= ICBXOPT_RIO_16BIT;
1623 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1624 icbp->icb_racctimer = 4;
1625 icbp->icb_idelaytimer = 8;
1626 } else {
1627 icbp->icb_fwoptions |= ICBOPT_FAST_POST;
1628 }
1629#else
1630 icbp->icb_xfwoptions &= ~ICBXOPT_RIO_16BIT;
1698 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1631 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1632#endif
1699 } else {
1700 /*
1701 * QLogic recommends that FAST Posting be turned
1702 * off for 23XX cards and instead allow the HBA
1703 * to write response queue entries and interrupt
1704 * after a delay (ZIO).
1705 */
1706 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1633 } else {
1634 /*
1635 * QLogic recommends that FAST Posting be turned
1636 * off for 23XX cards and instead allow the HBA
1637 * to write response queue entries and interrupt
1638 * after a delay (ZIO).
1639 */
1640 icbp->icb_fwoptions &= ~ICBOPT_FAST_POST;
1707 if ((fcp->isp_xfwoptions & ICBXOPT_TIMER_MASK) ==
1708 ICBXOPT_ZIO) {
1641 if ((fcp->isp_xfwoptions & ICBXOPT_TIMER_MASK) == ICBXOPT_ZIO) {
1709 icbp->icb_xfwoptions |= ICBXOPT_ZIO;
1710 icbp->icb_idelaytimer = 10;
1711 }
1712 if (isp->isp_confopts & ISP_CFG_ONEGB) {
1713 icbp->icb_zfwoptions |= ICBZOPT_RATE_ONEGB;
1714 } else if (isp->isp_confopts & ISP_CFG_TWOGB) {
1715 icbp->icb_zfwoptions |= ICBZOPT_RATE_TWOGB;
1716 } else {

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

1728 * XXX: Probably okay for newer 2100 f/w too.
1729 */
1730 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1731 /*
1732 * Turn on LIP F8 async event (1)
1733 * Turn on generate AE 8013 on all LIP Resets (2)
1734 * Disable LIP F7 switching (8)
1735 */
1642 icbp->icb_xfwoptions |= ICBXOPT_ZIO;
1643 icbp->icb_idelaytimer = 10;
1644 }
1645 if (isp->isp_confopts & ISP_CFG_ONEGB) {
1646 icbp->icb_zfwoptions |= ICBZOPT_RATE_ONEGB;
1647 } else if (isp->isp_confopts & ISP_CFG_TWOGB) {
1648 icbp->icb_zfwoptions |= ICBZOPT_RATE_TWOGB;
1649 } else {

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

1661 * XXX: Probably okay for newer 2100 f/w too.
1662 */
1663 if (ISP_FW_NEWER_THAN(isp, 2, 26, 0)) {
1664 /*
1665 * Turn on LIP F8 async event (1)
1666 * Turn on generate AE 8013 on all LIP Resets (2)
1667 * Disable LIP F7 switching (8)
1668 */
1736 MEMZERO(&mbs, sizeof (mbs));
1737 mbs.param[0] = MBOX_SET_FIRMWARE_OPTIONS;
1669 MBSINIT(&mbs, MBOX_SET_FIRMWARE_OPTIONS, MBLOGALL, 0);
1738 mbs.param[1] = 0xb;
1739 mbs.param[2] = 0;
1740 mbs.param[3] = 0;
1670 mbs.param[1] = 0xb;
1671 mbs.param[2] = 0;
1672 mbs.param[3] = 0;
1741 mbs.logval = MBLOGALL;
1742 isp_mboxcmd(isp, &mbs);
1743 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1744 return;
1745 }
1746 }
1747 icbp->icb_logintime = ICB_LOGIN_TOV;
1748 icbp->icb_lunetimeout = ICB_LUN_ENABLE_TOV;
1749
1673 isp_mboxcmd(isp, &mbs);
1674 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1675 return;
1676 }
1677 }
1678 icbp->icb_logintime = ICB_LOGIN_TOV;
1679 icbp->icb_lunetimeout = ICB_LUN_ENABLE_TOV;
1680
1750 nwwn = ISP_NODEWWN(isp);
1751 pwwn = ISP_PORTWWN(isp);
1752 if (nwwn && pwwn) {
1681 if (fcp->isp_wwnn && fcp->isp_wwpn && (fcp->isp_wwnn >> 60) != 2) {
1753 icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS;
1682 icbp->icb_fwoptions |= ICBOPT_BOTH_WWNS;
1754 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, nwwn);
1755 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn);
1683 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwnn);
1684 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1756 isp_prt(isp, ISP_LOGDEBUG1,
1757 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x",
1685 isp_prt(isp, ISP_LOGDEBUG1,
1686 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x",
1758 ((uint32_t) (nwwn >> 32)),
1759 ((uint32_t) (nwwn & 0xffffffff)),
1760 ((uint32_t) (pwwn >> 32)),
1761 ((uint32_t) (pwwn & 0xffffffff)));
1762 } else if (pwwn) {
1687 ((uint32_t) (fcp->isp_wwnn >> 32)),
1688 ((uint32_t) (fcp->isp_wwnn)),
1689 ((uint32_t) (fcp->isp_wwpn >> 32)),
1690 ((uint32_t) (fcp->isp_wwpn)));
1691 } else if (fcp->isp_wwpn) {
1763 icbp->icb_fwoptions &= ~ICBOPT_BOTH_WWNS;
1692 icbp->icb_fwoptions &= ~ICBOPT_BOTH_WWNS;
1764 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn);
1693 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1765 isp_prt(isp, ISP_LOGDEBUG1,
1766 "Setting ICB Port 0x%08x%08x",
1694 isp_prt(isp, ISP_LOGDEBUG1,
1695 "Setting ICB Port 0x%08x%08x",
1767 ((uint32_t) (pwwn >> 32)),
1768 ((uint32_t) (pwwn & 0xffffffff)));
1696 ((uint32_t) (fcp->isp_wwpn >> 32)),
1697 ((uint32_t) (fcp->isp_wwpn)));
1769 } else {
1770 isp_prt(isp, ISP_LOGERR, "No valid WWNs to use");
1771 return;
1772 }
1773 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1774 if (icbp->icb_rqstqlen < 1) {
1775 isp_prt(isp, ISP_LOGERR, "bad request queue length");
1776 }

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

1782 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
1783 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1784 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1785 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1786 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1787 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1788 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1789
1698 } else {
1699 isp_prt(isp, ISP_LOGERR, "No valid WWNs to use");
1700 return;
1701 }
1702 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1703 if (icbp->icb_rqstqlen < 1) {
1704 isp_prt(isp, ISP_LOGERR, "bad request queue length");
1705 }

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

1711 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
1712 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1713 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1714 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1715 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1716 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1717 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1718
1719 if (FC_SCRATCH_ACQUIRE(isp, 0)) {
1720 isp_prt(isp, ISP_LOGERR, sacq);
1721 return;
1722 }
1790 isp_prt(isp, ISP_LOGDEBUG0,
1791 "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
1792 icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
1793
1723 isp_prt(isp, ISP_LOGDEBUG0,
1724 "isp_fibre_init: fwopt 0x%x xfwopt 0x%x zfwopt 0x%x",
1725 icbp->icb_fwoptions, icbp->icb_xfwoptions, icbp->icb_zfwoptions);
1726
1794 FC_SCRATCH_ACQUIRE(isp);
1795 isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
1796
1797 /*
1798 * Init the firmware
1799 */
1727 isp_put_icb(isp, icbp, (isp_icb_t *)fcp->isp_scratch);
1728
1729 /*
1730 * Init the firmware
1731 */
1800 MEMZERO(&mbs, sizeof (mbs));
1801 mbs.param[0] = MBOX_INIT_FIRMWARE;
1732 MBSINIT(&mbs, MBOX_INIT_FIRMWARE, MBLOGALL, 30000000);
1802 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1803 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1804 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
1805 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
1806 mbs.logval = MBLOGALL;
1733 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
1734 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
1735 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
1736 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
1737 mbs.logval = MBLOGALL;
1807 mbs.timeout = 30 * 1000000;
1808 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)",
1809 fcp->isp_scratch, (uint32_t) ((uint64_t)fcp->isp_scdma >> 32),
1810 (uint32_t) fcp->isp_scdma);
1811 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp));
1812 isp_mboxcmd(isp, &mbs);
1738 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %p (%08x%08x)",
1739 fcp->isp_scratch, (uint32_t) ((uint64_t)fcp->isp_scdma >> 32),
1740 (uint32_t) fcp->isp_scdma);
1741 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp));
1742 isp_mboxcmd(isp, &mbs);
1813 FC_SCRATCH_RELEASE(isp);
1743 FC_SCRATCH_RELEASE(isp, 0);
1814 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1815 isp_print_bytes(isp, "isp_fibre_init", sizeof (*icbp), icbp);
1816 return;
1817 }
1818 isp->isp_reqidx = 0;
1819 isp->isp_reqodx = 0;
1820 isp->isp_residx = 0;
1821

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

1826}
1827
1828static void
1829isp_fibre_init_2400(ispsoftc_t *isp)
1830{
1831 fcparam *fcp;
1832 isp_icb_2400_t local, *icbp = &local;
1833 mbreg_t mbs;
1744 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1745 isp_print_bytes(isp, "isp_fibre_init", sizeof (*icbp), icbp);
1746 return;
1747 }
1748 isp->isp_reqidx = 0;
1749 isp->isp_reqodx = 0;
1750 isp->isp_residx = 0;
1751

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

1756}
1757
1758static void
1759isp_fibre_init_2400(ispsoftc_t *isp)
1760{
1761 fcparam *fcp;
1762 isp_icb_2400_t local, *icbp = &local;
1763 mbreg_t mbs;
1834 int ownloopid;
1835 uint64_t nwwn, pwwn;
1764 int chan;
1836
1765
1837 fcp = isp->isp_param;
1766 /*
1767 * Check to see whether all channels have *some* kind of role
1768 */
1769 for (chan = 0; chan < isp->isp_nchan; chan++) {
1770 fcp = FCPARAM(isp, chan);
1771 if (fcp->role != ISP_ROLE_NONE) {
1772 break;
1773 }
1774 }
1775 if (chan == isp->isp_nchan) {
1776 isp_prt(isp, ISP_LOGDEBUG0, "all %d channels with role 'none'", chan);
1777 isp->isp_state = ISP_INITSTATE;
1778 return;
1779 }
1838
1839 /*
1780
1781 /*
1782 * Start with channel 0.
1783 */
1784 fcp = FCPARAM(isp, 0);
1785
1786 /*
1840 * Turn on LIP F8 async event (1)
1841 */
1787 * Turn on LIP F8 async event (1)
1788 */
1842 MEMZERO(&mbs, sizeof (mbs));
1843 mbs.param[0] = MBOX_SET_FIRMWARE_OPTIONS;
1789 MBSINIT(&mbs, MBOX_SET_FIRMWARE_OPTIONS, MBLOGALL, 0);
1844 mbs.param[1] = 1;
1790 mbs.param[1] = 1;
1845 mbs.logval = MBLOGALL;
1846 isp_mboxcmd(isp, &mbs);
1847 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1848 return;
1849 }
1850
1791 isp_mboxcmd(isp, &mbs);
1792 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1793 return;
1794 }
1795
1851 /*
1852 * XXX: This should be applied to icb- not fwoptions
1853 */
1854 if (isp->isp_role & ISP_ROLE_TARGET) {
1855 fcp->isp_fwoptions |= ICB2400_OPT1_TGT_ENABLE;
1796 ISP_MEMZERO(icbp, sizeof (*icbp));
1797 icbp->icb_fwoptions1 = fcp->isp_fwoptions;
1798 if (fcp->role & ISP_ROLE_TARGET) {
1799 icbp->icb_fwoptions1 |= ICB2400_OPT1_TGT_ENABLE;
1856 } else {
1800 } else {
1857 fcp->isp_fwoptions &= ~ICB2400_OPT1_TGT_ENABLE;
1801 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_TGT_ENABLE;
1858 }
1859
1802 }
1803
1860 if (isp->isp_role & ISP_ROLE_INITIATOR) {
1861 fcp->isp_fwoptions &= ~ICB2400_OPT1_INI_DISABLE;
1804 if (fcp->role & ISP_ROLE_INITIATOR) {
1805 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_INI_DISABLE;
1862 } else {
1806 } else {
1863 fcp->isp_fwoptions |= ICB2400_OPT1_INI_DISABLE;
1807 icbp->icb_fwoptions1 |= ICB2400_OPT1_INI_DISABLE;
1864 }
1865
1808 }
1809
1866 MEMZERO(icbp, sizeof (*icbp));
1867 icbp->icb_version = ICB_VERSION1;
1810 icbp->icb_version = ICB_VERSION1;
1868 icbp->icb_maxfrmlen = fcp->isp_maxfrmlen;
1869 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN ||
1870 icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
1871 isp_prt(isp, ISP_LOGERR,
1872 "bad frame length (%d) from NVRAM- using %d",
1873 fcp->isp_maxfrmlen, ICB_DFLT_FRMLEN);
1811 icbp->icb_maxfrmlen = DEFAULT_FRAMESIZE(isp);
1812 if (icbp->icb_maxfrmlen < ICB_MIN_FRMLEN || icbp->icb_maxfrmlen > ICB_MAX_FRMLEN) {
1813 isp_prt(isp, ISP_LOGERR, "bad frame length (%d) from NVRAM- using %d", DEFAULT_FRAMESIZE(isp), ICB_DFLT_FRMLEN);
1874 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
1875 }
1876
1814 icbp->icb_maxfrmlen = ICB_DFLT_FRMLEN;
1815 }
1816
1877 icbp->icb_execthrottle = fcp->isp_execthrottle;
1817 icbp->icb_execthrottle = DEFAULT_EXEC_THROTTLE(isp);
1878 if (icbp->icb_execthrottle < 1) {
1818 if (icbp->icb_execthrottle < 1) {
1879 isp_prt(isp, ISP_LOGERR,
1880 "bad execution throttle of %d- using 16",
1881 fcp->isp_execthrottle);
1819 isp_prt(isp, ISP_LOGERR, "bad execution throttle of %d- using %d", DEFAULT_EXEC_THROTTLE(isp), ICB_DFLT_THROTTLE);
1882 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1883 }
1884
1820 icbp->icb_execthrottle = ICB_DFLT_THROTTLE;
1821 }
1822
1885 if (isp->isp_role & ISP_ROLE_TARGET) {
1823 if (icbp->icb_fwoptions1 & ICB2400_OPT1_TGT_ENABLE) {
1886 /*
1887 * Get current resource count
1888 */
1824 /*
1825 * Get current resource count
1826 */
1889 MEMZERO(&mbs, sizeof (mbs));
1890 mbs.param[0] = MBOX_GET_RESOURCE_COUNT;
1827 MBSINIT(&mbs, MBOX_GET_RESOURCE_COUNT, MBLOGALL, 0);
1891 mbs.obits = 0x4cf;
1828 mbs.obits = 0x4cf;
1892 mbs.logval = MBLOGALL;
1893 isp_mboxcmd(isp, &mbs);
1894 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1895 return;
1896 }
1897 icbp->icb_xchgcnt = mbs.param[3];
1898 }
1899
1829 isp_mboxcmd(isp, &mbs);
1830 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
1831 return;
1832 }
1833 icbp->icb_xchgcnt = mbs.param[3];
1834 }
1835
1900 icbp->icb_fwoptions1 = fcp->isp_fwoptions;
1901
1902 icbp->icb_hardaddr = fcp->isp_loopid;
1836
1837 icbp->icb_hardaddr = fcp->isp_loopid;
1903 ownloopid = (isp->isp_confopts & ISP_CFG_OWNLOOPID) != 0;
1904 if (icbp->icb_hardaddr > 125) {
1838 if (icbp->icb_hardaddr >= LOCAL_LOOP_LIM) {
1905 icbp->icb_hardaddr = 0;
1839 icbp->icb_hardaddr = 0;
1906 ownloopid = 0;
1907 }
1840 }
1908 if (ownloopid) {
1909 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
1910 }
1911
1841
1842 /*
1843 * Force this on.
1844 */
1845 icbp->icb_fwoptions1 |= ICB2400_OPT1_HARD_ADDRESS;
1846
1912 icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
1847 icbp->icb_fwoptions2 = fcp->isp_xfwoptions;
1913 switch(isp->isp_confopts & ISP_CFG_PORT_PREF) {
1848 switch (isp->isp_confopts & ISP_CFG_PORT_PREF) {
1849#if 0
1914 case ISP_CFG_NPORT:
1850 case ISP_CFG_NPORT:
1851 /*
1852 * XXX: This causes the f/w to crash.
1853 */
1915 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1916 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_2_LOOP;
1917 break;
1854 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1855 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_2_LOOP;
1856 break;
1857#endif
1918 case ISP_CFG_NPORT_ONLY:
1919 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1920 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_ONLY;
1921 break;
1922 case ISP_CFG_LPORT_ONLY:
1923 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1924 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_ONLY;
1925 break;
1926 default:
1927 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1928 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_2_PTP;
1929 break;
1930 }
1931
1858 case ISP_CFG_NPORT_ONLY:
1859 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1860 icbp->icb_fwoptions2 |= ICB2400_OPT2_PTP_ONLY;
1861 break;
1862 case ISP_CFG_LPORT_ONLY:
1863 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1864 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_ONLY;
1865 break;
1866 default:
1867 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TOPO_MASK;
1868 icbp->icb_fwoptions2 |= ICB2400_OPT2_LOOP_2_PTP;
1869 break;
1870 }
1871
1872 /* force this on for now */
1873 icbp->icb_fwoptions2 |= ICB2400_OPT2_ZIO;
1874
1932 switch (icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK) {
1933 case ICB2400_OPT2_ZIO:
1934 case ICB2400_OPT2_ZIO1:
1935 icbp->icb_idelaytimer = 0;
1936 break;
1937 case 0:
1938 break;
1939 default:
1875 switch (icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK) {
1876 case ICB2400_OPT2_ZIO:
1877 case ICB2400_OPT2_ZIO1:
1878 icbp->icb_idelaytimer = 0;
1879 break;
1880 case 0:
1881 break;
1882 default:
1940 isp_prt(isp, ISP_LOGWARN, "bad value %x in fwopt2 timer field",
1941 icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK);
1883 isp_prt(isp, ISP_LOGWARN, "bad value %x in fwopt2 timer field", icbp->icb_fwoptions2 & ICB2400_OPT2_TIMER_MASK);
1942 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TIMER_MASK;
1943 break;
1944 }
1945
1884 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_TIMER_MASK;
1885 break;
1886 }
1887
1888 /*
1889 * We don't support FCTAPE, so clear it.
1890 */
1891 icbp->icb_fwoptions2 &= ~ICB2400_OPT2_FCTAPE;
1892
1946 icbp->icb_fwoptions3 = fcp->isp_zfwoptions;
1947 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_AUTO;
1948 if (isp->isp_confopts & ISP_CFG_ONEGB) {
1949 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_ONEGB;
1950 } else if (isp->isp_confopts & ISP_CFG_TWOGB) {
1951 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_TWOGB;
1952 } else if (isp->isp_confopts & ISP_CFG_FOURGB) {
1953 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_FOURGB;
1954 } else {
1955 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_AUTO;
1956 }
1957
1958 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
1959 icbp->icb_fwoptions3 |= ICB2400_OPT3_SOFTID;
1960 }
1961 icbp->icb_logintime = ICB_LOGIN_TOV;
1962
1893 icbp->icb_fwoptions3 = fcp->isp_zfwoptions;
1894 icbp->icb_fwoptions3 &= ~ICB2400_OPT3_RATE_AUTO;
1895 if (isp->isp_confopts & ISP_CFG_ONEGB) {
1896 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_ONEGB;
1897 } else if (isp->isp_confopts & ISP_CFG_TWOGB) {
1898 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_TWOGB;
1899 } else if (isp->isp_confopts & ISP_CFG_FOURGB) {
1900 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_FOURGB;
1901 } else {
1902 icbp->icb_fwoptions3 |= ICB2400_OPT3_RATE_AUTO;
1903 }
1904
1905 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
1906 icbp->icb_fwoptions3 |= ICB2400_OPT3_SOFTID;
1907 }
1908 icbp->icb_logintime = ICB_LOGIN_TOV;
1909
1963 nwwn = ISP_NODEWWN(isp);
1964 pwwn = ISP_PORTWWN(isp);
1965
1966 if (nwwn && pwwn) {
1910 if (fcp->isp_wwnn && fcp->isp_wwpn && (fcp->isp_wwnn >> 60) != 2) {
1967 icbp->icb_fwoptions1 |= ICB2400_OPT1_BOTH_WWNS;
1911 icbp->icb_fwoptions1 |= ICB2400_OPT1_BOTH_WWNS;
1968 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, nwwn);
1969 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn);
1970 isp_prt(isp, ISP_LOGDEBUG1,
1971 "Setting ICB Node 0x%08x%08x Port 0x%08x%08x",
1972 ((uint32_t) (nwwn >> 32)),
1973 ((uint32_t) (nwwn & 0xffffffff)),
1974 ((uint32_t) (pwwn >> 32)),
1975 ((uint32_t) (pwwn & 0xffffffff)));
1976 } else if (pwwn) {
1912 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1913 MAKE_NODE_NAME_FROM_WWN(icbp->icb_nodename, fcp->isp_wwnn);
1914 isp_prt(isp, ISP_LOGDEBUG1, "Setting ICB Node 0x%08x%08x Port 0x%08x%08x", ((uint32_t) (fcp->isp_wwnn >> 32)), ((uint32_t) (fcp->isp_wwnn)),
1915 ((uint32_t) (fcp->isp_wwpn >> 32)), ((uint32_t) (fcp->isp_wwpn)));
1916 } else if (fcp->isp_wwpn) {
1977 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_BOTH_WWNS;
1917 icbp->icb_fwoptions1 &= ~ICB2400_OPT1_BOTH_WWNS;
1978 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, pwwn);
1979 isp_prt(isp, ISP_LOGDEBUG1,
1980 "Setting ICB Port 0x%08x%08x",
1981 ((uint32_t) (pwwn >> 32)),
1982 ((uint32_t) (pwwn & 0xffffffff)));
1918 MAKE_NODE_NAME_FROM_WWN(icbp->icb_portname, fcp->isp_wwpn);
1919 isp_prt(isp, ISP_LOGDEBUG1, "Setting ICB Node to be same as Port 0x%08x%08x", ((uint32_t) (fcp->isp_wwpn >> 32)), ((uint32_t) (fcp->isp_wwpn)));
1983 } else {
1984 isp_prt(isp, ISP_LOGERR, "No valid WWNs to use");
1985 return;
1986 }
1987 icbp->icb_retry_count = fcp->isp_retry_count;
1988
1989 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1990 if (icbp->icb_rqstqlen < 8) {
1920 } else {
1921 isp_prt(isp, ISP_LOGERR, "No valid WWNs to use");
1922 return;
1923 }
1924 icbp->icb_retry_count = fcp->isp_retry_count;
1925
1926 icbp->icb_rqstqlen = RQUEST_QUEUE_LEN(isp);
1927 if (icbp->icb_rqstqlen < 8) {
1991 isp_prt(isp, ISP_LOGERR, "bad request queue length %d",
1992 icbp->icb_rqstqlen);
1928 isp_prt(isp, ISP_LOGERR, "bad request queue length %d", icbp->icb_rqstqlen);
1993 return;
1994 }
1995 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1996 if (icbp->icb_rsltqlen < 8) {
1997 isp_prt(isp, ISP_LOGERR, "bad result queue length %d",
1998 icbp->icb_rsltqlen);
1999 return;
2000 }
2001 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma);
2002 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
2003 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
2004 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
2005
2006 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
2007 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
2008 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
2009 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
2010
2011#ifdef ISP_TARGET_MODE
1929 return;
1930 }
1931 icbp->icb_rsltqlen = RESULT_QUEUE_LEN(isp);
1932 if (icbp->icb_rsltqlen < 8) {
1933 isp_prt(isp, ISP_LOGERR, "bad result queue length %d",
1934 icbp->icb_rsltqlen);
1935 return;
1936 }
1937 icbp->icb_rqstaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_rquest_dma);
1938 icbp->icb_rqstaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_rquest_dma);
1939 icbp->icb_rqstaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_rquest_dma);
1940 icbp->icb_rqstaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_rquest_dma);
1941
1942 icbp->icb_respaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_result_dma);
1943 icbp->icb_respaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_result_dma);
1944 icbp->icb_respaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_result_dma);
1945 icbp->icb_respaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_result_dma);
1946
1947#ifdef ISP_TARGET_MODE
2012 if (isp->isp_role & ISP_ROLE_TARGET) {
2013 icbp->icb_atioqlen = RESULT_QUEUE_LEN(isp);
2014 if (icbp->icb_atioqlen < 8) {
2015 isp_prt(isp, ISP_LOGERR, "bad ATIO queue length %d",
2016 icbp->icb_atioqlen);
2017 return;
2018 }
2019 icbp->icb_atioqaddr[RQRSP_ADDR0015] =
2020 DMA_WD0(isp->isp_atioq_dma);
2021 icbp->icb_atioqaddr[RQRSP_ADDR1631] =
2022 DMA_WD1(isp->isp_atioq_dma);
2023 icbp->icb_atioqaddr[RQRSP_ADDR3247] =
2024 DMA_WD2(isp->isp_atioq_dma);
2025 icbp->icb_atioqaddr[RQRSP_ADDR4863] =
2026 DMA_WD3(isp->isp_atioq_dma);
2027 isp_prt(isp, ISP_LOGDEBUG0,
2028 "isp_fibre_init_2400: atioq %04x%04x%04x%04x",
2029 DMA_WD3(isp->isp_atioq_dma), DMA_WD2(isp->isp_atioq_dma),
2030 DMA_WD1(isp->isp_atioq_dma), DMA_WD0(isp->isp_atioq_dma));
1948 /* unconditionally set up the ATIO queue if we support target mode */
1949 icbp->icb_atioqlen = RESULT_QUEUE_LEN(isp);
1950 if (icbp->icb_atioqlen < 8) {
1951 isp_prt(isp, ISP_LOGERR, "bad ATIO queue length %d", icbp->icb_atioqlen);
1952 return;
2031 }
1953 }
1954 icbp->icb_atioqaddr[RQRSP_ADDR0015] = DMA_WD0(isp->isp_atioq_dma);
1955 icbp->icb_atioqaddr[RQRSP_ADDR1631] = DMA_WD1(isp->isp_atioq_dma);
1956 icbp->icb_atioqaddr[RQRSP_ADDR3247] = DMA_WD2(isp->isp_atioq_dma);
1957 icbp->icb_atioqaddr[RQRSP_ADDR4863] = DMA_WD3(isp->isp_atioq_dma);
1958 isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: atioq %04x%04x%04x%04x", DMA_WD3(isp->isp_atioq_dma), DMA_WD2(isp->isp_atioq_dma),
1959 DMA_WD1(isp->isp_atioq_dma), DMA_WD0(isp->isp_atioq_dma));
2032#endif
2033
1960#endif
1961
2034 isp_prt(isp, ISP_LOGDEBUG0,
2035 "isp_fibre_init_2400: fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x",
2036 icbp->icb_fwoptions1, icbp->icb_fwoptions2, icbp->icb_fwoptions3);
1962 isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: fwopt1 0x%x fwopt2 0x%x fwopt3 0x%x", icbp->icb_fwoptions1, icbp->icb_fwoptions2, icbp->icb_fwoptions3);
2037
1963
2038 isp_prt(isp, ISP_LOGDEBUG0,
2039 "isp_fibre_init_2400: rqst %04x%04x%04x%04x rsp %04x%04x%04x%04x",
2040 DMA_WD3(isp->isp_rquest_dma), DMA_WD2(isp->isp_rquest_dma),
2041 DMA_WD1(isp->isp_rquest_dma), DMA_WD0(isp->isp_rquest_dma),
2042 DMA_WD3(isp->isp_result_dma), DMA_WD2(isp->isp_result_dma),
1964 isp_prt(isp, ISP_LOGDEBUG0, "isp_fibre_init_2400: rqst %04x%04x%04x%04x rsp %04x%04x%04x%04x", DMA_WD3(isp->isp_rquest_dma), DMA_WD2(isp->isp_rquest_dma),
1965 DMA_WD1(isp->isp_rquest_dma), DMA_WD0(isp->isp_rquest_dma), DMA_WD3(isp->isp_result_dma), DMA_WD2(isp->isp_result_dma),
2043 DMA_WD1(isp->isp_result_dma), DMA_WD0(isp->isp_result_dma));
2044
2045 if (isp->isp_dblev & ISP_LOGDEBUG1) {
1966 DMA_WD1(isp->isp_result_dma), DMA_WD0(isp->isp_result_dma));
1967
1968 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2046 isp_print_bytes(isp, "isp_fibre_init_2400", sizeof (*icbp),
2047 icbp);
1969 isp_print_bytes(isp, "isp_fibre_init_2400", sizeof (*icbp), icbp);
2048 }
1970 }
2049 FC_SCRATCH_ACQUIRE(isp);
1971
1972 if (FC_SCRATCH_ACQUIRE(isp, 0)) {
1973 isp_prt(isp, ISP_LOGERR, sacq);
1974 return;
1975 }
1976 ISP_MEMZERO(fcp->isp_scratch, ISP_FC_SCRLEN);
2050 isp_put_icb_2400(isp, icbp, fcp->isp_scratch);
2051
1977 isp_put_icb_2400(isp, icbp, fcp->isp_scratch);
1978
1979 /*
1980 * Now fill in information about any additional channels
1981 */
1982 if (isp->isp_nchan > 1) {
1983 isp_icb_2400_vpinfo_t vpinfo, *vdst;
1984 vp_port_info_t pi, *pdst;
1985 size_t amt = 0;
1986 uint8_t *off;
2052
1987
1988 vpinfo.vp_count = isp->isp_nchan - 1;
1989 vpinfo.vp_global_options = 0;
1990 off = fcp->isp_scratch;
1991 off += ICB2400_VPINFO_OFF;
1992 vdst = (isp_icb_2400_vpinfo_t *) off;
1993 isp_put_icb_2400_vpinfo(isp, &vpinfo, vdst);
1994 amt = ICB2400_VPINFO_OFF + sizeof (isp_icb_2400_vpinfo_t);
1995 for (chan = 1; chan < isp->isp_nchan; chan++) {
1996 fcparam *fcp2;
1997
1998 ISP_MEMZERO(&pi, sizeof (pi));
1999 fcp2 = FCPARAM(isp, chan);
2000 if (fcp2->role != ISP_ROLE_NONE) {
2001 pi.vp_port_options = ICB2400_VPOPT_ENABLED;
2002 if (fcp2->role & ISP_ROLE_INITIATOR) {
2003 pi.vp_port_options |= ICB2400_VPOPT_INI_ENABLE;
2004 }
2005 if ((fcp2->role & ISP_ROLE_TARGET) == 0) {
2006 pi.vp_port_options |= ICB2400_VPOPT_TGT_DISABLE;
2007 }
2008 MAKE_NODE_NAME_FROM_WWN(pi.vp_port_portname, fcp2->isp_wwpn);
2009 MAKE_NODE_NAME_FROM_WWN(pi.vp_port_nodename, fcp2->isp_wwnn);
2010 }
2011 off = fcp->isp_scratch;
2012 off += ICB2400_VPINFO_PORT_OFF(chan);
2013 pdst = (vp_port_info_t *) off;
2014 isp_put_vp_port_info(isp, &pi, pdst);
2015 amt += ICB2400_VPOPT_WRITE_SIZE;
2016 }
2017 }
2018
2053 /*
2054 * Init the firmware
2055 */
2019 /*
2020 * Init the firmware
2021 */
2056 MEMZERO(&mbs, sizeof (mbs));
2057 mbs.param[0] = MBOX_INIT_FIRMWARE;
2022 MBSINIT(&mbs, 0, MBLOGALL, 30000000);
2023 if (isp->isp_nchan > 1) {
2024 mbs.param[0] = MBOX_INIT_FIRMWARE_MULTI_ID;
2025 } else {
2026 mbs.param[0] = MBOX_INIT_FIRMWARE;
2027 }
2058 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2059 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2060 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2061 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2028 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2029 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2030 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2031 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2062 mbs.logval = MBLOGALL;
2063 mbs.timeout = 30 * 1000000;
2064 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %04x%04x%04x%04x",
2065 DMA_WD3(fcp->isp_scdma), DMA_WD2(fcp->isp_scdma),
2066 DMA_WD1(fcp->isp_scdma), DMA_WD0(fcp->isp_scdma));
2032 isp_prt(isp, ISP_LOGDEBUG0, "INIT F/W from %04x%04x%04x%04x", DMA_WD3(fcp->isp_scdma), DMA_WD2(fcp->isp_scdma), DMA_WD1(fcp->isp_scdma), DMA_WD0(fcp->isp_scdma));
2067 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp));
2068 isp_mboxcmd(isp, &mbs);
2033 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (*icbp));
2034 isp_mboxcmd(isp, &mbs);
2069 FC_SCRATCH_RELEASE(isp);
2035 FC_SCRATCH_RELEASE(isp, 0);
2036
2070 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2071 return;
2072 }
2073 isp->isp_reqidx = 0;
2074 isp->isp_reqodx = 0;
2075 isp->isp_residx = 0;
2076
2077 /*
2078 * Whatever happens, we're now committed to being here.
2079 */
2080 isp->isp_state = ISP_INITSTATE;
2081}
2082
2083static void
2037 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2038 return;
2039 }
2040 isp->isp_reqidx = 0;
2041 isp->isp_reqodx = 0;
2042 isp->isp_residx = 0;
2043
2044 /*
2045 * Whatever happens, we're now committed to being here.
2046 */
2047 isp->isp_state = ISP_INITSTATE;
2048}
2049
2050static void
2084isp_mark_portdb(ispsoftc_t *isp, int onprobation)
2051isp_mark_portdb(ispsoftc_t *isp, int chan, int disposition)
2085{
2052{
2086 fcparam *fcp = (fcparam *) isp->isp_param;
2053 fcparam *fcp = FCPARAM(isp, chan);
2087 int i;
2088
2054 int i;
2055
2056 if (chan < 0 || chan >= isp->isp_nchan) {
2057 isp_prt(isp, ISP_LOGWARN, "isp_mark_portdb: bad channel %d", chan);
2058 return;
2059 }
2089 for (i = 0; i < MAX_FC_TARG; i++) {
2060 for (i = 0; i < MAX_FC_TARG; i++) {
2090 if (onprobation == 0) {
2091 MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t));
2061 if (fcp->portdb[i].target_mode) {
2062 if (disposition < 0) {
2063 isp_prt(isp, ISP_LOGTINFO, "isp_mark_portdb: Chan %d zeroing handle 0x" "%04x port 0x%06x", chan,
2064 fcp->portdb[i].handle, fcp->portdb[i].portid);
2065 ISP_MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t));
2066 }
2067 continue;
2068 }
2069 if (disposition == 0) {
2070 ISP_MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t));
2092 } else {
2093 switch (fcp->portdb[i].state) {
2094 case FC_PORTDB_STATE_CHANGED:
2095 case FC_PORTDB_STATE_PENDING_VALID:
2096 case FC_PORTDB_STATE_VALID:
2097 case FC_PORTDB_STATE_PROBATIONAL:
2071 } else {
2072 switch (fcp->portdb[i].state) {
2073 case FC_PORTDB_STATE_CHANGED:
2074 case FC_PORTDB_STATE_PENDING_VALID:
2075 case FC_PORTDB_STATE_VALID:
2076 case FC_PORTDB_STATE_PROBATIONAL:
2098 fcp->portdb[i].state =
2099 FC_PORTDB_STATE_PROBATIONAL;
2077 fcp->portdb[i].state = FC_PORTDB_STATE_PROBATIONAL;
2100 break;
2101 case FC_PORTDB_STATE_ZOMBIE:
2102 break;
2103 case FC_PORTDB_STATE_NIL:
2104 default:
2078 break;
2079 case FC_PORTDB_STATE_ZOMBIE:
2080 break;
2081 case FC_PORTDB_STATE_NIL:
2082 default:
2105 MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t));
2106 fcp->portdb[i].state =
2107 FC_PORTDB_STATE_NIL;
2083 ISP_MEMZERO(&fcp->portdb[i], sizeof (fcportdb_t));
2084 fcp->portdb[i].state = FC_PORTDB_STATE_NIL;
2108 break;
2109 }
2110 }
2111 }
2112}
2113
2114/*
2115 * Perform an IOCB PLOGI or LOGO via EXECUTE IOCB A64 for 24XX cards
2116 * or via FABRIC LOGIN/FABRIC LOGOUT for other cards.
2117 */
2118static int
2085 break;
2086 }
2087 }
2088 }
2089}
2090
2091/*
2092 * Perform an IOCB PLOGI or LOGO via EXECUTE IOCB A64 for 24XX cards
2093 * or via FABRIC LOGIN/FABRIC LOGOUT for other cards.
2094 */
2095static int
2119isp_plogx(ispsoftc_t *isp, uint16_t handle, uint32_t portid, int flags, int gs)
2096isp_plogx(ispsoftc_t *isp, int chan, uint16_t handle, uint32_t portid,
2097 int flags, int gs)
2120{
2121 mbreg_t mbs;
2122 uint8_t q[QENTRY_LEN];
2123 isp_plogx_t *plp;
2098{
2099 mbreg_t mbs;
2100 uint8_t q[QENTRY_LEN];
2101 isp_plogx_t *plp;
2102 fcparam *fcp;
2124 uint8_t *scp;
2125 uint32_t sst, parm1;
2103 uint8_t *scp;
2104 uint32_t sst, parm1;
2126 int rval;
2105 int rval, lev;
2106 const char *msg;
2107 char buf[64];
2127
2128 if (!IS_24XX(isp)) {
2129 int action = flags & PLOGX_FLG_CMD_MASK;
2130 if (action == PLOGX_FLG_CMD_PLOGI) {
2131 return (isp_port_login(isp, handle, portid));
2132 } else if (action == PLOGX_FLG_CMD_LOGO) {
2133 return (isp_port_logout(isp, handle, portid));
2134 } else {
2135 return (MBOX_INVALID_COMMAND);
2136 }
2137 }
2138
2108
2109 if (!IS_24XX(isp)) {
2110 int action = flags & PLOGX_FLG_CMD_MASK;
2111 if (action == PLOGX_FLG_CMD_PLOGI) {
2112 return (isp_port_login(isp, handle, portid));
2113 } else if (action == PLOGX_FLG_CMD_LOGO) {
2114 return (isp_port_logout(isp, handle, portid));
2115 } else {
2116 return (MBOX_INVALID_COMMAND);
2117 }
2118 }
2119
2139 MEMZERO(q, QENTRY_LEN);
2120 ISP_MEMZERO(q, QENTRY_LEN);
2140 plp = (isp_plogx_t *) q;
2141 plp->plogx_header.rqs_entry_count = 1;
2142 plp->plogx_header.rqs_entry_type = RQSTYPE_LOGIN;
2143 plp->plogx_handle = 0xffffffff;
2144 plp->plogx_nphdl = handle;
2121 plp = (isp_plogx_t *) q;
2122 plp->plogx_header.rqs_entry_count = 1;
2123 plp->plogx_header.rqs_entry_type = RQSTYPE_LOGIN;
2124 plp->plogx_handle = 0xffffffff;
2125 plp->plogx_nphdl = handle;
2126 plp->plogx_vphdl = chan;
2145 plp->plogx_portlo = portid;
2146 plp->plogx_rspsz_porthi = (portid >> 16) & 0xff;
2147 plp->plogx_flags = flags;
2148
2149 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2150 isp_print_bytes(isp, "IOCB LOGX", QENTRY_LEN, plp);
2151 }
2152
2153 if (gs == 0) {
2127 plp->plogx_portlo = portid;
2128 plp->plogx_rspsz_porthi = (portid >> 16) & 0xff;
2129 plp->plogx_flags = flags;
2130
2131 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2132 isp_print_bytes(isp, "IOCB LOGX", QENTRY_LEN, plp);
2133 }
2134
2135 if (gs == 0) {
2154 FC_SCRATCH_ACQUIRE(isp);
2136 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2137 isp_prt(isp, ISP_LOGERR, sacq);
2138 return (-1);
2139 }
2155 }
2140 }
2156 scp = FCPARAM(isp)->isp_scratch;
2141 fcp = FCPARAM(isp, chan);
2142 scp = fcp->isp_scratch;
2157 isp_put_plogx(isp, plp, (isp_plogx_t *) scp);
2158
2143 isp_put_plogx(isp, plp, (isp_plogx_t *) scp);
2144
2159
2160 MEMZERO(&mbs, sizeof (mbs));
2161 mbs.param[0] = MBOX_EXEC_COMMAND_IOCB_A64;
2145 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 500000);
2162 mbs.param[1] = QENTRY_LEN;
2146 mbs.param[1] = QENTRY_LEN;
2163 mbs.param[2] = DMA_WD1(FCPARAM(isp)->isp_scdma);
2164 mbs.param[3] = DMA_WD0(FCPARAM(isp)->isp_scdma);
2165 mbs.param[6] = DMA_WD3(FCPARAM(isp)->isp_scdma);
2166 mbs.param[7] = DMA_WD2(FCPARAM(isp)->isp_scdma);
2167 mbs.timeout = 500000;
2168 mbs.logval = MBLOGALL;
2147 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2148 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2149 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2150 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2169 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN);
2170 isp_mboxcmd(isp, &mbs);
2171 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2172 rval = mbs.param[0];
2173 goto out;
2174 }
2175 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN);
2176 scp += QENTRY_LEN;
2177 isp_get_plogx(isp, (isp_plogx_t *) scp, plp);
2178 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2179 isp_print_bytes(isp, "IOCB LOGX response", QENTRY_LEN, plp);
2180 }
2181
2182 if (plp->plogx_status == PLOGX_STATUS_OK) {
2183 rval = 0;
2184 goto out;
2185 } else if (plp->plogx_status != PLOGX_STATUS_IOCBERR) {
2151 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN);
2152 isp_mboxcmd(isp, &mbs);
2153 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2154 rval = mbs.param[0];
2155 goto out;
2156 }
2157 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN, QENTRY_LEN);
2158 scp += QENTRY_LEN;
2159 isp_get_plogx(isp, (isp_plogx_t *) scp, plp);
2160 if (isp->isp_dblev & ISP_LOGDEBUG1) {
2161 isp_print_bytes(isp, "IOCB LOGX response", QENTRY_LEN, plp);
2162 }
2163
2164 if (plp->plogx_status == PLOGX_STATUS_OK) {
2165 rval = 0;
2166 goto out;
2167 } else if (plp->plogx_status != PLOGX_STATUS_IOCBERR) {
2186 isp_prt(isp, ISP_LOGWARN, "status 0x%x on port login IOCB",
2187 plp->plogx_status);
2168 isp_prt(isp, ISP_LOGWARN,
2169 "status 0x%x on port login IOCB chanel %d",
2170 plp->plogx_status, chan);
2188 rval = -1;
2189 goto out;
2190 }
2191
2192 sst = plp->plogx_ioparm[0].lo16 | (plp->plogx_ioparm[0].hi16 << 16);
2193 parm1 = plp->plogx_ioparm[1].lo16 | (plp->plogx_ioparm[1].hi16 << 16);
2194
2195 rval = -1;
2171 rval = -1;
2172 goto out;
2173 }
2174
2175 sst = plp->plogx_ioparm[0].lo16 | (plp->plogx_ioparm[0].hi16 << 16);
2176 parm1 = plp->plogx_ioparm[1].lo16 | (plp->plogx_ioparm[1].hi16 << 16);
2177
2178 rval = -1;
2179 lev = ISP_LOGERR;
2180 msg = NULL;
2196
2197 switch (sst) {
2198 case PLOGX_IOCBERR_NOLINK:
2181
2182 switch (sst) {
2183 case PLOGX_IOCBERR_NOLINK:
2199 isp_prt(isp, ISP_LOGERR, "PLOGX failed- no link");
2184 msg = "no link";
2200 break;
2201 case PLOGX_IOCBERR_NOIOCB:
2185 break;
2186 case PLOGX_IOCBERR_NOIOCB:
2202 isp_prt(isp, ISP_LOGERR, "PLOGX failed- no IOCB buffer");
2187 msg = "no IOCB buffer";
2203 break;
2204 case PLOGX_IOCBERR_NOXGHG:
2188 break;
2189 case PLOGX_IOCBERR_NOXGHG:
2205 isp_prt(isp, ISP_LOGERR,
2206 "PLOGX failed- no Exchange Control Block");
2190 msg = "no Exchange Control Block";
2207 break;
2208 case PLOGX_IOCBERR_FAILED:
2191 break;
2192 case PLOGX_IOCBERR_FAILED:
2209 isp_prt(isp, ISP_LOGERR,
2210 "PLOGX(0x%x) of Port 0x%06x failed: reason 0x%x (last LOGIN"
2211 " state 0x%x)", flags, portid, parm1 & 0xff,
2212 (parm1 >> 8) & 0xff);
2193 ISP_SNPRINTF(buf, sizeof (buf),
2194 "reason 0x%x (last LOGIN state 0x%x)",
2195 parm1 & 0xff, (parm1 >> 8) & 0xff);
2196 msg = buf;
2213 break;
2214 case PLOGX_IOCBERR_NOFABRIC:
2197 break;
2198 case PLOGX_IOCBERR_NOFABRIC:
2215 isp_prt(isp, ISP_LOGERR, "PLOGX failed- no fabric");
2199 msg = "no fabric";
2216 break;
2217 case PLOGX_IOCBERR_NOTREADY:
2200 break;
2201 case PLOGX_IOCBERR_NOTREADY:
2218 isp_prt(isp, ISP_LOGERR, "PLOGX failed- f/w not ready");
2202 msg = "firmware not ready";
2219 break;
2220 case PLOGX_IOCBERR_NOLOGIN:
2203 break;
2204 case PLOGX_IOCBERR_NOLOGIN:
2221 isp_prt(isp, ISP_LOGERR,
2222 "PLOGX failed- not logged in (last LOGIN state 0x%x)",
2205 ISP_SNPRINTF(buf, sizeof (buf), "not logged in (last state 0x%x)",
2223 parm1);
2206 parm1);
2207 msg = buf;
2224 rval = MBOX_NOT_LOGGED_IN;
2225 break;
2226 case PLOGX_IOCBERR_REJECT:
2208 rval = MBOX_NOT_LOGGED_IN;
2209 break;
2210 case PLOGX_IOCBERR_REJECT:
2227 isp_prt(isp, ISP_LOGERR, "PLOGX failed: LS_RJT = 0x%x", parm1);
2211 ISP_SNPRINTF(buf, sizeof (buf), "LS_RJT = 0x%x", parm1);
2212 msg = buf;
2228 break;
2229 case PLOGX_IOCBERR_NOPCB:
2213 break;
2214 case PLOGX_IOCBERR_NOPCB:
2230 isp_prt(isp, ISP_LOGERR, "PLOGX failed- no PCB allocated");
2215 msg = "no PCB allocated";
2231 break;
2232 case PLOGX_IOCBERR_EINVAL:
2216 break;
2217 case PLOGX_IOCBERR_EINVAL:
2233 isp_prt(isp, ISP_LOGERR,
2234 "PLOGX failed: invalid parameter at offset 0x%x", parm1);
2218 ISP_SNPRINTF(buf, sizeof (buf), "invalid parameter at offset 0x%x",
2219 parm1);
2220 msg = buf;
2235 break;
2236 case PLOGX_IOCBERR_PORTUSED:
2221 break;
2222 case PLOGX_IOCBERR_PORTUSED:
2237 isp_prt(isp, ISP_LOGDEBUG0,
2238 "portid 0x%x already logged in with N-port handle 0x%x",
2239 portid, parm1);
2240 rval = MBOX_PORT_ID_USED | (handle << 16);
2223 lev = ISP_LOGSANCFG|ISP_LOGDEBUG0;
2224 ISP_SNPRINTF(buf, sizeof (buf),
2225 "already logged in with N-Port handle 0x%x", parm1);
2226 msg = buf;
2227 rval = MBOX_PORT_ID_USED | (parm1 << 16);
2241 break;
2242 case PLOGX_IOCBERR_HNDLUSED:
2228 break;
2229 case PLOGX_IOCBERR_HNDLUSED:
2243 isp_prt(isp, ISP_LOGDEBUG0,
2244 "N-port handle 0x%x already used for portid 0x%x",
2245 handle, parm1);
2230 lev = ISP_LOGSANCFG|ISP_LOGDEBUG0;
2231 ISP_SNPRINTF(buf, sizeof (buf),
2232 "handle already used for PortID 0x%06x", parm1);
2233 msg = buf;
2246 rval = MBOX_LOOP_ID_USED;
2247 break;
2248 case PLOGX_IOCBERR_NOHANDLE:
2234 rval = MBOX_LOOP_ID_USED;
2235 break;
2236 case PLOGX_IOCBERR_NOHANDLE:
2249 isp_prt(isp, ISP_LOGERR, "PLOGX failed- no handle allocated");
2237 msg = "no handle allocated";
2250 break;
2251 case PLOGX_IOCBERR_NOFLOGI:
2238 break;
2239 case PLOGX_IOCBERR_NOFLOGI:
2252 isp_prt(isp, ISP_LOGERR, "PLOGX failed- no FLOGI_ACC");
2240 msg = "no FLOGI_ACC";
2253 break;
2254 default:
2241 break;
2242 default:
2255 isp_prt(isp, ISP_LOGERR, "status %x from %x", plp->plogx_status,
2256 flags);
2257 rval = -1;
2243 ISP_SNPRINTF(buf, sizeof (buf), "status %x from %x",
2244 plp->plogx_status, flags);
2245 msg = buf;
2258 break;
2259 }
2246 break;
2247 }
2248 if (msg) {
2249 isp_prt(isp, ISP_LOGERR,
2250 "Chan %d PLOGX PortID 0x%06x to N-Port handle 0x%x: %s",
2251 chan, portid, handle, msg);
2252 }
2260out:
2261 if (gs == 0) {
2253out:
2254 if (gs == 0) {
2262 FC_SCRATCH_RELEASE(isp);
2255 FC_SCRATCH_RELEASE(isp, chan);
2263 }
2264 return (rval);
2265}
2266
2267static int
2268isp_port_login(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
2269{
2270 mbreg_t mbs;
2271
2256 }
2257 return (rval);
2258}
2259
2260static int
2261isp_port_login(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
2262{
2263 mbreg_t mbs;
2264
2272 MEMZERO(&mbs, sizeof (mbs));
2273 mbs.param[0] = MBOX_FABRIC_LOGIN;
2274 if (FCPARAM(isp)->isp_2klogin) {
2265 MBSINIT(&mbs, MBOX_FABRIC_LOGIN, MBLOGNONE, 500000);
2266 if (ISP_CAP_2KLOGIN(isp)) {
2275 mbs.param[1] = handle;
2276 mbs.ibits = (1 << 10);
2277 } else {
2278 mbs.param[1] = handle << 8;
2279 }
2280 mbs.param[2] = portid >> 16;
2281 mbs.param[3] = portid;
2282 mbs.logval = MBLOGNONE;
2283 mbs.timeout = 500000;
2284 isp_mboxcmd(isp, &mbs);
2285
2286 switch (mbs.param[0]) {
2287 case MBOX_PORT_ID_USED:
2288 isp_prt(isp, ISP_LOGDEBUG0,
2267 mbs.param[1] = handle;
2268 mbs.ibits = (1 << 10);
2269 } else {
2270 mbs.param[1] = handle << 8;
2271 }
2272 mbs.param[2] = portid >> 16;
2273 mbs.param[3] = portid;
2274 mbs.logval = MBLOGNONE;
2275 mbs.timeout = 500000;
2276 isp_mboxcmd(isp, &mbs);
2277
2278 switch (mbs.param[0]) {
2279 case MBOX_PORT_ID_USED:
2280 isp_prt(isp, ISP_LOGDEBUG0,
2289 "isp_plogi_old: portid 0x%06x already logged in as %u",
2281 "isp_port_login: portid 0x%06x already logged in as %u",
2290 portid, mbs.param[1]);
2291 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16));
2292
2293 case MBOX_LOOP_ID_USED:
2294 isp_prt(isp, ISP_LOGDEBUG0,
2282 portid, mbs.param[1]);
2283 return (MBOX_PORT_ID_USED | (mbs.param[1] << 16));
2284
2285 case MBOX_LOOP_ID_USED:
2286 isp_prt(isp, ISP_LOGDEBUG0,
2295 "isp_plogi_old: handle %u in use for port id 0x%02xXXXX",
2287 "isp_port_login: handle 0x%04x in use for port id 0x%02xXXXX",
2296 handle, mbs.param[1] & 0xff);
2297 return (MBOX_LOOP_ID_USED);
2298
2299 case MBOX_COMMAND_COMPLETE:
2300 return (0);
2301
2302 case MBOX_COMMAND_ERROR:
2303 isp_prt(isp, ISP_LOGINFO,
2288 handle, mbs.param[1] & 0xff);
2289 return (MBOX_LOOP_ID_USED);
2290
2291 case MBOX_COMMAND_COMPLETE:
2292 return (0);
2293
2294 case MBOX_COMMAND_ERROR:
2295 isp_prt(isp, ISP_LOGINFO,
2304 "isp_plogi_old: error 0x%x in PLOGI to port 0x%06x",
2296 "isp_port_login: error 0x%x in PLOGI to port 0x%06x",
2305 mbs.param[1], portid);
2306 return (MBOX_COMMAND_ERROR);
2307
2308 case MBOX_ALL_IDS_USED:
2309 isp_prt(isp, ISP_LOGINFO,
2297 mbs.param[1], portid);
2298 return (MBOX_COMMAND_ERROR);
2299
2300 case MBOX_ALL_IDS_USED:
2301 isp_prt(isp, ISP_LOGINFO,
2310 "isp_plogi_old: all IDs used for fabric login");
2302 "isp_port_login: all IDs used for fabric login");
2311 return (MBOX_ALL_IDS_USED);
2312
2313 default:
2314 isp_prt(isp, ISP_LOGINFO,
2303 return (MBOX_ALL_IDS_USED);
2304
2305 default:
2306 isp_prt(isp, ISP_LOGINFO,
2315 "isp_plogi_old: error 0x%x on port login of 0x%06x@0x%0x",
2307 "isp_port_login: error 0x%x on port login of 0x%06x@0x%0x",
2316 mbs.param[0], portid, handle);
2317 return (mbs.param[0]);
2318 }
2319}
2320
2321static int
2322isp_port_logout(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
2323{
2324 mbreg_t mbs;
2325
2308 mbs.param[0], portid, handle);
2309 return (mbs.param[0]);
2310 }
2311}
2312
2313static int
2314isp_port_logout(ispsoftc_t *isp, uint16_t handle, uint32_t portid)
2315{
2316 mbreg_t mbs;
2317
2326 MEMZERO(&mbs, sizeof (mbs));
2327 mbs.param[0] = MBOX_FABRIC_LOGOUT;
2328 if (FCPARAM(isp)->isp_2klogin) {
2318 MBSINIT(&mbs, MBOX_FABRIC_LOGOUT, MBLOGNONE, 500000);
2319 if (ISP_CAP_2KLOGIN(isp)) {
2329 mbs.param[1] = handle;
2330 mbs.ibits = (1 << 10);
2331 } else {
2332 mbs.param[1] = handle << 8;
2333 }
2320 mbs.param[1] = handle;
2321 mbs.ibits = (1 << 10);
2322 } else {
2323 mbs.param[1] = handle << 8;
2324 }
2334 mbs.logval = MBLOGNONE;
2335 mbs.timeout = 100000;
2336 isp_mboxcmd(isp, &mbs);
2337 return (mbs.param[0] == MBOX_COMMAND_COMPLETE? 0 : mbs.param[0]);
2338}
2339
2340static int
2325 isp_mboxcmd(isp, &mbs);
2326 return (mbs.param[0] == MBOX_COMMAND_COMPLETE? 0 : mbs.param[0]);
2327}
2328
2329static int
2341isp_getpdb(ispsoftc_t *isp, uint16_t id, isp_pdb_t *pdb, int dolock)
2330isp_getpdb(ispsoftc_t *isp, int chan, uint16_t id, isp_pdb_t *pdb, int dolock)
2342{
2331{
2343 fcparam *fcp = (fcparam *) isp->isp_param;
2332 fcparam *fcp = FCPARAM(isp, chan);
2344 mbreg_t mbs;
2345 union {
2346 isp_pdb_21xx_t fred;
2347 isp_pdb_24xx_t bill;
2348 } un;
2349
2333 mbreg_t mbs;
2334 union {
2335 isp_pdb_21xx_t fred;
2336 isp_pdb_24xx_t bill;
2337 } un;
2338
2350 MEMZERO(&mbs, sizeof (mbs));
2351 mbs.param[0] = MBOX_GET_PORT_DB;
2339 MBSINIT(&mbs, MBOX_GET_PORT_DB, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR, 250000);
2352 if (IS_24XX(isp)) {
2340 if (IS_24XX(isp)) {
2353 mbs.ibits = 0x3ff;
2341 mbs.ibits = (1 << 9)|(1 << 10);
2354 mbs.param[1] = id;
2342 mbs.param[1] = id;
2355 } else if (FCPARAM(isp)->isp_2klogin) {
2343 mbs.param[9] = chan;
2344 } else if (ISP_CAP_2KLOGIN(isp)) {
2356 mbs.param[1] = id;
2345 mbs.param[1] = id;
2357 mbs.ibits = (1 << 10);
2358 } else {
2359 mbs.param[1] = id << 8;
2360 }
2361 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2362 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2363 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2364 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2346 } else {
2347 mbs.param[1] = id << 8;
2348 }
2349 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
2350 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
2351 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
2352 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
2365 mbs.timeout = 250000;
2366 mbs.logval = MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR;
2367 if (dolock) {
2353 if (dolock) {
2368 FC_SCRATCH_ACQUIRE(isp);
2354 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
2355 isp_prt(isp, ISP_LOGERR, sacq);
2356 return (-1);
2357 }
2369 }
2370 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (un));
2371 isp_mboxcmd(isp, &mbs);
2372 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2373 if (dolock) {
2358 }
2359 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, sizeof (un));
2360 isp_mboxcmd(isp, &mbs);
2361 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2362 if (dolock) {
2374 FC_SCRATCH_RELEASE(isp);
2363 FC_SCRATCH_RELEASE(isp, chan);
2375 }
2364 }
2376 return (-1);
2365 return (mbs.param[0]);
2377 }
2378 if (IS_24XX(isp)) {
2379 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill);
2380 pdb->handle = un.bill.pdb_handle;
2381 pdb->s3_role = un.bill.pdb_prli_svc3;
2382 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
2366 }
2367 if (IS_24XX(isp)) {
2368 isp_get_pdb_24xx(isp, fcp->isp_scratch, &un.bill);
2369 pdb->handle = un.bill.pdb_handle;
2370 pdb->s3_role = un.bill.pdb_prli_svc3;
2371 pdb->portid = BITS2WORD_24XX(un.bill.pdb_portid_bits);
2383 MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
2384 MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
2372 ISP_MEMCPY(pdb->portname, un.bill.pdb_portname, 8);
2373 ISP_MEMCPY(pdb->nodename, un.bill.pdb_nodename, 8);
2374 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2375 "Chan %d Port 0x%06x flags 0x%x curstate %x",
2376 chan, pdb->portid, un.bill.pdb_flags,
2377 un.bill.pdb_curstate);
2378 if (un.bill.pdb_curstate < PDB2400_STATE_PLOGI_DONE ||
2379 un.bill.pdb_curstate > PDB2400_STATE_LOGGED_IN) {
2380 mbs.param[0] = MBOX_NOT_LOGGED_IN;
2381 if (dolock) {
2382 FC_SCRATCH_RELEASE(isp, chan);
2383 }
2384 return (mbs.param[0]);
2385 }
2385 } else {
2386 isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred);
2387 pdb->handle = un.fred.pdb_loopid;
2388 pdb->s3_role = un.fred.pdb_prli_svc3;
2389 pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
2386 } else {
2387 isp_get_pdb_21xx(isp, fcp->isp_scratch, &un.fred);
2388 pdb->handle = un.fred.pdb_loopid;
2389 pdb->s3_role = un.fred.pdb_prli_svc3;
2390 pdb->portid = BITS2WORD(un.fred.pdb_portid_bits);
2390 MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
2391 MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
2391 ISP_MEMCPY(pdb->portname, un.fred.pdb_portname, 8);
2392 ISP_MEMCPY(pdb->nodename, un.fred.pdb_nodename, 8);
2392 }
2393 if (dolock) {
2393 }
2394 if (dolock) {
2394 FC_SCRATCH_RELEASE(isp);
2395 FC_SCRATCH_RELEASE(isp, chan);
2395 }
2396 return (0);
2397}
2398
2396 }
2397 return (0);
2398}
2399
2400static void
2401isp_dump_chip_portdb(ispsoftc_t *isp, int chan, int dolock)
2402{
2403 isp_pdb_t pdb;
2404 int lim, loopid;
2405
2406 if (ISP_CAP_2KLOGIN(isp)) {
2407 lim = NPH_MAX_2K;
2408 } else {
2409 lim = NPH_MAX;
2410 }
2411 for (loopid = 0; loopid != lim; loopid++) {
2412 if (isp_getpdb(isp, chan, loopid, &pdb, dolock)) {
2413 continue;
2414 }
2415 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGINFO, "Chan %d Loopid 0x%04x "
2416 "PortID 0x%06x WWPN 0x%02x%02x%02x%02x%02x%02x%02x%02x",
2417 chan, loopid, pdb.portid, pdb.portname[0], pdb.portname[1],
2418 pdb.portname[2], pdb.portname[3], pdb.portname[4],
2419 pdb.portname[5], pdb.portname[6], pdb.portname[7]);
2420 }
2421}
2422
2399static uint64_t
2423static uint64_t
2400isp_get_portname(ispsoftc_t *isp, int loopid, int nodename)
2424isp_get_wwn(ispsoftc_t *isp, int chan, int loopid, int nodename)
2401{
2425{
2402 uint64_t wwn = (uint64_t) -1;
2426 uint64_t wwn = INI_NONE;
2427 fcparam *fcp = FCPARAM(isp, chan);
2403 mbreg_t mbs;
2404
2428 mbreg_t mbs;
2429
2405 MEMZERO(&mbs, sizeof (mbs));
2406 mbs.param[0] = MBOX_GET_PORT_NAME;
2407 if (FCPARAM(isp)->isp_2klogin || IS_24XX(isp)) {
2430 if (fcp->isp_fwstate < FW_READY ||
2431 fcp->isp_loopstate < LOOP_PDB_RCVD) {
2432 return (wwn);
2433 }
2434 MBSINIT(&mbs, MBOX_GET_PORT_NAME, MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR, 500000);
2435 if (ISP_CAP_2KLOGIN(isp)) {
2408 mbs.param[1] = loopid;
2409 mbs.ibits = (1 << 10);
2410 if (nodename) {
2411 mbs.param[10] = 1;
2412 }
2436 mbs.param[1] = loopid;
2437 mbs.ibits = (1 << 10);
2438 if (nodename) {
2439 mbs.param[10] = 1;
2440 }
2441 if (ISP_CAP_MULTI_ID(isp)) {
2442 mbs.ibits |= (1 << 9);
2443 mbs.param[9] = chan;
2444 }
2413 } else {
2414 mbs.param[1] = loopid << 8;
2415 if (nodename) {
2416 mbs.param[1] |= 1;
2417 }
2418 }
2445 } else {
2446 mbs.param[1] = loopid << 8;
2447 if (nodename) {
2448 mbs.param[1] |= 1;
2449 }
2450 }
2419 mbs.logval = MBLOGALL & ~MBOX_COMMAND_PARAM_ERROR;
2420 isp_mboxcmd(isp, &mbs);
2421 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2422 return (wwn);
2423 }
2424 if (IS_24XX(isp)) {
2425 wwn =
2451 isp_mboxcmd(isp, &mbs);
2452 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2453 return (wwn);
2454 }
2455 if (IS_24XX(isp)) {
2456 wwn =
2426 (((uint64_t)(mbs.param[2] >> 8)) << 56) |
2457 (((uint64_t)(mbs.param[2] >> 8)) << 56) |
2427 (((uint64_t)(mbs.param[2] & 0xff)) << 48) |
2428 (((uint64_t)(mbs.param[3] >> 8)) << 40) |
2429 (((uint64_t)(mbs.param[3] & 0xff)) << 32) |
2430 (((uint64_t)(mbs.param[6] >> 8)) << 24) |
2431 (((uint64_t)(mbs.param[6] & 0xff)) << 16) |
2432 (((uint64_t)(mbs.param[7] >> 8)) << 8) |
2433 (((uint64_t)(mbs.param[7] & 0xff)));
2434 } else {

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

2445 return (wwn);
2446}
2447
2448/*
2449 * Make sure we have good FC link.
2450 */
2451
2452static int
2458 (((uint64_t)(mbs.param[2] & 0xff)) << 48) |
2459 (((uint64_t)(mbs.param[3] >> 8)) << 40) |
2460 (((uint64_t)(mbs.param[3] & 0xff)) << 32) |
2461 (((uint64_t)(mbs.param[6] >> 8)) << 24) |
2462 (((uint64_t)(mbs.param[6] & 0xff)) << 16) |
2463 (((uint64_t)(mbs.param[7] >> 8)) << 8) |
2464 (((uint64_t)(mbs.param[7] & 0xff)));
2465 } else {

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

2476 return (wwn);
2477}
2478
2479/*
2480 * Make sure we have good FC link.
2481 */
2482
2483static int
2453isp_fclink_test(ispsoftc_t *isp, int usdelay)
2484isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
2454{
2485{
2455 static const char *toponames[] = {
2456 "Private Loop",
2457 "FL Port",
2458 "N-Port to N-Port",
2459 "F Port",
2460 "F Port (no FLOGI_ACC response)"
2461 };
2462 mbreg_t mbs;
2486 mbreg_t mbs;
2463 int count, check_for_fabric;
2487 int count, check_for_fabric, r;
2464 uint8_t lwfs;
2465 int loopid;
2466 fcparam *fcp;
2467 fcportdb_t *lp;
2468 isp_pdb_t pdb;
2469
2488 uint8_t lwfs;
2489 int loopid;
2490 fcparam *fcp;
2491 fcportdb_t *lp;
2492 isp_pdb_t pdb;
2493
2470 fcp = isp->isp_param;
2494 fcp = FCPARAM(isp, chan);
2471
2495
2472 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Link Test Entry");
2473 ISP_MARK_PORTDB(isp, 1);
2496 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d FC Link Test Entry", chan);
2497 ISP_MARK_PORTDB(isp, chan, 1);
2474
2475 /*
2476 * Wait up to N microseconds for F/W to go to a ready state.
2477 */
2478 lwfs = FW_CONFIG_WAIT;
2479 count = 0;
2480 while (count < usdelay) {
2481 uint64_t enano;
2482 uint32_t wrk;
2483 NANOTIME_T hra, hrb;
2484
2485 GET_NANOTIME(&hra);
2498
2499 /*
2500 * Wait up to N microseconds for F/W to go to a ready state.
2501 */
2502 lwfs = FW_CONFIG_WAIT;
2503 count = 0;
2504 while (count < usdelay) {
2505 uint64_t enano;
2506 uint32_t wrk;
2507 NANOTIME_T hra, hrb;
2508
2509 GET_NANOTIME(&hra);
2486 isp_fw_state(isp);
2510 isp_fw_state(isp, chan);
2487 if (lwfs != fcp->isp_fwstate) {
2511 if (lwfs != fcp->isp_fwstate) {
2488 isp_prt(isp, ISP_LOGCONFIG|ISP_LOGSANCFG,
2489 "Firmware State <%s->%s>",
2490 ispfc_fw_statename((int)lwfs),
2491 ispfc_fw_statename((int)fcp->isp_fwstate));
2512 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));
2492 lwfs = fcp->isp_fwstate;
2493 }
2494 if (fcp->isp_fwstate == FW_READY) {
2495 break;
2496 }
2497 GET_NANOTIME(&hrb);
2498
2499 /*
2500 * Get the elapsed time in nanoseconds.
2501 * Always guaranteed to be non-zero.
2502 */
2503 enano = NANOTIME_SUB(&hrb, &hra);
2504
2513 lwfs = fcp->isp_fwstate;
2514 }
2515 if (fcp->isp_fwstate == FW_READY) {
2516 break;
2517 }
2518 GET_NANOTIME(&hrb);
2519
2520 /*
2521 * Get the elapsed time in nanoseconds.
2522 * Always guaranteed to be non-zero.
2523 */
2524 enano = NANOTIME_SUB(&hrb, &hra);
2525
2505 isp_prt(isp, ISP_LOGDEBUG1,
2506 "usec%d: 0x%lx->0x%lx enano 0x%x%08x",
2507 count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb),
2508 (uint32_t)(enano >> 32), (uint32_t)(enano & 0xffffffff));
2526 isp_prt(isp, ISP_LOGDEBUG1, "usec%d: 0x%lx->0x%lx enano 0x%x%08x", count, (long) GET_NANOSEC(&hra), (long) GET_NANOSEC(&hrb), (uint32_t)(enano >> 32), (uint32_t)(enano));
2509
2510 /*
2511 * If the elapsed time is less than 1 millisecond,
2512 * delay a period of time up to that millisecond of
2513 * waiting.
2514 *
2515 * This peculiar code is an attempt to try and avoid
2516 * invoking uint64_t math support functions for some
2517 * platforms where linkage is a problem.
2518 */
2519 if (enano < (1000 * 1000)) {
2520 count += 1000;
2521 enano = (1000 * 1000) - enano;
2522 while (enano > (uint64_t) 4000000000U) {
2527
2528 /*
2529 * If the elapsed time is less than 1 millisecond,
2530 * delay a period of time up to that millisecond of
2531 * waiting.
2532 *
2533 * This peculiar code is an attempt to try and avoid
2534 * invoking uint64_t math support functions for some
2535 * platforms where linkage is a problem.
2536 */
2537 if (enano < (1000 * 1000)) {
2538 count += 1000;
2539 enano = (1000 * 1000) - enano;
2540 while (enano > (uint64_t) 4000000000U) {
2523 USEC_SLEEP(isp, 4000000);
2541 ISP_SLEEP(isp, 4000000);
2524 enano -= (uint64_t) 4000000000U;
2525 }
2526 wrk = enano;
2527 wrk /= 1000;
2542 enano -= (uint64_t) 4000000000U;
2543 }
2544 wrk = enano;
2545 wrk /= 1000;
2528 USEC_SLEEP(isp, wrk);
2546 ISP_SLEEP(isp, wrk);
2529 } else {
2530 while (enano > (uint64_t) 4000000000U) {
2531 count += 4000000;
2532 enano -= (uint64_t) 4000000000U;
2533 }
2534 wrk = enano;
2535 count += (wrk / 1000);
2536 }
2537 }
2538
2547 } else {
2548 while (enano > (uint64_t) 4000000000U) {
2549 count += 4000000;
2550 enano -= (uint64_t) 4000000000U;
2551 }
2552 wrk = enano;
2553 count += (wrk / 1000);
2554 }
2555 }
2556
2557
2558
2539 /*
2540 * If we haven't gone to 'ready' state, return.
2541 */
2542 if (fcp->isp_fwstate != FW_READY) {
2559 /*
2560 * If we haven't gone to 'ready' state, return.
2561 */
2562 if (fcp->isp_fwstate != FW_READY) {
2543 isp_prt(isp, ISP_LOGSANCFG,
2544 "isp_fclink_test: not at FW_READY state");
2563 isp_prt(isp, ISP_LOGSANCFG, "%s: chan %d not at FW_READY state", __func__, chan);
2545 return (-1);
2546 }
2547
2548 /*
2549 * Get our Loop ID and Port ID.
2550 */
2564 return (-1);
2565 }
2566
2567 /*
2568 * Get our Loop ID and Port ID.
2569 */
2551 MEMZERO(&mbs, sizeof (mbs));
2552 mbs.param[0] = MBOX_GET_LOOP_ID;
2553 mbs.logval = MBLOGALL;
2570 MBSINIT(&mbs, MBOX_GET_LOOP_ID, MBLOGALL, 0);
2571 if (ISP_CAP_MULTI_ID(isp)) {
2572 mbs.param[9] = chan;
2573 mbs.ibits = (1 << 9);
2574 mbs.obits = (1 << 7);
2575 }
2554 isp_mboxcmd(isp, &mbs);
2555 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2556 return (-1);
2557 }
2558
2576 isp_mboxcmd(isp, &mbs);
2577 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
2578 return (-1);
2579 }
2580
2559 if (FCPARAM(isp)->isp_2klogin) {
2581 if (ISP_CAP_2KLOGIN(isp)) {
2560 fcp->isp_loopid = mbs.param[1];
2561 } else {
2562 fcp->isp_loopid = mbs.param[1] & 0xff;
2563 }
2564
2565 if (IS_2100(isp)) {
2566 fcp->isp_topo = TOPO_NL_PORT;
2567 } else {

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

2578 * Don't bother with fabric if we are using really old
2579 * 2100 firmware. It's just not worth it.
2580 */
2581 if (ISP_FW_NEWER_THAN(isp, 1, 15, 37)) {
2582 check_for_fabric = 1;
2583 } else {
2584 check_for_fabric = 0;
2585 }
2582 fcp->isp_loopid = mbs.param[1];
2583 } else {
2584 fcp->isp_loopid = mbs.param[1] & 0xff;
2585 }
2586
2587 if (IS_2100(isp)) {
2588 fcp->isp_topo = TOPO_NL_PORT;
2589 } else {

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

2600 * Don't bother with fabric if we are using really old
2601 * 2100 firmware. It's just not worth it.
2602 */
2603 if (ISP_FW_NEWER_THAN(isp, 1, 15, 37)) {
2604 check_for_fabric = 1;
2605 } else {
2606 check_for_fabric = 0;
2607 }
2586 } else if (fcp->isp_topo == TOPO_FL_PORT ||
2587 fcp->isp_topo == TOPO_F_PORT) {
2608 } else if (fcp->isp_topo == TOPO_FL_PORT || fcp->isp_topo == TOPO_F_PORT) {
2588 check_for_fabric = 1;
2589 } else {
2590 check_for_fabric = 0;
2591 }
2592
2609 check_for_fabric = 1;
2610 } else {
2611 check_for_fabric = 0;
2612 }
2613
2593 if (IS_24XX(isp)) {
2614 /*
2615 * Check to make sure we got a valid loopid
2616 * The 24XX seems to mess this up for multiple channels.
2617 */
2618 if (fcp->isp_topo == TOPO_FL_PORT || fcp->isp_topo == TOPO_NL_PORT) {
2619 uint8_t alpa = fcp->isp_portid;
2620
2621 if (alpa == 0) {
2622 /* "Cannot Happen" */
2623 isp_prt(isp, ISP_LOGWARN, "Zero AL_PA for Loop Topology?");
2624 } else {
2625 int i;
2626 for (i = 0; alpa_map[i]; i++) {
2627 if (alpa_map[i] == alpa) {
2628 break;
2629 }
2630 }
2631 if (alpa_map[i] && fcp->isp_loopid != i) {
2632 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);
2633 fcp->isp_loopid = i;
2634 }
2635 }
2636 }
2637
2638
2639 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE FOR 2K F/W? XXX */
2594 loopid = NPH_FL_ID;
2595 } else {
2596 loopid = FL_ID;
2597 }
2640 loopid = NPH_FL_ID;
2641 } else {
2642 loopid = FL_ID;
2643 }
2598
2599 if (check_for_fabric && isp_getpdb(isp, loopid, &pdb, 1) == 0) {
2600 int r;
2644 if (check_for_fabric) {
2645 r = isp_getpdb(isp, chan, loopid, &pdb, 1);
2646 if (r && (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT)) {
2647 isp_prt(isp, ISP_LOGWARN, "fabric topology but cannot get info about fabric controller (0x%x)", r);
2648 fcp->isp_topo = TOPO_PTP_STUB;
2649 }
2650 } else {
2651 r = -1;
2652 }
2653 if (r == 0) {
2601 if (IS_2100(isp)) {
2602 fcp->isp_topo = TOPO_FL_PORT;
2603 }
2604 if (pdb.portid == 0) {
2605 /*
2606 * Crock.
2607 */
2608 fcp->isp_topo = TOPO_NL_PORT;

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

2617 MAKE_WWN_FROM_NODE_NAME(lp->node_wwn, pdb.nodename);
2618 MAKE_WWN_FROM_NODE_NAME(lp->port_wwn, pdb.portname);
2619 lp->roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
2620 lp->portid = pdb.portid;
2621 lp->handle = pdb.handle;
2622 lp->new_portid = lp->portid;
2623 lp->new_roles = lp->roles;
2624 if (IS_24XX(isp)) {
2654 if (IS_2100(isp)) {
2655 fcp->isp_topo = TOPO_FL_PORT;
2656 }
2657 if (pdb.portid == 0) {
2658 /*
2659 * Crock.
2660 */
2661 fcp->isp_topo = TOPO_NL_PORT;

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

2670 MAKE_WWN_FROM_NODE_NAME(lp->node_wwn, pdb.nodename);
2671 MAKE_WWN_FROM_NODE_NAME(lp->port_wwn, pdb.portname);
2672 lp->roles = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
2673 lp->portid = pdb.portid;
2674 lp->handle = pdb.handle;
2675 lp->new_portid = lp->portid;
2676 lp->new_roles = lp->roles;
2677 if (IS_24XX(isp)) {
2625 r = isp_register_fc4_type_24xx(isp);
2678 fcp->inorder = (mbs.param[7] & ISP24XX_INORDER) != 0;
2679 if (ISP_FW_NEWER_THAN(isp, 4, 0, 27)) {
2680 fcp->npiv_fabric = (mbs.param[7] & ISP24XX_NPIV_SAN) != 0;
2681 if (fcp->npiv_fabric) {
2682 isp_prt(isp, ISP_LOGCONFIG, "fabric supports NP-IV");
2683 }
2684 }
2685 if (chan) {
2686 fcp->isp_sns_hdl = NPH_SNS_HDLBASE + chan;
2687 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);
2688 if (r) {
2689 isp_prt(isp, ISP_LOGWARN, "%s: Chan %d cannot log into SNS", __func__, chan);
2690 return (-1);
2691 }
2692 } else {
2693 fcp->isp_sns_hdl = NPH_SNS_ID;
2694 }
2695 r = isp_register_fc4_type_24xx(isp, chan);
2626 } else {
2696 } else {
2627 r = isp_register_fc4_type(isp);
2697 fcp->isp_sns_hdl = SNS_ID;
2698 r = isp_register_fc4_type(isp, chan);
2628 }
2629 if (r) {
2699 }
2700 if (r) {
2630 isp_prt(isp, ISP_LOGSANCFG,
2631 "isp_fclink_test: register fc4 type failed");
2701 isp_prt(isp, ISP_LOGWARN|ISP_LOGSANCFG, "%s: register fc4 type failed", __func__);
2632 return (-1);
2633 }
2634 } else {
2635not_on_fabric:
2636 fcp->portdb[FL_ID].state = FC_PORTDB_STATE_NIL;
2637 }
2638
2639 fcp->isp_gbspeed = 1;
2640 if (IS_23XX(isp) || IS_24XX(isp)) {
2702 return (-1);
2703 }
2704 } else {
2705not_on_fabric:
2706 fcp->portdb[FL_ID].state = FC_PORTDB_STATE_NIL;
2707 }
2708
2709 fcp->isp_gbspeed = 1;
2710 if (IS_23XX(isp) || IS_24XX(isp)) {
2641 MEMZERO(&mbs, sizeof (mbs));
2642 mbs.param[0] = MBOX_GET_SET_DATA_RATE;
2711 MBSINIT(&mbs, MBOX_GET_SET_DATA_RATE, MBLOGALL, 3000000);
2643 mbs.param[1] = MBGSD_GET_RATE;
2644 /* mbs.param[2] undefined if we're just getting rate */
2712 mbs.param[1] = MBGSD_GET_RATE;
2713 /* mbs.param[2] undefined if we're just getting rate */
2645 mbs.logval = MBLOGALL;
2646 mbs.timeout = 3000000;
2647 isp_mboxcmd(isp, &mbs);
2648 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
2714 isp_mboxcmd(isp, &mbs);
2715 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
2649 if (mbs.param[1] == MBGSD_FOURGB) {
2650 isp_prt(isp, ISP_LOGINFO, "4Gb link speed/s");
2716 if (mbs.param[1] == MBGSD_EIGHTGB) {
2717 isp_prt(isp, ISP_LOGINFO, "Chan %d 8Gb link speed", chan);
2718 fcp->isp_gbspeed = 8;
2719 } else if (mbs.param[1] == MBGSD_FOURGB) {
2720 isp_prt(isp, ISP_LOGINFO, "Chan %d 4Gb link speed", chan);
2651 fcp->isp_gbspeed = 4;
2721 fcp->isp_gbspeed = 4;
2652 } if (mbs.param[1] == MBGSD_TWOGB) {
2653 isp_prt(isp, ISP_LOGINFO, "2Gb link speed/s");
2722 } else if (mbs.param[1] == MBGSD_TWOGB) {
2723 isp_prt(isp, ISP_LOGINFO, "Chan %d 2Gb link speed", chan);
2654 fcp->isp_gbspeed = 2;
2724 fcp->isp_gbspeed = 2;
2725 } else if (mbs.param[1] == MBGSD_ONEGB) {
2726 isp_prt(isp, ISP_LOGINFO, "Chan %d 1Gb link speed", chan);
2727 fcp->isp_gbspeed = 1;
2655 }
2656 }
2657 }
2658
2659 /*
2660 * Announce ourselves, too.
2661 */
2728 }
2729 }
2730 }
2731
2732 /*
2733 * Announce ourselves, too.
2734 */
2662 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGCONFIG, topology, fcp->isp_portid,
2663 fcp->isp_loopid, toponames[fcp->isp_topo]);
2664 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGCONFIG, ourwwn,
2665 (uint32_t) (ISP_NODEWWN(isp) >> 32),
2666 (uint32_t) ISP_NODEWWN(isp),
2667 (uint32_t) (ISP_PORTWWN(isp) >> 32),
2668 (uint32_t) ISP_PORTWWN(isp));
2669 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Link Test Complete");
2735 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));
2736 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Chan %d FC Link Test Complete", chan);
2670 return (0);
2671}
2672
2737 return (0);
2738}
2739
2673static const char *
2674ispfc_fw_statename(int state)
2675{
2676 switch(state) {
2677 case FW_CONFIG_WAIT: return "Config Wait";
2678 case FW_WAIT_AL_PA: return "Waiting for AL_PA";
2679 case FW_WAIT_LOGIN: return "Wait Login";
2680 case FW_READY: return "Ready";
2681 case FW_LOSS_OF_SYNC: return "Loss Of Sync";
2682 case FW_ERROR: return "Error";
2683 case FW_REINIT: return "Re-Init";
2684 case FW_NON_PART: return "Nonparticipating";
2685 default: return "?????";
2686 }
2687}
2688
2689/*
2690 * Complete the synchronization of our Port Database.
2691 *
2692 * At this point, we've scanned the local loop (if any) and the fabric
2693 * and performed fabric logins on all new devices.
2694 *
2695 * Our task here is to go through our port database and remove any entities
2696 * that are still marked probational (issuing PLOGO for ones which we had

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

2702 * as an old device or as a newly arrived device (and notify the outer
2703 * layer appropriately).
2704 *
2705 * We also do initiator map target id assignment here for new initiator
2706 * devices and refresh old ones ot make sure that they point to the corret
2707 * entities.
2708 */
2709static int
2740/*
2741 * Complete the synchronization of our Port Database.
2742 *
2743 * At this point, we've scanned the local loop (if any) and the fabric
2744 * and performed fabric logins on all new devices.
2745 *
2746 * Our task here is to go through our port database and remove any entities
2747 * that are still marked probational (issuing PLOGO for ones which we had

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

2753 * as an old device or as a newly arrived device (and notify the outer
2754 * layer appropriately).
2755 *
2756 * We also do initiator map target id assignment here for new initiator
2757 * devices and refresh old ones ot make sure that they point to the corret
2758 * entities.
2759 */
2760static int
2710isp_pdb_sync(ispsoftc_t *isp)
2761isp_pdb_sync(ispsoftc_t *isp, int chan)
2711{
2762{
2712 fcparam *fcp = isp->isp_param;
2763 fcparam *fcp = FCPARAM(isp, chan);
2713 fcportdb_t *lp;
2714 uint16_t dbidx;
2715
2716 if (fcp->isp_loopstate == LOOP_READY) {
2717 return (0);
2718 }
2719
2720 /*

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

2727 fcp->isp_loopstate);
2728 return (-1);
2729 }
2730
2731 if (fcp->isp_topo == TOPO_FL_PORT ||
2732 fcp->isp_topo == TOPO_NL_PORT ||
2733 fcp->isp_topo == TOPO_N_PORT) {
2734 if (fcp->isp_loopstate < LOOP_LSCAN_DONE) {
2764 fcportdb_t *lp;
2765 uint16_t dbidx;
2766
2767 if (fcp->isp_loopstate == LOOP_READY) {
2768 return (0);
2769 }
2770
2771 /*

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

2778 fcp->isp_loopstate);
2779 return (-1);
2780 }
2781
2782 if (fcp->isp_topo == TOPO_FL_PORT ||
2783 fcp->isp_topo == TOPO_NL_PORT ||
2784 fcp->isp_topo == TOPO_N_PORT) {
2785 if (fcp->isp_loopstate < LOOP_LSCAN_DONE) {
2735 if (isp_scan_loop(isp) != 0) {
2786 if (isp_scan_loop(isp, chan) != 0) {
2736 isp_prt(isp, ISP_LOGWARN,
2737 "isp_pdb_sync: isp_scan_loop failed");
2738 return (-1);
2739 }
2740 }
2741 }
2742
2743 if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) {
2744 if (fcp->isp_loopstate < LOOP_FSCAN_DONE) {
2787 isp_prt(isp, ISP_LOGWARN,
2788 "isp_pdb_sync: isp_scan_loop failed");
2789 return (-1);
2790 }
2791 }
2792 }
2793
2794 if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) {
2795 if (fcp->isp_loopstate < LOOP_FSCAN_DONE) {
2745 if (isp_scan_fabric(isp) != 0) {
2796 if (isp_scan_fabric(isp, chan) != 0) {
2746 isp_prt(isp, ISP_LOGWARN,
2747 "isp_pdb_sync: isp_scan_fabric failed");
2748 return (-1);
2749 }
2750 }
2751 }
2752
2797 isp_prt(isp, ISP_LOGWARN,
2798 "isp_pdb_sync: isp_scan_fabric failed");
2799 return (-1);
2800 }
2801 }
2802 }
2803
2753 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "Synchronizing PDBs");
2804 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2805 "Chan %d Synchronizing PDBs", chan);
2754
2755 fcp->isp_loopstate = LOOP_SYNCING_PDB;
2756
2757 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
2758 lp = &fcp->portdb[dbidx];
2759
2806
2807 fcp->isp_loopstate = LOOP_SYNCING_PDB;
2808
2809 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
2810 lp = &fcp->portdb[dbidx];
2811
2760 if (lp->state == FC_PORTDB_STATE_NIL) {
2812 if (lp->state == FC_PORTDB_STATE_NIL || lp->target_mode) {
2761 continue;
2762 }
2763
2764 if (lp->state == FC_PORTDB_STATE_VALID) {
2765 if (dbidx != FL_ID) {
2766 isp_prt(isp,
2767 ISP_LOGERR, "portdb idx %d already valid",
2768 dbidx);
2769 }
2770 continue;
2771 }
2772
2773 switch (lp->state) {
2774 case FC_PORTDB_STATE_PROBATIONAL:
2775 case FC_PORTDB_STATE_DEAD:
2776 /*
2813 continue;
2814 }
2815
2816 if (lp->state == FC_PORTDB_STATE_VALID) {
2817 if (dbidx != FL_ID) {
2818 isp_prt(isp,
2819 ISP_LOGERR, "portdb idx %d already valid",
2820 dbidx);
2821 }
2822 continue;
2823 }
2824
2825 switch (lp->state) {
2826 case FC_PORTDB_STATE_PROBATIONAL:
2827 case FC_PORTDB_STATE_DEAD:
2828 /*
2777 * It's up to the outer layers to clear isp_ini_map.
2829 * It's up to the outer layers to clear isp_dev_map.
2778 */
2779 lp->state = FC_PORTDB_STATE_NIL;
2830 */
2831 lp->state = FC_PORTDB_STATE_NIL;
2780 isp_async(isp, ISPASYNC_DEV_GONE, lp);
2832 isp_async(isp, ISPASYNC_DEV_GONE, chan, lp);
2781 if (lp->autologin == 0) {
2833 if (lp->autologin == 0) {
2782 (void) isp_plogx(isp, lp->handle, lp->portid,
2834 (void) isp_plogx(isp, chan, lp->handle,
2835 lp->portid,
2783 PLOGX_FLG_CMD_LOGO |
2784 PLOGX_FLG_IMPLICIT |
2785 PLOGX_FLG_FREE_NPHDL, 0);
2786 } else {
2787 lp->autologin = 0;
2788 }
2789 lp->new_roles = 0;
2790 lp->new_portid = 0;
2791 /*
2792 * Note that we might come out of this with our state
2793 * set to FC_PORTDB_STATE_ZOMBIE.
2794 */
2795 break;
2796 case FC_PORTDB_STATE_NEW:
2797 /*
2798 * It's up to the outer layers to assign a virtual
2836 PLOGX_FLG_CMD_LOGO |
2837 PLOGX_FLG_IMPLICIT |
2838 PLOGX_FLG_FREE_NPHDL, 0);
2839 } else {
2840 lp->autologin = 0;
2841 }
2842 lp->new_roles = 0;
2843 lp->new_portid = 0;
2844 /*
2845 * Note that we might come out of this with our state
2846 * set to FC_PORTDB_STATE_ZOMBIE.
2847 */
2848 break;
2849 case FC_PORTDB_STATE_NEW:
2850 /*
2851 * It's up to the outer layers to assign a virtual
2799 * target id in isp_ini_map (if any).
2852 * target id in isp_dev_map (if any).
2800 */
2801 lp->portid = lp->new_portid;
2802 lp->roles = lp->new_roles;
2803 lp->state = FC_PORTDB_STATE_VALID;
2853 */
2854 lp->portid = lp->new_portid;
2855 lp->roles = lp->new_roles;
2856 lp->state = FC_PORTDB_STATE_VALID;
2804 isp_async(isp, ISPASYNC_DEV_ARRIVED, lp);
2857 isp_async(isp, ISPASYNC_DEV_ARRIVED, chan, lp);
2805 lp->new_roles = 0;
2806 lp->new_portid = 0;
2807 lp->reserved = 0;
2808 lp->new_reserved = 0;
2809 break;
2810 case FC_PORTDB_STATE_CHANGED:
2811/*
2812 * XXXX FIX THIS
2813 */
2814 lp->state = FC_PORTDB_STATE_VALID;
2858 lp->new_roles = 0;
2859 lp->new_portid = 0;
2860 lp->reserved = 0;
2861 lp->new_reserved = 0;
2862 break;
2863 case FC_PORTDB_STATE_CHANGED:
2864/*
2865 * XXXX FIX THIS
2866 */
2867 lp->state = FC_PORTDB_STATE_VALID;
2815 isp_async(isp, ISPASYNC_DEV_CHANGED, lp);
2868 isp_async(isp, ISPASYNC_DEV_CHANGED, chan, lp);
2816 lp->new_roles = 0;
2817 lp->new_portid = 0;
2818 lp->reserved = 0;
2819 lp->new_reserved = 0;
2820 break;
2821 case FC_PORTDB_STATE_PENDING_VALID:
2822 lp->portid = lp->new_portid;
2823 lp->roles = lp->new_roles;
2869 lp->new_roles = 0;
2870 lp->new_portid = 0;
2871 lp->reserved = 0;
2872 lp->new_reserved = 0;
2873 break;
2874 case FC_PORTDB_STATE_PENDING_VALID:
2875 lp->portid = lp->new_portid;
2876 lp->roles = lp->new_roles;
2824 if (lp->ini_map_idx) {
2825 int t = lp->ini_map_idx - 1;
2826 fcp->isp_ini_map[t] = dbidx + 1;
2877 if (lp->dev_map_idx) {
2878 int t = lp->dev_map_idx - 1;
2879 fcp->isp_dev_map[t] = dbidx + 1;
2827 }
2828 lp->state = FC_PORTDB_STATE_VALID;
2880 }
2881 lp->state = FC_PORTDB_STATE_VALID;
2829 isp_async(isp, ISPASYNC_DEV_STAYED, lp);
2882 isp_async(isp, ISPASYNC_DEV_STAYED, chan, lp);
2830 if (dbidx != FL_ID) {
2831 lp->new_roles = 0;
2832 lp->new_portid = 0;
2833 }
2834 lp->reserved = 0;
2835 lp->new_reserved = 0;
2836 break;
2837 case FC_PORTDB_STATE_ZOMBIE:
2838 break;
2839 default:
2840 isp_prt(isp, ISP_LOGWARN,
2841 "isp_scan_loop: state %d for idx %d",
2842 lp->state, dbidx);
2883 if (dbidx != FL_ID) {
2884 lp->new_roles = 0;
2885 lp->new_portid = 0;
2886 }
2887 lp->reserved = 0;
2888 lp->new_reserved = 0;
2889 break;
2890 case FC_PORTDB_STATE_ZOMBIE:
2891 break;
2892 default:
2893 isp_prt(isp, ISP_LOGWARN,
2894 "isp_scan_loop: state %d for idx %d",
2895 lp->state, dbidx);
2843 isp_dump_portdb(isp);
2896 isp_dump_portdb(isp, chan);
2844 }
2845 }
2846
2847 /*
2848 * If we get here, we've for sure seen not only a valid loop
2849 * but know what is or isn't on it, so mark this for usage
2850 * in isp_start.
2851 */
2852 fcp->loop_seen_once = 1;
2853 fcp->isp_loopstate = LOOP_READY;
2854 return (0);
2855}
2856
2857/*
2858 * Scan local loop for devices.
2859 */
2860static int
2897 }
2898 }
2899
2900 /*
2901 * If we get here, we've for sure seen not only a valid loop
2902 * but know what is or isn't on it, so mark this for usage
2903 * in isp_start.
2904 */
2905 fcp->loop_seen_once = 1;
2906 fcp->isp_loopstate = LOOP_READY;
2907 return (0);
2908}
2909
2910/*
2911 * Scan local loop for devices.
2912 */
2913static int
2861isp_scan_loop(ispsoftc_t *isp)
2914isp_scan_loop(ispsoftc_t *isp, int chan)
2862{
2863 fcportdb_t *lp, tmp;
2915{
2916 fcportdb_t *lp, tmp;
2864 fcparam *fcp = isp->isp_param;
2917 fcparam *fcp = FCPARAM(isp, chan);
2865 int i;
2866 isp_pdb_t pdb;
2867 uint16_t handle, lim = 0;
2868
2869 if (fcp->isp_fwstate < FW_READY ||
2870 fcp->isp_loopstate < LOOP_PDB_RCVD) {
2871 return (-1);
2872 }
2873
2874 if (fcp->isp_loopstate > LOOP_SCANNING_LOOP) {
2875 return (0);
2876 }
2877
2878 /*
2879 * Check our connection topology.
2880 *
2881 * If we're a public or private loop, we scan 0..125 as handle values.
2918 int i;
2919 isp_pdb_t pdb;
2920 uint16_t handle, lim = 0;
2921
2922 if (fcp->isp_fwstate < FW_READY ||
2923 fcp->isp_loopstate < LOOP_PDB_RCVD) {
2924 return (-1);
2925 }
2926
2927 if (fcp->isp_loopstate > LOOP_SCANNING_LOOP) {
2928 return (0);
2929 }
2930
2931 /*
2932 * Check our connection topology.
2933 *
2934 * If we're a public or private loop, we scan 0..125 as handle values.
2882 * The firmware has (typically) peformed a PLOGI for us.
2935 * The firmware has (typically) peformed a PLOGI for us. We skip this
2936 * step if we're a ISP_24XX in NP-IV mode.
2883 *
2884 * If we're a N-port connection, we treat this is a short loop (0..1).
2937 *
2938 * If we're a N-port connection, we treat this is a short loop (0..1).
2885 *
2886 * If we're in target mode, we can all possible handles to see who
2887 * might have logged into us.
2888 */
2889 switch (fcp->isp_topo) {
2890 case TOPO_NL_PORT:
2939 */
2940 switch (fcp->isp_topo) {
2941 case TOPO_NL_PORT:
2942 lim = LOCAL_LOOP_LIM;
2943 break;
2891 case TOPO_FL_PORT:
2944 case TOPO_FL_PORT:
2945 if (IS_24XX(isp) && isp->isp_nchan > 1) {
2946 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2947 "Chan %d Skipping Local Loop Scan", chan);
2948 fcp->isp_loopstate = LOOP_LSCAN_DONE;
2949 return (0);
2950 }
2892 lim = LOCAL_LOOP_LIM;
2893 break;
2894 case TOPO_N_PORT:
2895 lim = 2;
2896 break;
2897 default:
2951 lim = LOCAL_LOOP_LIM;
2952 break;
2953 case TOPO_N_PORT:
2954 lim = 2;
2955 break;
2956 default:
2898 isp_prt(isp, ISP_LOGDEBUG0, "no loop topology to scan");
2957 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2958 "Chan %d no loop topology to scan", chan);
2899 fcp->isp_loopstate = LOOP_LSCAN_DONE;
2900 return (0);
2901 }
2902
2903 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
2904
2959 fcp->isp_loopstate = LOOP_LSCAN_DONE;
2960 return (0);
2961 }
2962
2963 fcp->isp_loopstate = LOOP_SCANNING_LOOP;
2964
2905 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC scan loop 0..%d", lim-1);
2965 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2966 "Chan %d FC scan loop 0..%d", chan, lim-1);
2906
2907
2908 /*
2909 * Run through the list and get the port database info for each one.
2910 */
2911 for (handle = 0; handle < lim; handle++) {
2967
2968
2969 /*
2970 * Run through the list and get the port database info for each one.
2971 */
2972 for (handle = 0; handle < lim; handle++) {
2973 int r;
2912 /*
2974 /*
2913 * But don't even try for ourselves...
2914 */
2915 if (handle == fcp->isp_loopid) {
2975 * Don't scan "special" ids.
2976 */
2977 if (handle >= FL_ID && handle <= SNS_ID) {
2916 continue;
2917 }
2978 continue;
2979 }
2918
2980 if (ISP_CAP_2KLOGIN(isp)) {
2981 if (handle >= NPH_RESERVED && handle <= NPH_FL_ID) {
2982 continue;
2983 }
2984 }
2919 /*
2920 * In older cards with older f/w GET_PORT_DATABASE has been
2921 * known to hang. This trick gets around that problem.
2922 */
2923 if (IS_2100(isp) || IS_2200(isp)) {
2985 /*
2986 * In older cards with older f/w GET_PORT_DATABASE has been
2987 * known to hang. This trick gets around that problem.
2988 */
2989 if (IS_2100(isp) || IS_2200(isp)) {
2924 uint64_t node_wwn = isp_get_portname(isp, handle, 1);
2990 uint64_t node_wwn = isp_get_wwn(isp, chan, handle, 1);
2925 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2991 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2992 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
2993 "Chan %d FC scan loop DONE (bad)", chan);
2926 return (-1);
2927 }
2994 return (-1);
2995 }
2928 if (node_wwn == 0) {
2996 if (node_wwn == INI_NONE) {
2929 continue;
2930 }
2931 }
2932
2933 /*
2934 * Get the port database entity for this index.
2935 */
2997 continue;
2998 }
2999 }
3000
3001 /*
3002 * Get the port database entity for this index.
3003 */
2936 if (isp_getpdb(isp, handle, &pdb, 1) != 0) {
3004 r = isp_getpdb(isp, chan, handle, &pdb, 1);
3005 if (r != 0) {
3006 isp_prt(isp, ISP_LOGDEBUG1,
3007 "Chan %d FC scan loop handle %d returned %x",
3008 chan, handle, r);
2937 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3009 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2938 ISP_MARK_PORTDB(isp, 1);
3010 ISP_MARK_PORTDB(isp, chan, 1);
3011 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3012 "Chan %d FC scan loop DONE (bad)", chan);
2939 return (-1);
2940 }
2941 continue;
2942 }
2943
2944 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
3013 return (-1);
3014 }
3015 continue;
3016 }
3017
3018 if (fcp->isp_loopstate < LOOP_SCANNING_LOOP) {
2945 ISP_MARK_PORTDB(isp, 1);
3019 ISP_MARK_PORTDB(isp, chan, 1);
3020 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3021 "Chan %d FC scan loop DONE (bad)", chan);
2946 return (-1);
2947 }
2948
2949 /*
2950 * On *very* old 2100 firmware we would end up sometimes
2951 * with the firmware returning the port database entry
2952 * for something else. We used to restart this, but
2953 * now we just punt.
2954 */
2955 if (IS_2100(isp) && pdb.handle != handle) {
2956 isp_prt(isp, ISP_LOGWARN,
3022 return (-1);
3023 }
3024
3025 /*
3026 * On *very* old 2100 firmware we would end up sometimes
3027 * with the firmware returning the port database entry
3028 * for something else. We used to restart this, but
3029 * now we just punt.
3030 */
3031 if (IS_2100(isp) && pdb.handle != handle) {
3032 isp_prt(isp, ISP_LOGWARN,
2957 "giving up on synchronizing the port database");
2958 ISP_MARK_PORTDB(isp, 1);
3033 "Chan %d cannot synchronize port database", chan);
3034 ISP_MARK_PORTDB(isp, chan, 1);
3035 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3036 "Chan %d FC scan loop DONE (bad)", chan);
2959 return (-1);
2960 }
2961
2962 /*
2963 * Save the pertinent info locally.
2964 */
2965 MAKE_WWN_FROM_NODE_NAME(tmp.node_wwn, pdb.nodename);
2966 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname);

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

2973 * to return a portid but not a WWPN/WWNN or role for devices
2974 * which shift on a loop.
2975 */
2976 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) {
2977 int a, b, c;
2978 a = (tmp.node_wwn == 0);
2979 b = (tmp.port_wwn == 0);
2980 c = (tmp.portid == 0);
3037 return (-1);
3038 }
3039
3040 /*
3041 * Save the pertinent info locally.
3042 */
3043 MAKE_WWN_FROM_NODE_NAME(tmp.node_wwn, pdb.nodename);
3044 MAKE_WWN_FROM_NODE_NAME(tmp.port_wwn, pdb.portname);

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

3051 * to return a portid but not a WWPN/WWNN or role for devices
3052 * which shift on a loop.
3053 */
3054 if (tmp.node_wwn == 0 || tmp.port_wwn == 0 || tmp.portid == 0) {
3055 int a, b, c;
3056 a = (tmp.node_wwn == 0);
3057 b = (tmp.port_wwn == 0);
3058 c = (tmp.portid == 0);
3059 if (a == 0 && b == 0) {
3060 tmp.node_wwn =
3061 isp_get_wwn(isp, chan, handle, 1);
3062 tmp.port_wwn =
3063 isp_get_wwn(isp, chan, handle, 0);
3064 if (tmp.node_wwn && tmp.port_wwn) {
3065 isp_prt(isp, ISP_LOGINFO, "DODGED!");
3066 goto cont;
3067 }
3068 }
2981 isp_prt(isp, ISP_LOGWARN,
3069 isp_prt(isp, ISP_LOGWARN,
2982 "bad pdb (%1d%1d%1d) @ handle 0x%x", a, b, c,
2983 handle);
2984 isp_dump_portdb(isp);
3070 "Chan %d bad pdb (%1d%1d%1d) @ handle 0x%x", chan,
3071 a, b, c, handle);
3072 isp_dump_portdb(isp, chan);
2985 continue;
2986 }
3073 continue;
3074 }
3075 cont:
2987
2988 /*
2989 * Now search the entire port database
2990 * for the same Port and Node WWN.
2991 */
2992 for (i = 0; i < MAX_FC_TARG; i++) {
2993 lp = &fcp->portdb[i];
3076
3077 /*
3078 * Now search the entire port database
3079 * for the same Port and Node WWN.
3080 */
3081 for (i = 0; i < MAX_FC_TARG; i++) {
3082 lp = &fcp->portdb[i];
2994 if (lp->state == FC_PORTDB_STATE_NIL) {
3083
3084 if (lp->state == FC_PORTDB_STATE_NIL ||
3085 lp->target_mode) {
2995 continue;
2996 }
2997 if (lp->node_wwn != tmp.node_wwn) {
2998 continue;
2999 }
3000 if (lp->port_wwn != tmp.port_wwn) {
3001 continue;
3002 }
3003
3004 /*
3005 * Okay- we've found a non-nil entry that matches.
3006 * Check to make sure it's probational or a zombie.
3007 */
3008 if (lp->state != FC_PORTDB_STATE_PROBATIONAL &&
3009 lp->state != FC_PORTDB_STATE_ZOMBIE) {
3010 isp_prt(isp, ISP_LOGERR,
3086 continue;
3087 }
3088 if (lp->node_wwn != tmp.node_wwn) {
3089 continue;
3090 }
3091 if (lp->port_wwn != tmp.port_wwn) {
3092 continue;
3093 }
3094
3095 /*
3096 * Okay- we've found a non-nil entry that matches.
3097 * Check to make sure it's probational or a zombie.
3098 */
3099 if (lp->state != FC_PORTDB_STATE_PROBATIONAL &&
3100 lp->state != FC_PORTDB_STATE_ZOMBIE) {
3101 isp_prt(isp, ISP_LOGERR,
3011 "[%d] not probational/zombie (0x%x)",
3012 i, lp->state);
3013 isp_dump_portdb(isp);
3014 ISP_MARK_PORTDB(isp, 1);
3102 "Chan %d [%d] not probational/zombie (0x%x)",
3103 chan, i, lp->state);
3104 isp_dump_portdb(isp, chan);
3105 ISP_MARK_PORTDB(isp, chan, 1);
3106 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3107 "Chan %d FC scan loop DONE (bad)", chan);
3015 return (-1);
3016 }
3017
3018 /*
3019 * Mark the device as something the f/w logs into
3020 * automatically.
3021 */
3022 lp->autologin = 1;
3023
3024 /*
3025 * Check to make see if really still the same
3026 * device. If it is, we mark it pending valid.
3027 */
3028 if (lp->portid == tmp.portid &&
3029 lp->handle == tmp.handle &&
3030 lp->roles == tmp.roles) {
3031 lp->new_portid = tmp.portid;
3032 lp->new_roles = tmp.roles;
3033 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3108 return (-1);
3109 }
3110
3111 /*
3112 * Mark the device as something the f/w logs into
3113 * automatically.
3114 */
3115 lp->autologin = 1;
3116
3117 /*
3118 * Check to make see if really still the same
3119 * device. If it is, we mark it pending valid.
3120 */
3121 if (lp->portid == tmp.portid &&
3122 lp->handle == tmp.handle &&
3123 lp->roles == tmp.roles) {
3124 lp->new_portid = tmp.portid;
3125 lp->new_roles = tmp.roles;
3126 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3034 isp_prt(isp, ISP_LOGSANCFG,
3035 "Loop Port 0x%02x@0x%x Pending Valid",
3036 tmp.portid, tmp.handle);
3127 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3128 "Chan %d Loop Port 0x%06x@0x%04x Pending "
3129 "Valid", chan, tmp.portid, tmp.handle);
3037 break;
3038 }
3130 break;
3131 }
3039
3132
3040 /*
3041 * We can wipe out the old handle value
3042 * here because it's no longer valid.
3043 */
3044 lp->handle = tmp.handle;
3045
3046 /*
3047 * Claim that this has changed and let somebody else
3048 * decide what to do.
3049 */
3133 /*
3134 * We can wipe out the old handle value
3135 * here because it's no longer valid.
3136 */
3137 lp->handle = tmp.handle;
3138
3139 /*
3140 * Claim that this has changed and let somebody else
3141 * decide what to do.
3142 */
3050 isp_prt(isp, ISP_LOGSANCFG,
3051 "Loop Port 0x%02x@0x%x changed",
3052 tmp.portid, tmp.handle);
3143 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3144 "Chan %d Loop Port 0x%06x@0x%04x changed",
3145 chan, tmp.portid, tmp.handle);
3053 lp->state = FC_PORTDB_STATE_CHANGED;
3054 lp->new_portid = tmp.portid;
3055 lp->new_roles = tmp.roles;
3056 break;
3057 }
3058
3059 /*
3060 * Did we find and update an old entry?
3061 */
3062 if (i < MAX_FC_TARG) {
3063 continue;
3064 }
3065
3066 /*
3067 * Ah. A new device entry. Find an empty slot
3068 * for it and save info for later disposition.
3069 */
3070 for (i = 0; i < MAX_FC_TARG; i++) {
3146 lp->state = FC_PORTDB_STATE_CHANGED;
3147 lp->new_portid = tmp.portid;
3148 lp->new_roles = tmp.roles;
3149 break;
3150 }
3151
3152 /*
3153 * Did we find and update an old entry?
3154 */
3155 if (i < MAX_FC_TARG) {
3156 continue;
3157 }
3158
3159 /*
3160 * Ah. A new device entry. Find an empty slot
3161 * for it and save info for later disposition.
3162 */
3163 for (i = 0; i < MAX_FC_TARG; i++) {
3164 if (fcp->portdb[i].target_mode) {
3165 continue;
3166 }
3071 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) {
3072 break;
3073 }
3074 }
3075 if (i == MAX_FC_TARG) {
3167 if (fcp->portdb[i].state == FC_PORTDB_STATE_NIL) {
3168 break;
3169 }
3170 }
3171 if (i == MAX_FC_TARG) {
3076 isp_prt(isp, ISP_LOGERR, "out of portdb entries");
3172 isp_prt(isp, ISP_LOGERR,
3173 "Chan %d out of portdb entries", chan);
3077 continue;
3078 }
3079 lp = &fcp->portdb[i];
3080
3174 continue;
3175 }
3176 lp = &fcp->portdb[i];
3177
3081 MEMZERO(lp, sizeof (fcportdb_t));
3178 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3082 lp->autologin = 1;
3083 lp->state = FC_PORTDB_STATE_NEW;
3084 lp->new_portid = tmp.portid;
3085 lp->new_roles = tmp.roles;
3086 lp->handle = tmp.handle;
3087 lp->port_wwn = tmp.port_wwn;
3088 lp->node_wwn = tmp.node_wwn;
3179 lp->autologin = 1;
3180 lp->state = FC_PORTDB_STATE_NEW;
3181 lp->new_portid = tmp.portid;
3182 lp->new_roles = tmp.roles;
3183 lp->handle = tmp.handle;
3184 lp->port_wwn = tmp.port_wwn;
3185 lp->node_wwn = tmp.node_wwn;
3089 isp_prt(isp, ISP_LOGSANCFG,
3090 "Loop Port 0x%02x@0x%x is New Entry",
3091 tmp.portid, tmp.handle);
3186 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3187 "Chan %d Loop Port 0x%06x@0x%04x is New Entry",
3188 chan, tmp.portid, tmp.handle);
3092 }
3093 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3189 }
3190 fcp->isp_loopstate = LOOP_LSCAN_DONE;
3191 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3192 "Chan %d FC scan loop DONE", chan);
3094 return (0);
3095}
3096
3097/*
3098 * Scan the fabric for devices and add them to our port database.
3099 *
3100 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows.
3101 *

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

3106 * mailbox command.
3107 *
3108 * The net result is to leave the list of Port IDs setting untranslated in
3109 * offset IGPOFF of the FC scratch area, whereupon we'll canonicalize it to
3110 * host order at OGPOFF.
3111 */
3112
3113/*
3193 return (0);
3194}
3195
3196/*
3197 * Scan the fabric for devices and add them to our port database.
3198 *
3199 * Use the GID_FT command to get all Port IDs for FC4 SCSI devices it knows.
3200 *

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

3205 * mailbox command.
3206 *
3207 * The net result is to leave the list of Port IDs setting untranslated in
3208 * offset IGPOFF of the FC scratch area, whereupon we'll canonicalize it to
3209 * host order at OGPOFF.
3210 */
3211
3212/*
3114 * Take less than half of our scratch area to store Port IDs
3213 * Take less than half of our scratch area to store Port IDs
3115 */
3214 */
3116#define GIDLEN ((ISP2100_SCRLEN >> 1) - 16 - SNS_GID_FT_REQ_SIZE)
3215#define GIDLEN ((ISP_FC_SCRLEN >> 1) - 16 - SNS_GID_FT_REQ_SIZE)
3117#define NGENT ((GIDLEN - 16) >> 2)
3118
3119#define IGPOFF (2 * QENTRY_LEN)
3216#define NGENT ((GIDLEN - 16) >> 2)
3217
3218#define IGPOFF (2 * QENTRY_LEN)
3120#define OGPOFF (ISP2100_SCRLEN >> 1)
3121#define ZTXOFF (ISP2100_SCRLEN - (1 * QENTRY_LEN))
3122#define CTXOFF (ISP2100_SCRLEN - (2 * QENTRY_LEN))
3123#define XTXOFF (ISP2100_SCRLEN - (3 * QENTRY_LEN))
3219#define OGPOFF (ISP_FC_SCRLEN >> 1)
3220#define ZTXOFF (ISP_FC_SCRLEN - (1 * QENTRY_LEN))
3221#define CTXOFF (ISP_FC_SCRLEN - (2 * QENTRY_LEN))
3222#define XTXOFF (ISP_FC_SCRLEN - (3 * QENTRY_LEN))
3124
3125static int
3223
3224static int
3126isp_gid_ft_sns(ispsoftc_t *isp)
3225isp_gid_ft_sns(ispsoftc_t *isp, int chan)
3127{
3128 union {
3129 sns_gid_ft_req_t _x;
3130 uint8_t _y[SNS_GID_FT_REQ_SIZE];
3131 } un;
3226{
3227 union {
3228 sns_gid_ft_req_t _x;
3229 uint8_t _y[SNS_GID_FT_REQ_SIZE];
3230 } un;
3132 fcparam *fcp = FCPARAM(isp);
3231 fcparam *fcp = FCPARAM(isp, chan);
3133 sns_gid_ft_req_t *rq = &un._x;
3134 mbreg_t mbs;
3135
3232 sns_gid_ft_req_t *rq = &un._x;
3233 mbreg_t mbs;
3234
3136 isp_prt(isp, ISP_LOGDEBUG0, "scanning fabric (GID_FT) via SNS");
3235 isp_prt(isp, ISP_LOGDEBUG0,
3236 "Chan %d scanning fabric (GID_FT) via SNS", chan);
3137
3237
3138 MEMZERO(rq, SNS_GID_FT_REQ_SIZE);
3238 ISP_MEMZERO(rq, SNS_GID_FT_REQ_SIZE);
3139 rq->snscb_rblen = GIDLEN >> 1;
3140 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + IGPOFF);
3141 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + IGPOFF);
3142 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + IGPOFF);
3143 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + IGPOFF);
3144 rq->snscb_sblen = 6;
3145 rq->snscb_cmd = SNS_GID_FT;
3146 rq->snscb_mword_div_2 = NGENT;
3147 rq->snscb_fc4_type = FC4_SCSI;
3148
3149 isp_put_gid_ft_request(isp, rq, fcp->isp_scratch);
3150 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE);
3151
3239 rq->snscb_rblen = GIDLEN >> 1;
3240 rq->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + IGPOFF);
3241 rq->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + IGPOFF);
3242 rq->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + IGPOFF);
3243 rq->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + IGPOFF);
3244 rq->snscb_sblen = 6;
3245 rq->snscb_cmd = SNS_GID_FT;
3246 rq->snscb_mword_div_2 = NGENT;
3247 rq->snscb_fc4_type = FC4_SCSI;
3248
3249 isp_put_gid_ft_request(isp, rq, fcp->isp_scratch);
3250 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_GID_FT_REQ_SIZE);
3251
3152 MEMZERO(&mbs, sizeof (mbs));
3252 MBSINIT(&mbs, MBOX_SEND_SNS, MBLOGALL, 10000000);
3153 mbs.param[0] = MBOX_SEND_SNS;
3154 mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1;
3155 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
3156 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
3157 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
3158 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
3253 mbs.param[0] = MBOX_SEND_SNS;
3254 mbs.param[1] = SNS_GID_FT_REQ_SIZE >> 1;
3255 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
3256 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
3257 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
3258 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
3159 mbs.logval = MBLOGALL;
3160 mbs.timeout = 10000000;
3161 isp_mboxcmd(isp, &mbs);
3162 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3163 if (mbs.param[0] == MBOX_INVALID_COMMAND) {
3164 return (1);
3165 } else {
3166 return (-1);
3167 }
3168 }
3169 return (0);
3170}
3171
3172static int
3259 isp_mboxcmd(isp, &mbs);
3260 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3261 if (mbs.param[0] == MBOX_INVALID_COMMAND) {
3262 return (1);
3263 } else {
3264 return (-1);
3265 }
3266 }
3267 return (0);
3268}
3269
3270static int
3173isp_gid_ft_ct_passthru(ispsoftc_t *isp)
3271isp_gid_ft_ct_passthru(ispsoftc_t *isp, int chan)
3174{
3175 mbreg_t mbs;
3272{
3273 mbreg_t mbs;
3176 fcparam *fcp = FCPARAM(isp);
3274 fcparam *fcp = FCPARAM(isp, chan);
3177 union {
3178 isp_ct_pt_t plocal;
3179 ct_hdr_t clocal;
3180 uint8_t q[QENTRY_LEN];
3181 } un;
3182 isp_ct_pt_t *pt;
3183 ct_hdr_t *ct;
3184 uint32_t *rp;
3185 uint8_t *scp = fcp->isp_scratch;
3186
3275 union {
3276 isp_ct_pt_t plocal;
3277 ct_hdr_t clocal;
3278 uint8_t q[QENTRY_LEN];
3279 } un;
3280 isp_ct_pt_t *pt;
3281 ct_hdr_t *ct;
3282 uint32_t *rp;
3283 uint8_t *scp = fcp->isp_scratch;
3284
3187 isp_prt(isp, ISP_LOGDEBUG0, "scanning fabric (GID_FT) via CT");
3285 isp_prt(isp, ISP_LOGDEBUG0,
3286 "Chan %d scanning fabric (GID_FT) via CT", chan);
3188
3189 if (!IS_24XX(isp)) {
3190 return (1);
3191 }
3192
3193 /*
3194 * Build a Passthrough IOCB in memory.
3195 */
3196 pt = &un.plocal;
3287
3288 if (!IS_24XX(isp)) {
3289 return (1);
3290 }
3291
3292 /*
3293 * Build a Passthrough IOCB in memory.
3294 */
3295 pt = &un.plocal;
3197 MEMZERO(un.q, QENTRY_LEN);
3296 ISP_MEMZERO(un.q, QENTRY_LEN);
3198 pt->ctp_header.rqs_entry_count = 1;
3199 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
3200 pt->ctp_handle = 0xffffffff;
3297 pt->ctp_header.rqs_entry_count = 1;
3298 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
3299 pt->ctp_handle = 0xffffffff;
3201 pt->ctp_nphdl = NPH_SNS_ID;
3300 pt->ctp_nphdl = fcp->isp_sns_hdl;
3202 pt->ctp_cmd_cnt = 1;
3301 pt->ctp_cmd_cnt = 1;
3302 pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
3203 pt->ctp_time = 30;
3204 pt->ctp_rsp_cnt = 1;
3205 pt->ctp_rsp_bcnt = GIDLEN;
3206 pt->ctp_cmd_bcnt = sizeof (*ct) + sizeof (uint32_t);
3207 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
3208 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
3209 pt->ctp_dataseg[0].ds_count = sizeof (*ct) + sizeof (uint32_t);
3210 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);

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

3216 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
3217
3218 /*
3219 * Build the CT header and command in memory.
3220 *
3221 * Note that the CT header has to end up as Big Endian format in memory.
3222 */
3223 ct = &un.clocal;
3303 pt->ctp_time = 30;
3304 pt->ctp_rsp_cnt = 1;
3305 pt->ctp_rsp_bcnt = GIDLEN;
3306 pt->ctp_cmd_bcnt = sizeof (*ct) + sizeof (uint32_t);
3307 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
3308 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
3309 pt->ctp_dataseg[0].ds_count = sizeof (*ct) + sizeof (uint32_t);
3310 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);

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

3316 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
3317
3318 /*
3319 * Build the CT header and command in memory.
3320 *
3321 * Note that the CT header has to end up as Big Endian format in memory.
3322 */
3323 ct = &un.clocal;
3224 MEMZERO(ct, sizeof (*ct));
3324 ISP_MEMZERO(ct, sizeof (*ct));
3225 ct->ct_revision = CT_REVISION;
3226 ct->ct_fcs_type = CT_FC_TYPE_FC;
3227 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
3228 ct->ct_cmd_resp = SNS_GID_FT;
3229 ct->ct_bcnt_resid = (GIDLEN - 16) >> 2;
3230
3231 isp_put_ct_hdr(isp, ct, (ct_hdr_t *) &scp[XTXOFF]);
3232 rp = (uint32_t *) &scp[XTXOFF+sizeof (*ct)];
3233 ISP_IOZPUT_32(isp, FC4_SCSI, rp);
3234 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3235 isp_print_bytes(isp, "CT HDR + payload after put",
3236 sizeof (*ct) + sizeof (uint32_t), &scp[XTXOFF]);
3237 }
3325 ct->ct_revision = CT_REVISION;
3326 ct->ct_fcs_type = CT_FC_TYPE_FC;
3327 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
3328 ct->ct_cmd_resp = SNS_GID_FT;
3329 ct->ct_bcnt_resid = (GIDLEN - 16) >> 2;
3330
3331 isp_put_ct_hdr(isp, ct, (ct_hdr_t *) &scp[XTXOFF]);
3332 rp = (uint32_t *) &scp[XTXOFF+sizeof (*ct)];
3333 ISP_IOZPUT_32(isp, FC4_SCSI, rp);
3334 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3335 isp_print_bytes(isp, "CT HDR + payload after put",
3336 sizeof (*ct) + sizeof (uint32_t), &scp[XTXOFF]);
3337 }
3238 MEMZERO(&scp[ZTXOFF], QENTRY_LEN);
3239 MEMZERO(&mbs, sizeof (mbs));
3240 mbs.param[0] = MBOX_EXEC_COMMAND_IOCB_A64;
3338 ISP_MEMZERO(&scp[ZTXOFF], QENTRY_LEN);
3339 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 500000);
3241 mbs.param[1] = QENTRY_LEN;
3242 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
3243 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
3244 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
3245 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
3340 mbs.param[1] = QENTRY_LEN;
3341 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
3342 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
3343 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
3344 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
3246 mbs.timeout = 500000;
3247 mbs.logval = MBLOGALL;
3248 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN);
3249 isp_mboxcmd(isp, &mbs);
3250 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3251 return (-1);
3252 }
3253 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN);
3254 pt = &un.plocal;
3255 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
3256 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3257 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
3258 }
3259
3260 if (pt->ctp_status && pt->ctp_status != RQCS_DATA_UNDERRUN) {
3345 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN);
3346 isp_mboxcmd(isp, &mbs);
3347 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3348 return (-1);
3349 }
3350 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN);
3351 pt = &un.plocal;
3352 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
3353 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3354 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
3355 }
3356
3357 if (pt->ctp_status && pt->ctp_status != RQCS_DATA_UNDERRUN) {
3261 isp_prt(isp, ISP_LOGWARN, "CT Passthrough returned 0x%x",
3262 pt->ctp_status);
3358 isp_prt(isp, ISP_LOGWARN,
3359 "Chan %d ISP GID FT CT Passthrough returned 0x%x",
3360 chan, pt->ctp_status);
3263 return (-1);
3264 }
3265 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN + 16);
3266 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3267 isp_print_bytes(isp, "CT response", GIDLEN+16, &scp[IGPOFF]);
3268 }
3269 return (0);
3270}
3271
3272static int
3361 return (-1);
3362 }
3363 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN + 16);
3364 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3365 isp_print_bytes(isp, "CT response", GIDLEN+16, &scp[IGPOFF]);
3366 }
3367 return (0);
3368}
3369
3370static int
3273isp_scan_fabric(ispsoftc_t *isp)
3371isp_scan_fabric(ispsoftc_t *isp, int chan)
3274{
3372{
3275 fcparam *fcp = FCPARAM(isp);
3373 fcparam *fcp = FCPARAM(isp, chan);
3276 uint32_t portid;
3374 uint32_t portid;
3277 uint16_t handle, oldhandle;
3375 uint16_t handle, oldhandle, loopid;
3376 isp_pdb_t pdb;
3278 int portidx, portlim, r;
3279 sns_gid_ft_rsp_t *rs0, *rs1;
3280
3377 int portidx, portlim, r;
3378 sns_gid_ft_rsp_t *rs0, *rs1;
3379
3281 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Scan Fabric");
3380 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3381 "Chan %d FC Scan Fabric", chan);
3282 if (fcp->isp_fwstate != FW_READY ||
3283 fcp->isp_loopstate < LOOP_LSCAN_DONE) {
3284 return (-1);
3285 }
3286 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) {
3287 return (0);
3288 }
3289 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) {
3290 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3291 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3382 if (fcp->isp_fwstate != FW_READY ||
3383 fcp->isp_loopstate < LOOP_LSCAN_DONE) {
3384 return (-1);
3385 }
3386 if (fcp->isp_loopstate > LOOP_SCANNING_FABRIC) {
3387 return (0);
3388 }
3389 if (fcp->isp_topo != TOPO_FL_PORT && fcp->isp_topo != TOPO_F_PORT) {
3390 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3391 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3292 "FC Scan Fabric Done (no fabric)");
3392 "Chan %d FC Scan Fabric Done (no fabric)", chan);
3293 return (0);
3294 }
3295
3393 return (0);
3394 }
3395
3296 FC_SCRATCH_ACQUIRE(isp);
3297 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
3396 fcp->isp_loopstate = LOOP_SCANNING_FABRIC;
3397 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
3398 isp_prt(isp, ISP_LOGERR, sacq);
3399 ISP_MARK_PORTDB(isp, chan, 1);
3400 return (-1);
3401 }
3402 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3403 FC_SCRATCH_RELEASE(isp, chan);
3404 ISP_MARK_PORTDB(isp, chan, 1);
3405 return (-1);
3406 }
3298
3407
3408 /*
3409 * Make sure we still are logged into the fabric controller.
3410 */
3411 if (IS_24XX(isp)) { /* XXX SHOULDN'T THIS BE TRUE FOR 2K F/W? XXX */
3412 loopid = NPH_FL_ID;
3413 } else {
3414 loopid = FL_ID;
3415 }
3416 r = isp_getpdb(isp, chan, loopid, &pdb, 0);
3417 if (r == MBOX_NOT_LOGGED_IN) {
3418 isp_dump_chip_portdb(isp, chan, 0);
3419 }
3420 if (r) {
3421 fcp->isp_loopstate = LOOP_PDB_RCVD;
3422 FC_SCRATCH_RELEASE(isp, chan);
3423 ISP_MARK_PORTDB(isp, chan, 1);
3424 return (-1);
3425 }
3426
3299 if (IS_24XX(isp)) {
3427 if (IS_24XX(isp)) {
3300 r = isp_gid_ft_ct_passthru(isp);
3428 r = isp_gid_ft_ct_passthru(isp, chan);
3301 } else {
3429 } else {
3302 r = isp_gid_ft_sns(isp);
3430 r = isp_gid_ft_sns(isp, chan);
3303 }
3304
3431 }
3432
3433 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3434 FC_SCRATCH_RELEASE(isp, chan);
3435 ISP_MARK_PORTDB(isp, chan, 1);
3436 return (-1);
3437 }
3438
3305 if (r > 0) {
3306 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3439 if (r > 0) {
3440 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3307 FC_SCRATCH_RELEASE(isp);
3441 FC_SCRATCH_RELEASE(isp, chan);
3308 return (0);
3309 } else if (r < 0) {
3310 fcp->isp_loopstate = LOOP_PDB_RCVD; /* try again */
3442 return (0);
3443 } else if (r < 0) {
3444 fcp->isp_loopstate = LOOP_PDB_RCVD; /* try again */
3311 FC_SCRATCH_RELEASE(isp);
3445 FC_SCRATCH_RELEASE(isp, chan);
3312 return (0);
3313 }
3446 return (0);
3447 }
3314 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3315 FC_SCRATCH_RELEASE(isp);
3316 return (-1);
3317 }
3318
3319 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN);
3320 rs0 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+IGPOFF);
3321 rs1 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+OGPOFF);
3322 isp_get_gid_ft_response(isp, rs0, rs1, NGENT);
3448
3449 MEMORYBARRIER(isp, SYNC_SFORCPU, IGPOFF, GIDLEN);
3450 rs0 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+IGPOFF);
3451 rs1 = (sns_gid_ft_rsp_t *) ((uint8_t *)fcp->isp_scratch+OGPOFF);
3452 isp_get_gid_ft_response(isp, rs0, rs1, NGENT);
3453 if (fcp->isp_loopstate < LOOP_SCANNING_FABRIC) {
3454 FC_SCRATCH_RELEASE(isp, chan);
3455 ISP_MARK_PORTDB(isp, chan, 1);
3456 return (-1);
3457 }
3323 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) {
3324 int level;
3325 if (rs1->snscb_cthdr.ct_reason == 9 &&
3326 rs1->snscb_cthdr.ct_explanation == 7) {
3327 level = ISP_LOGSANCFG|ISP_LOGDEBUG0;
3328 } else {
3329 level = ISP_LOGWARN;
3330 }
3458 if (rs1->snscb_cthdr.ct_cmd_resp != LS_ACC) {
3459 int level;
3460 if (rs1->snscb_cthdr.ct_reason == 9 &&
3461 rs1->snscb_cthdr.ct_explanation == 7) {
3462 level = ISP_LOGSANCFG|ISP_LOGDEBUG0;
3463 } else {
3464 level = ISP_LOGWARN;
3465 }
3331 isp_prt(isp, level, "Fabric Nameserver rejected GID_FT "
3332 "(Reason=0x%x Expl=0x%x)", rs1->snscb_cthdr.ct_reason,
3466 isp_prt(isp, level, "Chan %d Fabric Nameserver rejected GID_FT"
3467 " (Reason=0x%x Expl=0x%x)", chan,
3468 rs1->snscb_cthdr.ct_reason,
3333 rs1->snscb_cthdr.ct_explanation);
3469 rs1->snscb_cthdr.ct_explanation);
3334 FC_SCRATCH_RELEASE(isp);
3470 FC_SCRATCH_RELEASE(isp, chan);
3335 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3336 return (0);
3337 }
3338
3339
3340 /*
3341 * If we get this far, we certainly still have the fabric controller.
3342 */
3343 fcp->portdb[FL_ID].state = FC_PORTDB_STATE_PENDING_VALID;
3344
3345 /*
3346 * Prime the handle we will start using.
3347 */
3471 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3472 return (0);
3473 }
3474
3475
3476 /*
3477 * If we get this far, we certainly still have the fabric controller.
3478 */
3479 fcp->portdb[FL_ID].state = FC_PORTDB_STATE_PENDING_VALID;
3480
3481 /*
3482 * Prime the handle we will start using.
3483 */
3348 oldhandle = NIL_HANDLE;
3484 oldhandle = FCPARAM(isp, 0)->isp_lasthdl;
3349
3350 /*
3485
3486 /*
3351 * Okay, we now have a list of Port IDs for all FC4 SCSI devices
3352 * that the Fabric Name server knows about. Go through the list
3353 * and remove duplicate port ids.
3487 * Go through the list and remove duplicate port ids.
3354 */
3355
3356 portlim = 0;
3357 portidx = 0;
3358 for (portidx = 0; portidx < NGENT-1; portidx++) {
3359 if (rs1->snscb_ports[portidx].control & 0x80) {
3360 break;
3361 }
3362 }
3363
3364 /*
3365 * If we're not at the last entry, our list wasn't big enough.
3366 */
3367 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) {
3368 isp_prt(isp, ISP_LOGWARN,
3488 */
3489
3490 portlim = 0;
3491 portidx = 0;
3492 for (portidx = 0; portidx < NGENT-1; portidx++) {
3493 if (rs1->snscb_ports[portidx].control & 0x80) {
3494 break;
3495 }
3496 }
3497
3498 /*
3499 * If we're not at the last entry, our list wasn't big enough.
3500 */
3501 if ((rs1->snscb_ports[portidx].control & 0x80) == 0) {
3502 isp_prt(isp, ISP_LOGWARN,
3369 "fabric too big for scratch area: increase ISP2100_SCRLEN");
3503 "fabric too big for scratch area: increase ISP_FC_SCRLEN");
3370 }
3371 portlim = portidx + 1;
3372 isp_prt(isp, ISP_LOGSANCFG,
3504 }
3505 portlim = portidx + 1;
3506 isp_prt(isp, ISP_LOGSANCFG,
3373 "got %d ports back from name server", portlim);
3507 "Chan %d got %d ports back from name server", chan, portlim);
3374
3375 for (portidx = 0; portidx < portlim; portidx++) {
3376 int npidx;
3377
3378 portid =
3379 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3380 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3381 ((rs1->snscb_ports[portidx].portid[2]));

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

3390 }
3391 }
3392
3393 if (npidx < portlim) {
3394 rs1->snscb_ports[npidx].portid[0] = 0;
3395 rs1->snscb_ports[npidx].portid[1] = 0;
3396 rs1->snscb_ports[npidx].portid[2] = 0;
3397 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3508
3509 for (portidx = 0; portidx < portlim; portidx++) {
3510 int npidx;
3511
3512 portid =
3513 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3514 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3515 ((rs1->snscb_ports[portidx].portid[2]));

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

3524 }
3525 }
3526
3527 if (npidx < portlim) {
3528 rs1->snscb_ports[npidx].portid[0] = 0;
3529 rs1->snscb_ports[npidx].portid[1] = 0;
3530 rs1->snscb_ports[npidx].portid[2] = 0;
3531 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3398 "removing duplicate PortID 0x%x entry from list",
3399 portid);
3532 "Chan %d removing duplicate PortID 0x%06x"
3533 " entry from list", chan, portid);
3400 }
3401 }
3402
3403 /*
3534 }
3535 }
3536
3537 /*
3404 * Okay, we now have a list of Port IDs for all FC4 SCSI devices
3538 * We now have a list of Port IDs for all FC4 SCSI devices
3405 * that the Fabric Name server knows about.
3406 *
3407 * For each entry on this list go through our port database looking
3408 * for probational entries- if we find one, then an old entry is
3539 * that the Fabric Name server knows about.
3540 *
3541 * For each entry on this list go through our port database looking
3542 * for probational entries- if we find one, then an old entry is
3409 * is maybe still this one. We get some information to find out.
3543 * maybe still this one. We get some information to find out.
3410 *
3411 * Otherwise, it's a new fabric device, and we log into it
3412 * (unconditionally). After searching the entire database
3413 * again to make sure that we never ever ever ever have more
3414 * than one entry that has the same PortID or the same
3415 * WWNN/WWPN duple, we enter the device into our database.
3416 */
3417
3418 for (portidx = 0; portidx < portlim; portidx++) {
3419 fcportdb_t *lp;
3544 *
3545 * Otherwise, it's a new fabric device, and we log into it
3546 * (unconditionally). After searching the entire database
3547 * again to make sure that we never ever ever ever have more
3548 * than one entry that has the same PortID or the same
3549 * WWNN/WWPN duple, we enter the device into our database.
3550 */
3551
3552 for (portidx = 0; portidx < portlim; portidx++) {
3553 fcportdb_t *lp;
3420 isp_pdb_t pdb;
3421 uint64_t wwnn, wwpn;
3422 int dbidx, nr;
3423
3424 portid =
3425 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3426 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3427 ((rs1->snscb_ports[portidx].portid[2]));
3428
3429 if (portid == 0) {
3430 isp_prt(isp, ISP_LOGSANCFG,
3554 uint64_t wwnn, wwpn;
3555 int dbidx, nr;
3556
3557 portid =
3558 ((rs1->snscb_ports[portidx].portid[0]) << 16) |
3559 ((rs1->snscb_ports[portidx].portid[1]) << 8) |
3560 ((rs1->snscb_ports[portidx].portid[2]));
3561
3562 if (portid == 0) {
3563 isp_prt(isp, ISP_LOGSANCFG,
3431 "skipping null PortID at idx %d", portidx);
3564 "Chan %d skipping null PortID at idx %d",
3565 chan, portidx);
3432 continue;
3433 }
3434
3435 /*
3566 continue;
3567 }
3568
3569 /*
3436 * Skip ourselves...
3570 * Skip ourselves here and on other channels. If we're
3571 * multi-id, we can't check the portids in other FCPARAM
3572 * arenas because the resolutions here aren't synchronized.
3573 * The best way to do this is to exclude looking at portids
3574 * that have the same domain and area code as our own
3575 * portid.
3437 */
3576 */
3438 if (portid == fcp->isp_portid) {
3577 if (ISP_CAP_MULTI_ID(isp)) {
3578 if ((portid >> 8) == (fcp->isp_portid >> 8)) {
3579 isp_prt(isp, ISP_LOGSANCFG,
3580 "Chan %d skip PortID 0x%06x",
3581 chan, portid);
3582 continue;
3583 }
3584 } else if (portid == fcp->isp_portid) {
3439 isp_prt(isp, ISP_LOGSANCFG,
3585 isp_prt(isp, ISP_LOGSANCFG,
3440 "skip ourselves @ PortID 0x%06x", portid);
3586 "Chan %d skip ourselves on @ PortID 0x%06x",
3587 chan, portid);
3441 continue;
3442 }
3588 continue;
3589 }
3590
3443 isp_prt(isp, ISP_LOGSANCFG,
3591 isp_prt(isp, ISP_LOGSANCFG,
3444 "Checking Fabric Port 0x%06x", portid);
3592 "Chan %d Checking Fabric Port 0x%06x", chan, portid);
3445
3446 /*
3447 * We now search our Port Database for any
3448 * probational entries with this PortID. We don't
3449 * look for zombies here- only probational
3450 * entries (we've already logged out of zombies).
3451 */
3452 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3453 lp = &fcp->portdb[dbidx];
3454
3593
3594 /*
3595 * We now search our Port Database for any
3596 * probational entries with this PortID. We don't
3597 * look for zombies here- only probational
3598 * entries (we've already logged out of zombies).
3599 */
3600 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3601 lp = &fcp->portdb[dbidx];
3602
3455 if (lp->state != FC_PORTDB_STATE_PROBATIONAL) {
3603 if (lp->state != FC_PORTDB_STATE_PROBATIONAL ||
3604 lp->target_mode) {
3456 continue;
3457 }
3458 if (lp->portid == portid) {
3459 break;
3460 }
3461 }
3462
3463 /*

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

3480 * device still (it should be). If for some
3481 * reason it isn't, mark it as a changed device
3482 * and leave the new portid and role in the
3483 * database entry for somebody further along to
3484 * decide what to do (policy choice).
3485 *
3486 */
3487
3605 continue;
3606 }
3607 if (lp->portid == portid) {
3608 break;
3609 }
3610 }
3611
3612 /*

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

3629 * device still (it should be). If for some
3630 * reason it isn't, mark it as a changed device
3631 * and leave the new portid and role in the
3632 * database entry for somebody further along to
3633 * decide what to do (policy choice).
3634 *
3635 */
3636
3488 r = isp_getpdb(isp, lp->handle, &pdb, 0);
3637 r = isp_getpdb(isp, chan, lp->handle, &pdb, 0);
3489 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3638 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3490 FC_SCRATCH_RELEASE(isp);
3491 ISP_MARK_PORTDB(isp, 1);
3639 FC_SCRATCH_RELEASE(isp, chan);
3640 ISP_MARK_PORTDB(isp, chan, 1);
3492 return (-1);
3493 }
3494 if (r != 0) {
3495 lp->new_portid = portid;
3496 lp->state = FC_PORTDB_STATE_DEAD;
3497 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3641 return (-1);
3642 }
3643 if (r != 0) {
3644 lp->new_portid = portid;
3645 lp->state = FC_PORTDB_STATE_DEAD;
3646 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3498 "Fabric Port 0x%06x considered dead",
3499 portid);
3647 "Chan %d Fabric Port 0x%06x is dead",
3648 chan, portid);
3500 continue;
3501 }
3502
3503
3504 /*
3505 * Check to make sure that handle, portid, WWPN and
3506 * WWNN agree. If they don't, then the association
3507 * between this PortID and the stated handle has been
3508 * broken by the firmware.
3509 */
3510 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3511 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3512 if (pdb.handle != lp->handle ||
3513 pdb.portid != portid ||
3514 wwpn != lp->port_wwn ||
3515 wwnn != lp->node_wwn) {
3516 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3649 continue;
3650 }
3651
3652
3653 /*
3654 * Check to make sure that handle, portid, WWPN and
3655 * WWNN agree. If they don't, then the association
3656 * between this PortID and the stated handle has been
3657 * broken by the firmware.
3658 */
3659 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3660 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3661 if (pdb.handle != lp->handle ||
3662 pdb.portid != portid ||
3663 wwpn != lp->port_wwn ||
3664 wwnn != lp->node_wwn) {
3665 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3517 fconf, dbidx, pdb.handle, pdb.portid,
3666 fconf, chan, dbidx, pdb.handle, pdb.portid,
3518 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,
3519 (uint32_t) (wwpn >> 32), (uint32_t) wwpn,
3520 lp->handle, portid,
3521 (uint32_t) (lp->node_wwn >> 32),
3522 (uint32_t) lp->node_wwn,
3523 (uint32_t) (lp->port_wwn >> 32),
3524 (uint32_t) lp->port_wwn);
3525 /*
3526 * Try to re-login to this device using a
3527 * new handle. If that fails, mark it dead.
3667 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,
3668 (uint32_t) (wwpn >> 32), (uint32_t) wwpn,
3669 lp->handle, portid,
3670 (uint32_t) (lp->node_wwn >> 32),
3671 (uint32_t) lp->node_wwn,
3672 (uint32_t) (lp->port_wwn >> 32),
3673 (uint32_t) lp->port_wwn);
3674 /*
3675 * Try to re-login to this device using a
3676 * new handle. If that fails, mark it dead.
3528 *
3677 *
3529 * isp_login_device will check for handle and
3530 * portid consistency after re-login.
3678 * isp_login_device will check for handle and
3679 * portid consistency after re-login.
3531 *
3680 *
3532 */
3681 */
3533 if (isp_login_device(isp, portid, &pdb,
3682 if (isp_login_device(isp, chan, portid, &pdb,
3534 &oldhandle)) {
3535 lp->new_portid = portid;
3536 lp->state = FC_PORTDB_STATE_DEAD;
3537 if (fcp->isp_loopstate !=
3538 LOOP_SCANNING_FABRIC) {
3683 &oldhandle)) {
3684 lp->new_portid = portid;
3685 lp->state = FC_PORTDB_STATE_DEAD;
3686 if (fcp->isp_loopstate !=
3687 LOOP_SCANNING_FABRIC) {
3539 FC_SCRATCH_RELEASE(isp);
3540 ISP_MARK_PORTDB(isp, 1);
3688 FC_SCRATCH_RELEASE(isp, chan);
3689 ISP_MARK_PORTDB(isp, chan, 1);
3541 return (-1);
3542 }
3543 continue;
3544 }
3690 return (-1);
3691 }
3692 continue;
3693 }
3694 if (fcp->isp_loopstate !=
3695 LOOP_SCANNING_FABRIC) {
3696 FC_SCRATCH_RELEASE(isp, chan);
3697 ISP_MARK_PORTDB(isp, chan, 1);
3698 return (-1);
3699 }
3700 FCPARAM(isp, 0)->isp_lasthdl = oldhandle;
3545 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3546 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3547 if (wwpn != lp->port_wwn ||
3548 wwnn != lp->node_wwn) {
3549 isp_prt(isp, ISP_LOGWARN, "changed WWN"
3550 " after relogin");
3551 lp->new_portid = portid;
3552 lp->state = FC_PORTDB_STATE_DEAD;

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

3571 * and let somebody else decide.
3572 */
3573
3574 lp->new_portid = portid;
3575 lp->new_roles = nr;
3576 if (pdb.portid != lp->portid || nr != lp->roles ||
3577 handle_changed) {
3578 isp_prt(isp, ISP_LOGSANCFG,
3701 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3702 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3703 if (wwpn != lp->port_wwn ||
3704 wwnn != lp->node_wwn) {
3705 isp_prt(isp, ISP_LOGWARN, "changed WWN"
3706 " after relogin");
3707 lp->new_portid = portid;
3708 lp->state = FC_PORTDB_STATE_DEAD;

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

3727 * and let somebody else decide.
3728 */
3729
3730 lp->new_portid = portid;
3731 lp->new_roles = nr;
3732 if (pdb.portid != lp->portid || nr != lp->roles ||
3733 handle_changed) {
3734 isp_prt(isp, ISP_LOGSANCFG,
3579 "Fabric Port 0x%06x changed", portid);
3735 "Chan %d Fabric Port 0x%06x changed",
3736 chan, portid);
3580 lp->state = FC_PORTDB_STATE_CHANGED;
3581 } else {
3582 isp_prt(isp, ISP_LOGSANCFG,
3737 lp->state = FC_PORTDB_STATE_CHANGED;
3738 } else {
3739 isp_prt(isp, ISP_LOGSANCFG,
3583 "Fabric Port 0x%06x Now Pending Valid",
3584 portid);
3740 "Chan %d Fabric Port 0x%06x "
3741 "Now Pending Valid", chan, portid);
3585 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3586 }
3587 continue;
3588 }
3589
3590 /*
3591 * Ah- a new entry. Search the database again for all non-NIL
3592 * entries to make sure we never ever make a new database entry
3593 * with the same port id. While we're at it, mark where the
3594 * last free entry was.
3595 */
3742 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3743 }
3744 continue;
3745 }
3746
3747 /*
3748 * Ah- a new entry. Search the database again for all non-NIL
3749 * entries to make sure we never ever make a new database entry
3750 * with the same port id. While we're at it, mark where the
3751 * last free entry was.
3752 */
3596
3753
3597 dbidx = MAX_FC_TARG;
3598 for (lp = fcp->portdb; lp < &fcp->portdb[MAX_FC_TARG]; lp++) {
3599 if (lp >= &fcp->portdb[FL_ID] &&
3600 lp <= &fcp->portdb[SNS_ID]) {
3601 continue;
3602 }
3754 dbidx = MAX_FC_TARG;
3755 for (lp = fcp->portdb; lp < &fcp->portdb[MAX_FC_TARG]; lp++) {
3756 if (lp >= &fcp->portdb[FL_ID] &&
3757 lp <= &fcp->portdb[SNS_ID]) {
3758 continue;
3759 }
3760 /*
3761 * Skip any target mode entries.
3762 */
3763 if (lp->target_mode) {
3764 continue;
3765 }
3603 if (lp->state == FC_PORTDB_STATE_NIL) {
3604 if (dbidx == MAX_FC_TARG) {
3605 dbidx = lp - fcp->portdb;
3606 }
3607 continue;
3608 }
3609 if (lp->state == FC_PORTDB_STATE_ZOMBIE) {
3610 continue;
3611 }
3612 if (lp->portid == portid) {
3613 break;
3614 }
3615 }
3616
3617 if (lp < &fcp->portdb[MAX_FC_TARG]) {
3766 if (lp->state == FC_PORTDB_STATE_NIL) {
3767 if (dbidx == MAX_FC_TARG) {
3768 dbidx = lp - fcp->portdb;
3769 }
3770 continue;
3771 }
3772 if (lp->state == FC_PORTDB_STATE_ZOMBIE) {
3773 continue;
3774 }
3775 if (lp->portid == portid) {
3776 break;
3777 }
3778 }
3779
3780 if (lp < &fcp->portdb[MAX_FC_TARG]) {
3618 isp_prt(isp, ISP_LOGWARN,
3619 "PortID 0x%06x already at %d handle %d state %d",
3620 portid, dbidx, lp->handle, lp->state);
3781 isp_prt(isp, ISP_LOGWARN, "Chan %d PortID 0x%06x "
3782 "already at %d handle %d state %d",
3783 chan, portid, dbidx, lp->handle, lp->state);
3621 continue;
3622 }
3623
3624 /*
3625 * We should have the index of the first free entry seen.
3626 */
3627 if (dbidx == MAX_FC_TARG) {
3628 isp_prt(isp, ISP_LOGERR,

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

3638
3639 /*
3640 * Try to see if we are logged into this device,
3641 * and maybe log into it.
3642 *
3643 * isp_login_device will check for handle and
3644 * portid consistency after login.
3645 */
3784 continue;
3785 }
3786
3787 /*
3788 * We should have the index of the first free entry seen.
3789 */
3790 if (dbidx == MAX_FC_TARG) {
3791 isp_prt(isp, ISP_LOGERR,

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

3801
3802 /*
3803 * Try to see if we are logged into this device,
3804 * and maybe log into it.
3805 *
3806 * isp_login_device will check for handle and
3807 * portid consistency after login.
3808 */
3646 if (isp_login_device(isp, portid, &pdb, &oldhandle)) {
3809 if (isp_login_device(isp, chan, portid, &pdb, &oldhandle)) {
3647 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3810 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3648 FC_SCRATCH_RELEASE(isp);
3649 ISP_MARK_PORTDB(isp, 1);
3811 FC_SCRATCH_RELEASE(isp, chan);
3812 ISP_MARK_PORTDB(isp, chan, 1);
3650 return (-1);
3651 }
3652 continue;
3653 }
3813 return (-1);
3814 }
3815 continue;
3816 }
3817 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3818 FC_SCRATCH_RELEASE(isp, chan);
3819 ISP_MARK_PORTDB(isp, chan, 1);
3820 return (-1);
3821 }
3822 FCPARAM(isp, 0)->isp_lasthdl = oldhandle;
3654
3655 handle = pdb.handle;
3656 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3657 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3658 nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
3659
3660 /*
3661 * And go through the database *one* more time to make sure
3662 * that we do not make more than one entry that has the same
3663 * WWNN/WWPN duple
3664 */
3665 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3666 if (dbidx >= FL_ID && dbidx <= SNS_ID) {
3667 continue;
3668 }
3823
3824 handle = pdb.handle;
3825 MAKE_WWN_FROM_NODE_NAME(wwnn, pdb.nodename);
3826 MAKE_WWN_FROM_NODE_NAME(wwpn, pdb.portname);
3827 nr = (pdb.s3_role & SVC3_ROLE_MASK) >> SVC3_ROLE_SHIFT;
3828
3829 /*
3830 * And go through the database *one* more time to make sure
3831 * that we do not make more than one entry that has the same
3832 * WWNN/WWPN duple
3833 */
3834 for (dbidx = 0; dbidx < MAX_FC_TARG; dbidx++) {
3835 if (dbidx >= FL_ID && dbidx <= SNS_ID) {
3836 continue;
3837 }
3669 if (fcp->portdb[dbidx].state == FC_PORTDB_STATE_NIL) {
3838 if (fcp->portdb[dbidx].target_mode) {
3670 continue;
3671 }
3672 if (fcp->portdb[dbidx].node_wwn == wwnn &&
3673 fcp->portdb[dbidx].port_wwn == wwpn) {
3674 break;
3675 }
3676 }
3677
3678 if (dbidx == MAX_FC_TARG) {
3839 continue;
3840 }
3841 if (fcp->portdb[dbidx].node_wwn == wwnn &&
3842 fcp->portdb[dbidx].port_wwn == wwpn) {
3843 break;
3844 }
3845 }
3846
3847 if (dbidx == MAX_FC_TARG) {
3679 MEMZERO(lp, sizeof (fcportdb_t));
3848 ISP_MEMZERO(lp, sizeof (fcportdb_t));
3680 lp->handle = handle;
3681 lp->node_wwn = wwnn;
3682 lp->port_wwn = wwpn;
3683 lp->new_portid = portid;
3684 lp->new_roles = nr;
3685 lp->state = FC_PORTDB_STATE_NEW;
3686 isp_prt(isp, ISP_LOGSANCFG,
3849 lp->handle = handle;
3850 lp->node_wwn = wwnn;
3851 lp->port_wwn = wwpn;
3852 lp->new_portid = portid;
3853 lp->new_roles = nr;
3854 lp->state = FC_PORTDB_STATE_NEW;
3855 isp_prt(isp, ISP_LOGSANCFG,
3687 "Fabric Port 0x%06x is New Entry", portid);
3856 "Chan %d Fabric Port 0x%06x is a New Entry",
3857 chan, portid);
3688 continue;
3689 }
3690
3691 if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) {
3692 isp_prt(isp, ISP_LOGWARN,
3858 continue;
3859 }
3860
3861 if (fcp->portdb[dbidx].state != FC_PORTDB_STATE_ZOMBIE) {
3862 isp_prt(isp, ISP_LOGWARN,
3693 "PortID 0x%x 0x%08x%08x/0x%08x%08x %ld already at "
3694 "idx %d, state 0x%x", portid,
3863 "Chan %d PortID 0x%x 0x%08x%08x/0x%08x%08x %ld "
3864 "already at idx %d, state 0x%x", chan, portid,
3695 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,
3696 (uint32_t) (wwpn >> 32), (uint32_t) wwpn,
3697 (long) (lp - fcp->portdb), dbidx,
3698 fcp->portdb[dbidx].state);
3699 continue;
3700 }
3701
3702 /*

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

3708 * are different, it maybe a changed device.
3709 */
3710 lp = &fcp->portdb[dbidx];
3711 lp->handle = handle;
3712 lp->new_portid = portid;
3713 lp->new_roles = nr;
3714 if (lp->portid != portid || lp->roles != nr) {
3715 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3865 (uint32_t) (wwnn >> 32), (uint32_t) wwnn,
3866 (uint32_t) (wwpn >> 32), (uint32_t) wwpn,
3867 (long) (lp - fcp->portdb), dbidx,
3868 fcp->portdb[dbidx].state);
3869 continue;
3870 }
3871
3872 /*

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

3878 * are different, it maybe a changed device.
3879 */
3880 lp = &fcp->portdb[dbidx];
3881 lp->handle = handle;
3882 lp->new_portid = portid;
3883 lp->new_roles = nr;
3884 if (lp->portid != portid || lp->roles != nr) {
3885 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3716 "Zombie Fabric Port 0x%06x Now Changed", portid);
3886 "Chan %d Zombie Fabric Port 0x%06x Now Changed",
3887 chan, portid);
3717 lp->state = FC_PORTDB_STATE_CHANGED;
3718 } else {
3719 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3888 lp->state = FC_PORTDB_STATE_CHANGED;
3889 } else {
3890 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3720 "Zombie Fabric Port 0x%06x Now Pending Valid",
3721 portid);
3891 "Chan %d Zombie Fabric Port 0x%06x "
3892 "Now Pending Valid", chan, portid);
3722 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3723 }
3724 }
3725
3893 lp->state = FC_PORTDB_STATE_PENDING_VALID;
3894 }
3895 }
3896
3726 FC_SCRATCH_RELEASE(isp);
3897 FC_SCRATCH_RELEASE(isp, chan);
3727 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3898 if (fcp->isp_loopstate != LOOP_SCANNING_FABRIC) {
3728 ISP_MARK_PORTDB(isp, 1);
3899 ISP_MARK_PORTDB(isp, chan, 1);
3729 return (-1);
3730 }
3731 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3900 return (-1);
3901 }
3902 fcp->isp_loopstate = LOOP_FSCAN_DONE;
3732 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0, "FC Scan Fabric Done");
3903 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3904 "Chan %d FC Scan Fabric Done", chan);
3733 return (0);
3734}
3735
3736/*
3737 * Find an unused handle and try and use to login to a port.
3738 */
3739static int
3905 return (0);
3906}
3907
3908/*
3909 * Find an unused handle and try and use to login to a port.
3910 */
3911static int
3740isp_login_device(ispsoftc_t *isp, uint32_t portid, isp_pdb_t *p, uint16_t *ohp)
3912isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p,
3913 uint16_t *ohp)
3741{
3742 int lim, i, r;
3743 uint16_t handle;
3744
3914{
3915 int lim, i, r;
3916 uint16_t handle;
3917
3745 if (FCPARAM(isp)->isp_2klogin) {
3918 if (ISP_CAP_2KLOGIN(isp)) {
3746 lim = NPH_MAX_2K;
3747 } else {
3748 lim = NPH_MAX;
3749 }
3750
3919 lim = NPH_MAX_2K;
3920 } else {
3921 lim = NPH_MAX;
3922 }
3923
3751 handle = isp_nxt_handle(isp, *ohp);
3924 handle = isp_nxt_handle(isp, chan, *ohp);
3752 for (i = 0; i < lim; i++) {
3753 /*
3754 * See if we're still logged into something with
3755 * this handle and that something agrees with this
3756 * port id.
3757 */
3925 for (i = 0; i < lim; i++) {
3926 /*
3927 * See if we're still logged into something with
3928 * this handle and that something agrees with this
3929 * port id.
3930 */
3758 r = isp_getpdb(isp, handle, p, 0);
3931 r = isp_getpdb(isp, chan, handle, p, 0);
3759 if (r == 0 && p->portid != portid) {
3932 if (r == 0 && p->portid != portid) {
3760 (void) isp_plogx(isp, handle, portid,
3933 (void) isp_plogx(isp, chan, handle, portid,
3761 PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT, 1);
3762 } else if (r == 0) {
3763 break;
3764 }
3934 PLOGX_FLG_CMD_LOGO | PLOGX_FLG_IMPLICIT, 1);
3935 } else if (r == 0) {
3936 break;
3937 }
3765 if (FCPARAM(isp)->isp_loopstate != LOOP_SCANNING_FABRIC) {
3938 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC) {
3766 return (-1);
3767 }
3768 /*
3769 * Now try and log into the device
3770 */
3939 return (-1);
3940 }
3941 /*
3942 * Now try and log into the device
3943 */
3771 r = isp_plogx(isp, handle, portid, PLOGX_FLG_CMD_PLOGI, 1);
3772 if (FCPARAM(isp)->isp_loopstate != LOOP_SCANNING_FABRIC) {
3944 r = isp_plogx(isp, chan, handle, portid,
3945 PLOGX_FLG_CMD_PLOGI, 1);
3946 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC) {
3773 return (-1);
3774 }
3775 if (r == 0) {
3776 *ohp = handle;
3777 break;
3778 } else if ((r & 0xffff) == MBOX_PORT_ID_USED) {
3779 handle = r >> 16;
3780 break;
3781 } else if (r != MBOX_LOOP_ID_USED) {
3782 i = lim;
3783 break;
3947 return (-1);
3948 }
3949 if (r == 0) {
3950 *ohp = handle;
3951 break;
3952 } else if ((r & 0xffff) == MBOX_PORT_ID_USED) {
3953 handle = r >> 16;
3954 break;
3955 } else if (r != MBOX_LOOP_ID_USED) {
3956 i = lim;
3957 break;
3958 } else if (r == MBOX_TIMEOUT) {
3959 return (-1);
3784 } else {
3785 *ohp = handle;
3960 } else {
3961 *ohp = handle;
3786 handle = isp_nxt_handle(isp, *ohp);
3962 handle = isp_nxt_handle(isp, chan, *ohp);
3787 }
3788 }
3789
3790 if (i == lim) {
3963 }
3964 }
3965
3966 if (i == lim) {
3791 isp_prt(isp, ISP_LOGWARN, "PLOGI 0x%06x failed", portid);
3967 isp_prt(isp, ISP_LOGWARN, "Chan %d PLOGI 0x%06x failed",
3968 chan, portid);
3792 return (-1);
3793 }
3794
3795 /*
3796 * If we successfully logged into it, get the PDB for it
3797 * so we can crosscheck that it is still what we think it
3798 * is and that we also have the role it plays
3799 */
3969 return (-1);
3970 }
3971
3972 /*
3973 * If we successfully logged into it, get the PDB for it
3974 * so we can crosscheck that it is still what we think it
3975 * is and that we also have the role it plays
3976 */
3800 r = isp_getpdb(isp, handle, p, 0);
3801 if (FCPARAM(isp)->isp_loopstate != LOOP_SCANNING_FABRIC) {
3977 r = isp_getpdb(isp, chan, handle, p, 0);
3978 if (FCPARAM(isp, chan)->isp_loopstate != LOOP_SCANNING_FABRIC) {
3802 return (-1);
3803 }
3804 if (r != 0) {
3979 return (-1);
3980 }
3981 if (r != 0) {
3805 isp_prt(isp, ISP_LOGERR, "new device 0x%06x@0x%x disappeared",
3806 portid, handle);
3982 isp_prt(isp, ISP_LOGERR,
3983 "Chan %d new device 0x%06x@0x%x disappeared",
3984 chan, portid, handle);
3807 return (-1);
3808 }
3809
3810 if (p->handle != handle || p->portid != portid) {
3811 isp_prt(isp, ISP_LOGERR,
3985 return (-1);
3986 }
3987
3988 if (p->handle != handle || p->portid != portid) {
3989 isp_prt(isp, ISP_LOGERR,
3812 "new device 0x%06x@0x%x changed (0x%06x@0x%0x)",
3813 portid, handle, p->portid, p->handle);
3990 "Chan %d new device 0x%06x@0x%x changed (0x%06x@0x%0x)",
3991 chan, portid, handle, p->portid, p->handle);
3814 return (-1);
3815 }
3816 return (0);
3817}
3818
3819static int
3992 return (-1);
3993 }
3994 return (0);
3995}
3996
3997static int
3820isp_register_fc4_type(ispsoftc_t *isp)
3998isp_register_fc4_type(ispsoftc_t *isp, int chan)
3821{
3999{
3822 fcparam *fcp = isp->isp_param;
4000 fcparam *fcp = FCPARAM(isp, chan);
3823 uint8_t local[SNS_RFT_ID_REQ_SIZE];
3824 sns_screq_t *reqp = (sns_screq_t *) local;
3825 mbreg_t mbs;
3826
4001 uint8_t local[SNS_RFT_ID_REQ_SIZE];
4002 sns_screq_t *reqp = (sns_screq_t *) local;
4003 mbreg_t mbs;
4004
3827 MEMZERO((void *) reqp, SNS_RFT_ID_REQ_SIZE);
4005 ISP_MEMZERO((void *) reqp, SNS_RFT_ID_REQ_SIZE);
3828 reqp->snscb_rblen = SNS_RFT_ID_RESP_SIZE >> 1;
3829 reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100);
3830 reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100);
3831 reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100);
3832 reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100);
3833 reqp->snscb_sblen = 22;
3834 reqp->snscb_data[0] = SNS_RFT_ID;
3835 reqp->snscb_data[4] = fcp->isp_portid & 0xffff;
3836 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff;
3837 reqp->snscb_data[6] = (1 << FC4_SCSI);
4006 reqp->snscb_rblen = SNS_RFT_ID_RESP_SIZE >> 1;
4007 reqp->snscb_addr[RQRSP_ADDR0015] = DMA_WD0(fcp->isp_scdma + 0x100);
4008 reqp->snscb_addr[RQRSP_ADDR1631] = DMA_WD1(fcp->isp_scdma + 0x100);
4009 reqp->snscb_addr[RQRSP_ADDR3247] = DMA_WD2(fcp->isp_scdma + 0x100);
4010 reqp->snscb_addr[RQRSP_ADDR4863] = DMA_WD3(fcp->isp_scdma + 0x100);
4011 reqp->snscb_sblen = 22;
4012 reqp->snscb_data[0] = SNS_RFT_ID;
4013 reqp->snscb_data[4] = fcp->isp_portid & 0xffff;
4014 reqp->snscb_data[5] = (fcp->isp_portid >> 16) & 0xff;
4015 reqp->snscb_data[6] = (1 << FC4_SCSI);
3838 FC_SCRATCH_ACQUIRE(isp);
4016 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4017 isp_prt(isp, ISP_LOGERR, sacq);
4018 return (-1);
4019 }
3839 isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch);
4020 isp_put_sns_request(isp, reqp, (sns_screq_t *) fcp->isp_scratch);
3840 MEMZERO(&mbs, sizeof (mbs));
3841 mbs.param[0] = MBOX_SEND_SNS;
4021 MBSINIT(&mbs, MBOX_SEND_SNS, MBLOGALL, 1000000);
3842 mbs.param[1] = SNS_RFT_ID_REQ_SIZE >> 1;
3843 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
3844 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
3845 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
3846 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
4022 mbs.param[1] = SNS_RFT_ID_REQ_SIZE >> 1;
4023 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
4024 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
4025 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
4026 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
3847 mbs.logval = MBLOGALL;
3848 mbs.timeout = 10000000;
3849 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_RFT_ID_REQ_SIZE);
3850 isp_mboxcmd(isp, &mbs);
4027 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, SNS_RFT_ID_REQ_SIZE);
4028 isp_mboxcmd(isp, &mbs);
3851 FC_SCRATCH_RELEASE(isp);
4029 FC_SCRATCH_RELEASE(isp, chan);
3852 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
3853 return (0);
3854 } else {
3855 return (-1);
3856 }
3857}
3858
3859static int
4030 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
4031 return (0);
4032 } else {
4033 return (-1);
4034 }
4035}
4036
4037static int
3860isp_register_fc4_type_24xx(ispsoftc_t *isp)
4038isp_register_fc4_type_24xx(ispsoftc_t *isp, int chan)
3861{
3862 mbreg_t mbs;
4039{
4040 mbreg_t mbs;
3863 fcparam *fcp = FCPARAM(isp);
4041 fcparam *fcp = FCPARAM(isp, chan);
3864 union {
3865 isp_ct_pt_t plocal;
3866 rft_id_t clocal;
3867 uint8_t q[QENTRY_LEN];
3868 } un;
3869 isp_ct_pt_t *pt;
3870 ct_hdr_t *ct;
3871 rft_id_t *rp;
3872 uint8_t *scp = fcp->isp_scratch;
3873
4042 union {
4043 isp_ct_pt_t plocal;
4044 rft_id_t clocal;
4045 uint8_t q[QENTRY_LEN];
4046 } un;
4047 isp_ct_pt_t *pt;
4048 ct_hdr_t *ct;
4049 rft_id_t *rp;
4050 uint8_t *scp = fcp->isp_scratch;
4051
3874 FC_SCRATCH_ACQUIRE(isp);
4052 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4053 isp_prt(isp, ISP_LOGERR, sacq);
4054 return (-1);
4055 }
4056
3875 /*
3876 * Build a Passthrough IOCB in memory.
3877 */
4057 /*
4058 * Build a Passthrough IOCB in memory.
4059 */
3878 MEMZERO(un.q, QENTRY_LEN);
4060 ISP_MEMZERO(un.q, QENTRY_LEN);
3879 pt = &un.plocal;
3880 pt->ctp_header.rqs_entry_count = 1;
3881 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
3882 pt->ctp_handle = 0xffffffff;
4061 pt = &un.plocal;
4062 pt->ctp_header.rqs_entry_count = 1;
4063 pt->ctp_header.rqs_entry_type = RQSTYPE_CT_PASSTHRU;
4064 pt->ctp_handle = 0xffffffff;
3883 pt->ctp_nphdl = NPH_SNS_ID;
4065 pt->ctp_nphdl = fcp->isp_sns_hdl;
3884 pt->ctp_cmd_cnt = 1;
4066 pt->ctp_cmd_cnt = 1;
4067 pt->ctp_vpidx = ISP_GET_VPIDX(isp, chan);
3885 pt->ctp_time = 1;
3886 pt->ctp_rsp_cnt = 1;
3887 pt->ctp_rsp_bcnt = sizeof (ct_hdr_t);
3888 pt->ctp_cmd_bcnt = sizeof (rft_id_t);
3889 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
3890 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
3891 pt->ctp_dataseg[0].ds_count = sizeof (rft_id_t);
3892 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);
3893 pt->ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma+IGPOFF);
3894 pt->ctp_dataseg[1].ds_count = sizeof (ct_hdr_t);
3895 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
4068 pt->ctp_time = 1;
4069 pt->ctp_rsp_cnt = 1;
4070 pt->ctp_rsp_bcnt = sizeof (ct_hdr_t);
4071 pt->ctp_cmd_bcnt = sizeof (rft_id_t);
4072 pt->ctp_dataseg[0].ds_base = DMA_LO32(fcp->isp_scdma+XTXOFF);
4073 pt->ctp_dataseg[0].ds_basehi = DMA_HI32(fcp->isp_scdma+XTXOFF);
4074 pt->ctp_dataseg[0].ds_count = sizeof (rft_id_t);
4075 pt->ctp_dataseg[1].ds_base = DMA_LO32(fcp->isp_scdma+IGPOFF);
4076 pt->ctp_dataseg[1].ds_basehi = DMA_HI32(fcp->isp_scdma+IGPOFF);
4077 pt->ctp_dataseg[1].ds_count = sizeof (ct_hdr_t);
4078 isp_put_ct_pt(isp, pt, (isp_ct_pt_t *) &scp[CTXOFF]);
4079 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4080 isp_print_bytes(isp, "IOCB CT Request", QENTRY_LEN, pt);
4081 }
3896
3897 /*
3898 * Build the CT header and command in memory.
3899 *
3900 * Note that the CT header has to end up as Big Endian format in memory.
3901 */
4082
4083 /*
4084 * Build the CT header and command in memory.
4085 *
4086 * Note that the CT header has to end up as Big Endian format in memory.
4087 */
3902 MEMZERO(&un.clocal, sizeof (un.clocal));
4088 ISP_MEMZERO(&un.clocal, sizeof (un.clocal));
3903 ct = &un.clocal.rftid_hdr;
3904 ct->ct_revision = CT_REVISION;
3905 ct->ct_fcs_type = CT_FC_TYPE_FC;
3906 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
3907 ct->ct_cmd_resp = SNS_RFT_ID;
3908 ct->ct_bcnt_resid = (sizeof (rft_id_t) - sizeof (ct_hdr_t)) >> 2;
3909 rp = &un.clocal;
3910 rp->rftid_portid[0] = fcp->isp_portid >> 16;
3911 rp->rftid_portid[1] = fcp->isp_portid >> 8;
3912 rp->rftid_portid[2] = fcp->isp_portid;
3913 rp->rftid_fc4types[FC4_SCSI >> 5] = 1 << (FC4_SCSI & 0x1f);
3914 isp_put_rft_id(isp, rp, (rft_id_t *) &scp[XTXOFF]);
4089 ct = &un.clocal.rftid_hdr;
4090 ct->ct_revision = CT_REVISION;
4091 ct->ct_fcs_type = CT_FC_TYPE_FC;
4092 ct->ct_fcs_subtype = CT_FC_SUBTYPE_NS;
4093 ct->ct_cmd_resp = SNS_RFT_ID;
4094 ct->ct_bcnt_resid = (sizeof (rft_id_t) - sizeof (ct_hdr_t)) >> 2;
4095 rp = &un.clocal;
4096 rp->rftid_portid[0] = fcp->isp_portid >> 16;
4097 rp->rftid_portid[1] = fcp->isp_portid >> 8;
4098 rp->rftid_portid[2] = fcp->isp_portid;
4099 rp->rftid_fc4types[FC4_SCSI >> 5] = 1 << (FC4_SCSI & 0x1f);
4100 isp_put_rft_id(isp, rp, (rft_id_t *) &scp[XTXOFF]);
4101 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4102 isp_print_bytes(isp, "CT Header", QENTRY_LEN, &scp[XTXOFF]);
4103 }
3915
4104
3916 MEMZERO(&scp[ZTXOFF], sizeof (ct_hdr_t));
4105 ISP_MEMZERO(&scp[ZTXOFF], sizeof (ct_hdr_t));
3917
4106
3918 MEMZERO(&mbs, sizeof (mbs));
3919 mbs.param[0] = MBOX_EXEC_COMMAND_IOCB_A64;
4107 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 1000000);
3920 mbs.param[1] = QENTRY_LEN;
3921 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
3922 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
3923 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
3924 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
4108 mbs.param[1] = QENTRY_LEN;
4109 mbs.param[2] = DMA_WD1(fcp->isp_scdma + CTXOFF);
4110 mbs.param[3] = DMA_WD0(fcp->isp_scdma + CTXOFF);
4111 mbs.param[6] = DMA_WD3(fcp->isp_scdma + CTXOFF);
4112 mbs.param[7] = DMA_WD2(fcp->isp_scdma + CTXOFF);
3925 mbs.timeout = 500000;
3926 mbs.logval = MBLOGALL;
3927 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN);
3928 isp_mboxcmd(isp, &mbs);
3929 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4113 MEMORYBARRIER(isp, SYNC_SFORDEV, XTXOFF, 2 * QENTRY_LEN);
4114 isp_mboxcmd(isp, &mbs);
4115 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
3930 FC_SCRATCH_RELEASE(isp);
4116 FC_SCRATCH_RELEASE(isp, chan);
3931 return (-1);
3932 }
3933 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN);
3934 pt = &un.plocal;
3935 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
3936 if (isp->isp_dblev & ISP_LOGDEBUG1) {
3937 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
3938 }
3939 if (pt->ctp_status) {
4117 return (-1);
4118 }
4119 MEMORYBARRIER(isp, SYNC_SFORCPU, ZTXOFF, QENTRY_LEN);
4120 pt = &un.plocal;
4121 isp_get_ct_pt(isp, (isp_ct_pt_t *) &scp[ZTXOFF], pt);
4122 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4123 isp_print_bytes(isp, "IOCB response", QENTRY_LEN, pt);
4124 }
4125 if (pt->ctp_status) {
3940 FC_SCRATCH_RELEASE(isp);
3941 isp_prt(isp, ISP_LOGWARN, "CT Passthrough returned 0x%x",
3942 pt->ctp_status);
3943 return (-1);
4126 FC_SCRATCH_RELEASE(isp, chan);
4127 isp_prt(isp, ISP_LOGWARN,
4128 "Chan %d Register FC4 Type CT Passthrough returned 0x%x",
4129 chan, pt->ctp_status);
4130 return (1);
3944 }
3945
3946 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct);
4131 }
4132
4133 isp_get_ct_hdr(isp, (ct_hdr_t *) &scp[IGPOFF], ct);
3947 FC_SCRATCH_RELEASE(isp);
4134 FC_SCRATCH_RELEASE(isp, chan);
3948
3949 if (ct->ct_cmd_resp == LS_RJT) {
3950 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
4135
4136 if (ct->ct_cmd_resp == LS_RJT) {
4137 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3951 "Register FC4 Type rejected");
4138 "Chan %d Register FC4 Type rejected", chan);
3952 return (-1);
3953 } else if (ct->ct_cmd_resp == LS_ACC) {
3954 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
4139 return (-1);
4140 } else if (ct->ct_cmd_resp == LS_ACC) {
4141 isp_prt(isp, ISP_LOGSANCFG|ISP_LOGDEBUG0,
3955 "Register FC4 Type accepted");
3956 return(0);
4142 "Chan %d Register FC4 Type accepted", chan);
4143 return (0);
3957 } else {
3958 isp_prt(isp, ISP_LOGWARN,
4144 } else {
4145 isp_prt(isp, ISP_LOGWARN,
3959 "Register FC4 Type: 0x%x", ct->ct_cmd_resp);
4146 "Chan %d Register FC4 Type: 0x%x",
4147 chan, ct->ct_cmd_resp);
3960 return (-1);
3961 }
3962}
3963
3964static uint16_t
4148 return (-1);
4149 }
4150}
4151
4152static uint16_t
3965isp_nxt_handle(ispsoftc_t *isp, uint16_t handle)
4153isp_nxt_handle(ispsoftc_t *isp, int chan, uint16_t handle)
3966{
3967 int i;
3968 if (handle == NIL_HANDLE) {
4154{
4155 int i;
4156 if (handle == NIL_HANDLE) {
3969 if (FCPARAM(isp)->isp_topo == TOPO_F_PORT) {
4157 if (FCPARAM(isp, chan)->isp_topo == TOPO_F_PORT) {
3970 handle = 0;
3971 } else {
3972 handle = SNS_ID+1;
3973 }
3974 } else {
3975 handle += 1;
3976 if (handle >= FL_ID && handle <= SNS_ID) {
3977 handle = SNS_ID+1;
3978 }
3979 if (handle >= NPH_RESERVED && handle <= NPH_FL_ID) {
3980 handle = NPH_FL_ID+1;
3981 }
4158 handle = 0;
4159 } else {
4160 handle = SNS_ID+1;
4161 }
4162 } else {
4163 handle += 1;
4164 if (handle >= FL_ID && handle <= SNS_ID) {
4165 handle = SNS_ID+1;
4166 }
4167 if (handle >= NPH_RESERVED && handle <= NPH_FL_ID) {
4168 handle = NPH_FL_ID+1;
4169 }
3982 if (FCPARAM(isp)->isp_2klogin) {
4170 if (ISP_CAP_2KLOGIN(isp)) {
3983 if (handle == NPH_MAX_2K) {
3984 handle = 0;
3985 }
3986 } else {
3987 if (handle == NPH_MAX) {
3988 handle = 0;
3989 }
3990 }
3991 }
4171 if (handle == NPH_MAX_2K) {
4172 handle = 0;
4173 }
4174 } else {
4175 if (handle == NPH_MAX) {
4176 handle = 0;
4177 }
4178 }
4179 }
3992 if (handle == FCPARAM(isp)->isp_loopid) {
3993 return (isp_nxt_handle(isp, handle));
4180 if (handle == FCPARAM(isp, chan)->isp_loopid) {
4181 return (isp_nxt_handle(isp, chan, handle));
3994 }
3995 for (i = 0; i < MAX_FC_TARG; i++) {
4182 }
4183 for (i = 0; i < MAX_FC_TARG; i++) {
3996 if (FCPARAM(isp)->portdb[i].state == FC_PORTDB_STATE_NIL) {
4184 if (FCPARAM(isp, chan)->portdb[i].state ==
4185 FC_PORTDB_STATE_NIL) {
3997 continue;
3998 }
4186 continue;
4187 }
3999 if (FCPARAM(isp)->portdb[i].handle == handle) {
4000 return (isp_nxt_handle(isp, handle));
4188 if (FCPARAM(isp, chan)->portdb[i].handle == handle) {
4189 return (isp_nxt_handle(isp, chan, handle));
4001 }
4002 }
4003 return (handle);
4004}
4005
4006/*
4007 * Start a command. Locking is assumed done in the caller.
4008 */
4009
4010int
4011isp_start(XS_T *xs)
4012{
4013 ispsoftc_t *isp;
4190 }
4191 }
4192 return (handle);
4193}
4194
4195/*
4196 * Start a command. Locking is assumed done in the caller.
4197 */
4198
4199int
4200isp_start(XS_T *xs)
4201{
4202 ispsoftc_t *isp;
4014 uint32_t nxti, optr, handle;
4203 uint32_t handle;
4015 uint8_t local[QENTRY_LEN];
4204 uint8_t local[QENTRY_LEN];
4016 ispreq_t *reqp, *qep;
4017 void *cdbp;
4205 ispreq_t *reqp;
4206 void *cdbp, *qep;
4018 uint16_t *tptr;
4207 uint16_t *tptr;
4019 int target, i, hdlidx = 0;
4208 int target, dmaresult, hdlidx = 0;
4020
4021 XS_INITERR(xs);
4022 isp = XS_ISP(xs);
4023
4024 /*
4209
4210 XS_INITERR(xs);
4211 isp = XS_ISP(xs);
4212
4213 /*
4025 * Check to make sure we're supporting initiator role.
4026 */
4027 if ((isp->isp_role & ISP_ROLE_INITIATOR) == 0) {
4028 XS_SETERR(xs, HBA_SELTIMEOUT);
4029 return (CMD_COMPLETE);
4030 }
4031
4032 /*
4033 * Now make sure we're running.
4034 */
4035
4036 if (isp->isp_state != ISP_RUNSTATE) {
4037 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
4038 XS_SETERR(xs, HBA_BOTCH);
4039 return (CMD_COMPLETE);
4040 }
4041
4042 /*
4043 * Check command CDB length, etc.. We really are limited to 16 bytes
4044 * for Fibre Channel, but can do up to 44 bytes in parallel SCSI,
4045 * but probably only if we're running fairly new firmware (we'll
4046 * let the old f/w choke on an extended command queue entry).
4047 */
4048
4049 if (XS_CDBLEN(xs) > (IS_FC(isp)? 16 : 44) || XS_CDBLEN(xs) == 0) {
4214 * Now make sure we're running.
4215 */
4216
4217 if (isp->isp_state != ISP_RUNSTATE) {
4218 isp_prt(isp, ISP_LOGERR, "Adapter not at RUNSTATE");
4219 XS_SETERR(xs, HBA_BOTCH);
4220 return (CMD_COMPLETE);
4221 }
4222
4223 /*
4224 * Check command CDB length, etc.. We really are limited to 16 bytes
4225 * for Fibre Channel, but can do up to 44 bytes in parallel SCSI,
4226 * but probably only if we're running fairly new firmware (we'll
4227 * let the old f/w choke on an extended command queue entry).
4228 */
4229
4230 if (XS_CDBLEN(xs) > (IS_FC(isp)? 16 : 44) || XS_CDBLEN(xs) == 0) {
4050 isp_prt(isp, ISP_LOGERR,
4051 "unsupported cdb length (%d, CDB[0]=0x%x)",
4052 XS_CDBLEN(xs), XS_CDBP(xs)[0] & 0xff);
4231 isp_prt(isp, ISP_LOGERR, "unsupported cdb length (%d, CDB[0]=0x%x)", XS_CDBLEN(xs), XS_CDBP(xs)[0] & 0xff);
4053 XS_SETERR(xs, HBA_BOTCH);
4054 return (CMD_COMPLETE);
4055 }
4056
4057 /*
4058 * Translate the target to device handle as appropriate, checking
4059 * for correct device state as well.
4060 */
4061 target = XS_TGT(xs);
4062 if (IS_FC(isp)) {
4232 XS_SETERR(xs, HBA_BOTCH);
4233 return (CMD_COMPLETE);
4234 }
4235
4236 /*
4237 * Translate the target to device handle as appropriate, checking
4238 * for correct device state as well.
4239 */
4240 target = XS_TGT(xs);
4241 if (IS_FC(isp)) {
4063 fcparam *fcp = isp->isp_param;
4242 fcparam *fcp = FCPARAM(isp, XS_CHANNEL(xs));
4064
4243
4244 if ((fcp->role & ISP_ROLE_INITIATOR) == 0) {
4245 XS_SETERR(xs, HBA_SELTIMEOUT);
4246 return (CMD_COMPLETE);
4247 }
4248
4065 /*
4066 * Try again later.
4067 */
4249 /*
4250 * Try again later.
4251 */
4068 if (fcp->isp_fwstate != FW_READY ||
4069 fcp->isp_loopstate != LOOP_READY) {
4252 if (fcp->isp_fwstate != FW_READY || fcp->isp_loopstate != LOOP_READY) {
4070 return (CMD_RQLATER);
4071 }
4072
4073 if (XS_TGT(xs) >= MAX_FC_TARG) {
4074 XS_SETERR(xs, HBA_SELTIMEOUT);
4075 return (CMD_COMPLETE);
4076 }
4077
4253 return (CMD_RQLATER);
4254 }
4255
4256 if (XS_TGT(xs) >= MAX_FC_TARG) {
4257 XS_SETERR(xs, HBA_SELTIMEOUT);
4258 return (CMD_COMPLETE);
4259 }
4260
4078 hdlidx = fcp->isp_ini_map[XS_TGT(xs)] - 1;
4079 isp_prt(isp, ISP_LOGDEBUG1, "XS_TGT(xs)=%d- hdlidx value %d",
4080 XS_TGT(xs), hdlidx);
4261 hdlidx = fcp->isp_dev_map[XS_TGT(xs)] - 1;
4262 isp_prt(isp, ISP_LOGDEBUG2, "XS_TGT(xs)=%d- hdlidx value %d", XS_TGT(xs), hdlidx);
4081 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4082 XS_SETERR(xs, HBA_SELTIMEOUT);
4083 return (CMD_COMPLETE);
4084 }
4085 if (fcp->portdb[hdlidx].state == FC_PORTDB_STATE_ZOMBIE) {
4086 return (CMD_RQLATER);
4087 }
4088 if (fcp->portdb[hdlidx].state != FC_PORTDB_STATE_VALID) {
4089 XS_SETERR(xs, HBA_SELTIMEOUT);
4090 return (CMD_COMPLETE);
4091 }
4092 target = fcp->portdb[hdlidx].handle;
4263 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4264 XS_SETERR(xs, HBA_SELTIMEOUT);
4265 return (CMD_COMPLETE);
4266 }
4267 if (fcp->portdb[hdlidx].state == FC_PORTDB_STATE_ZOMBIE) {
4268 return (CMD_RQLATER);
4269 }
4270 if (fcp->portdb[hdlidx].state != FC_PORTDB_STATE_VALID) {
4271 XS_SETERR(xs, HBA_SELTIMEOUT);
4272 return (CMD_COMPLETE);
4273 }
4274 target = fcp->portdb[hdlidx].handle;
4275 fcp->portdb[hdlidx].dirty = 1;
4276 } else {
4277 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
4278 if ((sdp->role & ISP_ROLE_INITIATOR) == 0) {
4279 XS_SETERR(xs, HBA_SELTIMEOUT);
4280 return (CMD_COMPLETE);
4281 }
4282 if (sdp->update) {
4283 isp_spi_update(isp, XS_CHANNEL(xs));
4284 }
4093 }
4094
4285 }
4286
4095 /*
4096 * Next check to see if any HBA or Device parameters need to be updated.
4097 */
4098 if (isp->isp_update != 0) {
4099 isp_update(isp);
4100 }
4101
4102 start_again:
4103
4287 start_again:
4288
4104 if (isp_getrqentry(isp, &nxti, &optr, (void *)&qep)) {
4289 qep = isp_getrqentry(isp);
4290 if (qep == NULL) {
4105 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow");
4106 XS_SETERR(xs, HBA_BOTCH);
4107 return (CMD_EAGAIN);
4108 }
4291 isp_prt(isp, ISP_LOGDEBUG0, "Request Queue Overflow");
4292 XS_SETERR(xs, HBA_BOTCH);
4293 return (CMD_EAGAIN);
4294 }
4295 XS_SETERR(xs, HBA_NOERROR);
4109
4110 /*
4111 * Now see if we need to synchronize the ISP with respect to anything.
4112 * We do dual duty here (cough) for synchronizing for busses other
4113 * than which we got here to send a command to.
4114 */
4115 reqp = (ispreq_t *) local;
4296
4297 /*
4298 * Now see if we need to synchronize the ISP with respect to anything.
4299 * We do dual duty here (cough) for synchronizing for busses other
4300 * than which we got here to send a command to.
4301 */
4302 reqp = (ispreq_t *) local;
4116 if (isp->isp_sendmarker) {
4303 ISP_MEMZERO(local, QENTRY_LEN);
4304 if (ISP_TST_SENDMARKER(isp, XS_CHANNEL(xs))) {
4117 if (IS_24XX(isp)) {
4305 if (IS_24XX(isp)) {
4118 isp_marker_24xx_t *m = (isp_marker_24xx_t *) qep;
4119 MEMZERO(m, QENTRY_LEN);
4306 isp_marker_24xx_t *m = (isp_marker_24xx_t *) reqp;
4120 m->mrk_header.rqs_entry_count = 1;
4121 m->mrk_header.rqs_entry_type = RQSTYPE_MARKER;
4122 m->mrk_modifier = SYNC_ALL;
4307 m->mrk_header.rqs_entry_count = 1;
4308 m->mrk_header.rqs_entry_type = RQSTYPE_MARKER;
4309 m->mrk_modifier = SYNC_ALL;
4123 isp_put_marker_24xx(isp, m, (isp_marker_24xx_t *)qep);
4124 ISP_ADD_REQUEST(isp, nxti);
4125 isp->isp_sendmarker = 0;
4126 goto start_again;
4310 isp_put_marker_24xx(isp, m, qep);
4127 } else {
4311 } else {
4128 for (i = 0; i < (IS_DUALBUS(isp)? 2: 1); i++) {
4129 isp_marker_t *m = (isp_marker_t *) qep;
4130 if ((isp->isp_sendmarker & (1 << i)) == 0) {
4131 continue;
4132 }
4133 MEMZERO(m, QENTRY_LEN);
4134 m->mrk_header.rqs_entry_count = 1;
4135 m->mrk_header.rqs_entry_type = RQSTYPE_MARKER;
4136 m->mrk_target = (i << 7); /* bus # */
4137 m->mrk_modifier = SYNC_ALL;
4138 isp_put_marker(isp, m, (isp_marker_t *) qep);
4139 ISP_ADD_REQUEST(isp, nxti);
4140 isp->isp_sendmarker &= ~(1 << i);
4141 goto start_again;
4142 }
4312 isp_marker_t *m = (isp_marker_t *) reqp;
4313 m->mrk_header.rqs_entry_count = 1;
4314 m->mrk_header.rqs_entry_type = RQSTYPE_MARKER;
4315 m->mrk_target = (XS_CHANNEL(xs) << 7); /* bus # */
4316 m->mrk_modifier = SYNC_ALL;
4317 isp_put_marker(isp, m, qep);
4143 }
4318 }
4319 ISP_SYNC_REQUEST(isp);
4320 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 0);
4321 goto start_again;
4144 }
4145
4322 }
4323
4146 MEMZERO((void *)reqp, QENTRY_LEN);
4147 reqp->req_header.rqs_entry_count = 1;
4148 if (IS_24XX(isp)) {
4149 reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS;
4150 } else if (IS_FC(isp)) {
4151 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS;
4152 } else {
4324 reqp->req_header.rqs_entry_count = 1;
4325 if (IS_24XX(isp)) {
4326 reqp->req_header.rqs_entry_type = RQSTYPE_T7RQS;
4327 } else if (IS_FC(isp)) {
4328 reqp->req_header.rqs_entry_type = RQSTYPE_T2RQS;
4329 } else {
4153 if (XS_CDBLEN(xs) > 12)
4330 if (XS_CDBLEN(xs) > 12) {
4154 reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY;
4331 reqp->req_header.rqs_entry_type = RQSTYPE_CMDONLY;
4155 else
4332 } else {
4156 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;
4333 reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;
4334 }
4157 }
4158 /* reqp->req_header.rqs_flags = 0; */
4159 /* reqp->req_header.rqs_seqno = 0; */
4160 if (IS_24XX(isp)) {
4161 int ttype;
4162 if (XS_TAG_P(xs)) {
4163 ttype = XS_TAG_TYPE(xs);
4164 } else {

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

4175 } else {
4176 ttype = FCP_CMND_TASK_ATTR_SIMPLE;
4177 }
4178 ((ispreqt7_t *)reqp)->req_task_attribute = ttype;
4179 } else if (IS_FC(isp)) {
4180 /*
4181 * See comment in isp_intr
4182 */
4335 }
4336 /* reqp->req_header.rqs_flags = 0; */
4337 /* reqp->req_header.rqs_seqno = 0; */
4338 if (IS_24XX(isp)) {
4339 int ttype;
4340 if (XS_TAG_P(xs)) {
4341 ttype = XS_TAG_TYPE(xs);
4342 } else {

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

4353 } else {
4354 ttype = FCP_CMND_TASK_ATTR_SIMPLE;
4355 }
4356 ((ispreqt7_t *)reqp)->req_task_attribute = ttype;
4357 } else if (IS_FC(isp)) {
4358 /*
4359 * See comment in isp_intr
4360 */
4183 /* XS_RESID(xs) = 0; */
4361 /* XS_SET_RESID(xs, 0); */
4184
4185 /*
4186 * Fibre Channel always requires some kind of tag.
4187 * The Qlogic drivers seem be happy not to use a tag,
4188 * but this breaks for some devices (IBM drives).
4189 */
4190 if (XS_TAG_P(xs)) {
4191 ((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs);
4192 } else {
4193 /*
4194 * If we don't know what tag to use, use HEAD OF QUEUE
4195 * for Request Sense or Simple.
4196 */
4197 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
4198 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG;
4199 else
4200 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG;
4201 }
4202 } else {
4362
4363 /*
4364 * Fibre Channel always requires some kind of tag.
4365 * The Qlogic drivers seem be happy not to use a tag,
4366 * but this breaks for some devices (IBM drives).
4367 */
4368 if (XS_TAG_P(xs)) {
4369 ((ispreqt2_t *)reqp)->req_flags = XS_TAG_TYPE(xs);
4370 } else {
4371 /*
4372 * If we don't know what tag to use, use HEAD OF QUEUE
4373 * for Request Sense or Simple.
4374 */
4375 if (XS_CDBP(xs)[0] == 0x3) /* REQUEST SENSE */
4376 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_HTAG;
4377 else
4378 ((ispreqt2_t *)reqp)->req_flags = REQFLAG_STAG;
4379 }
4380 } else {
4203 sdparam *sdp = (sdparam *)isp->isp_param;
4204 sdp += XS_CHANNEL(xs);
4205 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) &&
4206 XS_TAG_P(xs)) {
4381 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
4382 if ((sdp->isp_devparam[target].actv_flags & DPARM_TQING) && XS_TAG_P(xs)) {
4207 reqp->req_flags = XS_TAG_TYPE(xs);
4208 }
4209 }
4210 cdbp = reqp->req_cdb;
4211 tptr = &reqp->req_time;
4212
4213 if (IS_SCSI(isp)) {
4214 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
4215 reqp->req_lun_trn = XS_LUN(xs);
4216 reqp->req_cdblen = XS_CDBLEN(xs);
4217 } else if (IS_24XX(isp)) {
4218 fcportdb_t *lp;
4219
4383 reqp->req_flags = XS_TAG_TYPE(xs);
4384 }
4385 }
4386 cdbp = reqp->req_cdb;
4387 tptr = &reqp->req_time;
4388
4389 if (IS_SCSI(isp)) {
4390 reqp->req_target = target | (XS_CHANNEL(xs) << 7);
4391 reqp->req_lun_trn = XS_LUN(xs);
4392 reqp->req_cdblen = XS_CDBLEN(xs);
4393 } else if (IS_24XX(isp)) {
4394 fcportdb_t *lp;
4395
4220 lp = &FCPARAM(isp)->portdb[hdlidx];
4396 lp = &FCPARAM(isp, XS_CHANNEL(xs))->portdb[hdlidx];
4221 ((ispreqt7_t *)reqp)->req_nphdl = target;
4222 ((ispreqt7_t *)reqp)->req_tidlo = lp->portid;
4223 ((ispreqt7_t *)reqp)->req_tidhi = lp->portid >> 16;
4397 ((ispreqt7_t *)reqp)->req_nphdl = target;
4398 ((ispreqt7_t *)reqp)->req_tidlo = lp->portid;
4399 ((ispreqt7_t *)reqp)->req_tidhi = lp->portid >> 16;
4400 ((ispreqt7_t *)reqp)->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
4224 if (XS_LUN(xs) > 256) {
4225 ((ispreqt7_t *)reqp)->req_lun[0] = XS_LUN(xs) >> 8;
4226 ((ispreqt7_t *)reqp)->req_lun[0] |= 0x40;
4227 }
4228 ((ispreqt7_t *)reqp)->req_lun[1] = XS_LUN(xs);
4229 cdbp = ((ispreqt7_t *)reqp)->req_cdb;
4230 tptr = &((ispreqt7_t *)reqp)->req_time;
4401 if (XS_LUN(xs) > 256) {
4402 ((ispreqt7_t *)reqp)->req_lun[0] = XS_LUN(xs) >> 8;
4403 ((ispreqt7_t *)reqp)->req_lun[0] |= 0x40;
4404 }
4405 ((ispreqt7_t *)reqp)->req_lun[1] = XS_LUN(xs);
4406 cdbp = ((ispreqt7_t *)reqp)->req_cdb;
4407 tptr = &((ispreqt7_t *)reqp)->req_time;
4231 } else if (FCPARAM(isp)->isp_2klogin) {
4408 } else if (ISP_CAP_2KLOGIN(isp)) {
4232 ((ispreqt2e_t *)reqp)->req_target = target;
4233 ((ispreqt2e_t *)reqp)->req_scclun = XS_LUN(xs);
4409 ((ispreqt2e_t *)reqp)->req_target = target;
4410 ((ispreqt2e_t *)reqp)->req_scclun = XS_LUN(xs);
4234 } else if (FCPARAM(isp)->isp_sccfw) {
4411 } else if (ISP_CAP_SCCFW(isp)) {
4235 ((ispreqt2_t *)reqp)->req_target = target;
4236 ((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs);
4237 } else {
4238 ((ispreqt2_t *)reqp)->req_target = target;
4239 ((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs);
4240 }
4412 ((ispreqt2_t *)reqp)->req_target = target;
4413 ((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs);
4414 } else {
4415 ((ispreqt2_t *)reqp)->req_target = target;
4416 ((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs);
4417 }
4241 MEMCPY(cdbp, XS_CDBP(xs), XS_CDBLEN(xs));
4418 ISP_MEMCPY(cdbp, XS_CDBP(xs), XS_CDBLEN(xs));
4242
4243 *tptr = XS_TIME(xs) / 1000;
4244 if (*tptr == 0 && XS_TIME(xs)) {
4245 *tptr = 1;
4246 }
4247 if (IS_24XX(isp) && *tptr > 0x1999) {
4248 *tptr = 0x1999;
4249 }
4250
4251 if (isp_save_xs(isp, xs, &handle)) {
4252 isp_prt(isp, ISP_LOGDEBUG0, "out of xflist pointers");
4253 XS_SETERR(xs, HBA_BOTCH);
4254 return (CMD_EAGAIN);
4255 }
4256 /* Whew. Thankfully the same for type 7 requests */
4257 reqp->req_handle = handle;
4258
4259 /*
4419
4420 *tptr = XS_TIME(xs) / 1000;
4421 if (*tptr == 0 && XS_TIME(xs)) {
4422 *tptr = 1;
4423 }
4424 if (IS_24XX(isp) && *tptr > 0x1999) {
4425 *tptr = 0x1999;
4426 }
4427
4428 if (isp_save_xs(isp, xs, &handle)) {
4429 isp_prt(isp, ISP_LOGDEBUG0, "out of xflist pointers");
4430 XS_SETERR(xs, HBA_BOTCH);
4431 return (CMD_EAGAIN);
4432 }
4433 /* Whew. Thankfully the same for type 7 requests */
4434 reqp->req_handle = handle;
4435
4436 /*
4260 * Set up DMA and/or do any bus swizzling of the request entry
4437 * Set up DMA and/or do any platform dependent swizzling of the request entry
4261 * so that the Qlogic F/W understands what is being asked of it.
4438 * so that the Qlogic F/W understands what is being asked of it.
4439 *
4440 * The callee is responsible for adding all requests at this point.
4262 */
4441 */
4263 i = ISP_DMASETUP(isp, xs, reqp, &nxti, optr);
4264 if (i != CMD_QUEUED) {
4442 dmaresult = ISP_DMASETUP(isp, xs, reqp);
4443 if (dmaresult != CMD_QUEUED) {
4265 isp_destroy_handle(isp, handle);
4266 /*
4267 * dmasetup sets actual error in packet, and
4268 * return what we were given to return.
4269 */
4444 isp_destroy_handle(isp, handle);
4445 /*
4446 * dmasetup sets actual error in packet, and
4447 * return what we were given to return.
4448 */
4270 return (i);
4449 return (dmaresult);
4271 }
4450 }
4272 XS_SETERR(xs, HBA_NOERROR);
4273 isp_prt(isp, ISP_LOGDEBUG0,
4274 "START cmd for %d.%d.%d cmd 0x%x datalen %ld",
4275 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), XS_CDBP(xs)[0],
4276 (long) XS_XFRLEN(xs));
4277 ISP_ADD_REQUEST(isp, nxti);
4451 isp_prt(isp, ISP_LOGDEBUG0, "START cmd for %d.%d.%d cmd 0x%x datalen %ld", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), XS_CDBP(xs)[0], (long) XS_XFRLEN(xs));
4278 isp->isp_nactive++;
4279 return (CMD_QUEUED);
4280}
4281
4282/*
4283 * isp control
4284 * Locks (ints blocked) assumed held.
4285 */
4286
4287int
4452 isp->isp_nactive++;
4453 return (CMD_QUEUED);
4454}
4455
4456/*
4457 * isp control
4458 * Locks (ints blocked) assumed held.
4459 */
4460
4461int
4288isp_control(ispsoftc_t *isp, ispctl_t ctl, void *arg)
4462isp_control(ispsoftc_t *isp, ispctl_t ctl, ...)
4289{
4290 XS_T *xs;
4463{
4464 XS_T *xs;
4291 mbreg_t mbs;
4292 int bus, tgt;
4465 mbreg_t *mbr, mbs;
4466 int chan, tgt;
4293 uint32_t handle;
4467 uint32_t handle;
4468 va_list ap;
4294
4469
4295 MEMZERO(&mbs, sizeof (mbs));
4296
4297 switch (ctl) {
4470 switch (ctl) {
4298 default:
4299 isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl);
4300 break;
4301
4302 case ISPCTL_RESET_BUS:
4303 /*
4304 * Issue a bus reset.
4305 */
4306 if (IS_24XX(isp)) {
4307 isp_prt(isp, ISP_LOGWARN, "RESET BUS NOT IMPLEMENTED");
4308 break;
4309 } else if (IS_FC(isp)) {
4310 mbs.param[1] = 10;
4471 case ISPCTL_RESET_BUS:
4472 /*
4473 * Issue a bus reset.
4474 */
4475 if (IS_24XX(isp)) {
4476 isp_prt(isp, ISP_LOGWARN, "RESET BUS NOT IMPLEMENTED");
4477 break;
4478 } else if (IS_FC(isp)) {
4479 mbs.param[1] = 10;
4311 bus = 0;
4480 chan = 0;
4312 } else {
4481 } else {
4313 mbs.param[1] = SDPARAM(isp)->isp_bus_reset_delay;
4482 va_start(ap, ctl);
4483 chan = va_arg(ap, int);
4484 va_end(ap);
4485 mbs.param[1] = SDPARAM(isp, chan)->isp_bus_reset_delay;
4314 if (mbs.param[1] < 2) {
4315 mbs.param[1] = 2;
4316 }
4486 if (mbs.param[1] < 2) {
4487 mbs.param[1] = 2;
4488 }
4317 bus = *((int *) arg);
4318 if (IS_DUALBUS(isp)) {
4319 mbs.param[2] = bus;
4320 }
4489 mbs.param[2] = chan;
4321 }
4490 }
4322 mbs.param[0] = MBOX_BUS_RESET;
4323 isp->isp_sendmarker |= (1 << bus);
4324 mbs.logval = MBLOGALL;
4491 MBSINIT(&mbs, MBOX_BUS_RESET, MBLOGALL, 0);
4492 ISP_SET_SENDMARKER(isp, chan, 1);
4325 isp_mboxcmd(isp, &mbs);
4326 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4327 break;
4328 }
4329 isp_prt(isp, ISP_LOGINFO,
4493 isp_mboxcmd(isp, &mbs);
4494 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4495 break;
4496 }
4497 isp_prt(isp, ISP_LOGINFO,
4330 "driver initiated bus reset of bus %d", bus);
4498 "driver initiated bus reset of bus %d", chan);
4331 return (0);
4332
4333 case ISPCTL_RESET_DEV:
4499 return (0);
4500
4501 case ISPCTL_RESET_DEV:
4334 tgt = (*((int *) arg)) & 0xffff;
4502 va_start(ap, ctl);
4503 chan = va_arg(ap, int);
4504 tgt = va_arg(ap, int);
4505 va_end(ap);
4335 if (IS_24XX(isp)) {
4506 if (IS_24XX(isp)) {
4336 isp_prt(isp, ISP_LOGWARN, "RESET DEV NOT IMPLEMENTED");
4507 uint8_t local[QENTRY_LEN];
4508 isp24xx_tmf_t *tmf;
4509 isp24xx_statusreq_t *sp;
4510 fcparam *fcp = FCPARAM(isp, chan);
4511 fcportdb_t *lp;
4512 int hdlidx;
4513
4514 hdlidx = fcp->isp_dev_map[tgt] - 1;
4515 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4516 isp_prt(isp, ISP_LOGWARN,
4517 "Chan %d bad handle %d trying to reset"
4518 "target %d", chan, hdlidx, tgt);
4519 break;
4520 }
4521 lp = &fcp->portdb[hdlidx];
4522 if (lp->state != FC_PORTDB_STATE_VALID) {
4523 isp_prt(isp, ISP_LOGWARN,
4524 "Chan %d handle %d for abort of target %d "
4525 "no longer valid", chan,
4526 hdlidx, tgt);
4527 break;
4528 }
4529
4530 tmf = (isp24xx_tmf_t *) local;
4531 ISP_MEMZERO(tmf, QENTRY_LEN);
4532 tmf->tmf_header.rqs_entry_type = RQSTYPE_TSK_MGMT;
4533 tmf->tmf_header.rqs_entry_count = 1;
4534 tmf->tmf_nphdl = lp->handle;
4535 tmf->tmf_delay = 2;
4536 tmf->tmf_timeout = 2;
4537 tmf->tmf_flags = ISP24XX_TMF_TARGET_RESET;
4538 tmf->tmf_tidlo = lp->portid;
4539 tmf->tmf_tidhi = lp->portid >> 16;
4540 tmf->tmf_vpidx = ISP_GET_VPIDX(isp, chan);
4541 isp_prt(isp, ISP_LOGALL, "Chan %d Reset N-Port Handle 0x%04x @ Port 0x%06x", chan, lp->handle, lp->portid);
4542 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 5000000);
4543 mbs.param[1] = QENTRY_LEN;
4544 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
4545 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
4546 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
4547 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
4548
4549 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4550 isp_prt(isp, ISP_LOGERR, sacq);
4551 break;
4552 }
4553 isp_put_24xx_tmf(isp, tmf, fcp->isp_scratch);
4554 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, QENTRY_LEN);
4555 fcp->sendmarker = 1;
4556 isp_mboxcmd(isp, &mbs);
4557 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4558 FC_SCRATCH_RELEASE(isp, chan);
4559 break;
4560 }
4561 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN,
4562 QENTRY_LEN);
4563 sp = (isp24xx_statusreq_t *) local;
4564 isp_get_24xx_response(isp,
4565 &((isp24xx_statusreq_t *)fcp->isp_scratch)[1], sp);
4566 FC_SCRATCH_RELEASE(isp, chan);
4567 if (sp->req_completion_status == 0) {
4568 return (0);
4569 }
4570 isp_prt(isp, ISP_LOGWARN,
4571 "Chan %d reset of target %d returned 0x%x",
4572 chan, tgt, sp->req_completion_status);
4337 break;
4338 } else if (IS_FC(isp)) {
4573 break;
4574 } else if (IS_FC(isp)) {
4339 if (FCPARAM(isp)->isp_2klogin) {
4575 if (ISP_CAP_2KLOGIN(isp)) {
4340 mbs.param[1] = tgt;
4341 mbs.ibits = (1 << 10);
4342 } else {
4343 mbs.param[1] = (tgt << 8);
4344 }
4576 mbs.param[1] = tgt;
4577 mbs.ibits = (1 << 10);
4578 } else {
4579 mbs.param[1] = (tgt << 8);
4580 }
4345 bus = 0;
4346 } else {
4581 } else {
4347 bus = (*((int *) arg)) >> 16;
4348 mbs.param[1] = (bus << 15) | (tgt << 8);
4582 mbs.param[1] = (chan << 15) | (tgt << 8);
4349 }
4583 }
4350 mbs.param[0] = MBOX_ABORT_TARGET;
4584 MBSINIT(&mbs, MBOX_ABORT_TARGET, MBLOGALL, 0);
4351 mbs.param[2] = 3; /* 'delay', in seconds */
4585 mbs.param[2] = 3; /* 'delay', in seconds */
4352 mbs.logval = MBLOGALL;
4353 isp_mboxcmd(isp, &mbs);
4354 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4355 break;
4356 }
4357 isp_prt(isp, ISP_LOGINFO,
4586 isp_mboxcmd(isp, &mbs);
4587 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4588 break;
4589 }
4590 isp_prt(isp, ISP_LOGINFO,
4358 "Target %d on Bus %d Reset Succeeded", tgt, bus);
4359 isp->isp_sendmarker |= (1 << bus);
4591 "Target %d on Bus %d Reset Succeeded", tgt, chan);
4592 ISP_SET_SENDMARKER(isp, chan, 1);
4360 return (0);
4361
4362 case ISPCTL_ABORT_CMD:
4593 return (0);
4594
4595 case ISPCTL_ABORT_CMD:
4363 xs = (XS_T *) arg;
4596 va_start(ap, ctl);
4597 xs = va_arg(ap, XS_T *);
4598 va_end(ap);
4599
4364 tgt = XS_TGT(xs);
4600 tgt = XS_TGT(xs);
4601 chan = XS_CHANNEL(xs);
4365
4366 handle = isp_find_handle(isp, xs);
4367 if (handle == 0) {
4368 isp_prt(isp, ISP_LOGWARN,
4369 "cannot find handle for command to abort");
4370 break;
4371 }
4372 if (IS_24XX(isp)) {
4602
4603 handle = isp_find_handle(isp, xs);
4604 if (handle == 0) {
4605 isp_prt(isp, ISP_LOGWARN,
4606 "cannot find handle for command to abort");
4607 break;
4608 }
4609 if (IS_24XX(isp)) {
4373 isp_prt(isp, ISP_LOGWARN, "ABORT CMD NOT IMPLEMENTED");
4610 isp24xx_abrt_t local, *ab = &local, *ab2;
4611 fcparam *fcp;
4612 fcportdb_t *lp;
4613 int hdlidx;
4614
4615 fcp = FCPARAM(isp, chan);
4616 hdlidx = fcp->isp_dev_map[tgt] - 1;
4617 if (hdlidx < 0 || hdlidx >= MAX_FC_TARG) {
4618 isp_prt(isp, ISP_LOGWARN,
4619 "Chan %d bad handle %d trying to abort"
4620 "target %d", chan, hdlidx, tgt);
4621 break;
4622 }
4623 lp = &fcp->portdb[hdlidx];
4624 if (lp->state != FC_PORTDB_STATE_VALID) {
4625 isp_prt(isp, ISP_LOGWARN,
4626 "Chan %d handle %d for abort of target %d "
4627 "no longer valid", chan, hdlidx, tgt);
4628 break;
4629 }
4630 isp_prt(isp, ISP_LOGALL,
4631 "Chan %d Abort Cmd for N-Port 0x%04x @ Port "
4632 "0x%06x %p", chan, lp->handle, lp->portid, xs);
4633 ISP_MEMZERO(ab, QENTRY_LEN);
4634 ab->abrt_header.rqs_entry_type = RQSTYPE_ABORT_IO;
4635 ab->abrt_header.rqs_entry_count = 1;
4636 ab->abrt_handle = lp->handle;
4637 ab->abrt_cmd_handle = handle;
4638 ab->abrt_tidlo = lp->portid;
4639 ab->abrt_tidhi = lp->portid >> 16;
4640 ab->abrt_vpidx = ISP_GET_VPIDX(isp, chan);
4641
4642 ISP_MEMZERO(&mbs, sizeof (mbs));
4643 MBSINIT(&mbs, MBOX_EXEC_COMMAND_IOCB_A64, MBLOGALL, 5000000);
4644 mbs.param[1] = QENTRY_LEN;
4645 mbs.param[2] = DMA_WD1(fcp->isp_scdma);
4646 mbs.param[3] = DMA_WD0(fcp->isp_scdma);
4647 mbs.param[6] = DMA_WD3(fcp->isp_scdma);
4648 mbs.param[7] = DMA_WD2(fcp->isp_scdma);
4649
4650 if (FC_SCRATCH_ACQUIRE(isp, chan)) {
4651 isp_prt(isp, ISP_LOGERR, sacq);
4652 break;
4653 }
4654 isp_put_24xx_abrt(isp, ab, fcp->isp_scratch);
4655 ab2 = (isp24xx_abrt_t *)
4656 &((uint8_t *)fcp->isp_scratch)[QENTRY_LEN];
4657 ab2->abrt_nphdl = 0xdeaf;
4658 MEMORYBARRIER(isp, SYNC_SFORDEV, 0, 2 * QENTRY_LEN);
4659 isp_mboxcmd(isp, &mbs);
4660 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4661 FC_SCRATCH_RELEASE(isp, chan);
4662 break;
4663 }
4664 MEMORYBARRIER(isp, SYNC_SFORCPU, QENTRY_LEN,
4665 QENTRY_LEN);
4666 isp_get_24xx_abrt(isp, ab2, ab);
4667 FC_SCRATCH_RELEASE(isp, chan);
4668 if (ab->abrt_nphdl == ISP24XX_ABRT_OKAY) {
4669 return (0);
4670 }
4671 isp_prt(isp, ISP_LOGWARN,
4672 "Chan %d handle %d abort returned 0x%x", chan,
4673 hdlidx, ab->abrt_nphdl);
4374 break;
4375 } else if (IS_FC(isp)) {
4674 break;
4675 } else if (IS_FC(isp)) {
4376 if (FCPARAM(isp)->isp_sccfw) {
4377 if (FCPARAM(isp)->isp_2klogin) {
4676 if (ISP_CAP_SCCFW(isp)) {
4677 if (ISP_CAP_2KLOGIN(isp)) {
4378 mbs.param[1] = tgt;
4379 } else {
4380 mbs.param[1] = tgt << 8;
4381 }
4382 mbs.param[6] = XS_LUN(xs);
4383 } else {
4384 mbs.param[1] = tgt << 8 | XS_LUN(xs);
4385 }
4386 } else {
4678 mbs.param[1] = tgt;
4679 } else {
4680 mbs.param[1] = tgt << 8;
4681 }
4682 mbs.param[6] = XS_LUN(xs);
4683 } else {
4684 mbs.param[1] = tgt << 8 | XS_LUN(xs);
4685 }
4686 } else {
4387 bus = XS_CHANNEL(xs);
4388 mbs.param[1] = (bus << 15) | (tgt << 8) | XS_LUN(xs);
4687 mbs.param[1] = (chan << 15) | (tgt << 8) | XS_LUN(xs);
4389 }
4688 }
4390 mbs.param[0] = MBOX_ABORT;
4689 MBSINIT(&mbs, MBOX_ABORT, MBLOGALL & ~MBOX_COMMAND_ERROR, 0);
4391 mbs.param[2] = handle;
4690 mbs.param[2] = handle;
4392 mbs.logval = MBLOGALL & ~MBOX_COMMAND_ERROR;
4393 isp_mboxcmd(isp, &mbs);
4394 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4395 break;
4396 }
4397 return (0);
4398
4399 case ISPCTL_UPDATE_PARAMS:
4400
4691 isp_mboxcmd(isp, &mbs);
4692 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4693 break;
4694 }
4695 return (0);
4696
4697 case ISPCTL_UPDATE_PARAMS:
4698
4401 isp_update(isp);
4699 va_start(ap, ctl);
4700 chan = va_arg(ap, int);
4701 va_end(ap);
4702 isp_spi_update(isp, chan);
4402 return (0);
4403
4404 case ISPCTL_FCLINK_TEST:
4405
4406 if (IS_FC(isp)) {
4703 return (0);
4704
4705 case ISPCTL_FCLINK_TEST:
4706
4707 if (IS_FC(isp)) {
4407 int usdelay = *((int *) arg);
4708 int usdelay;
4709 va_start(ap, ctl);
4710 chan = va_arg(ap, int);
4711 usdelay = va_arg(ap, int);
4712 va_end(ap);
4408 if (usdelay == 0) {
4409 usdelay = 250000;
4410 }
4713 if (usdelay == 0) {
4714 usdelay = 250000;
4715 }
4411 return (isp_fclink_test(isp, usdelay));
4716 return (isp_fclink_test(isp, chan, usdelay));
4412 }
4413 break;
4414
4415 case ISPCTL_SCAN_FABRIC:
4416
4417 if (IS_FC(isp)) {
4717 }
4718 break;
4719
4720 case ISPCTL_SCAN_FABRIC:
4721
4722 if (IS_FC(isp)) {
4418 return (isp_scan_fabric(isp));
4723 va_start(ap, ctl);
4724 chan = va_arg(ap, int);
4725 va_end(ap);
4726 return (isp_scan_fabric(isp, chan));
4419 }
4420 break;
4421
4422 case ISPCTL_SCAN_LOOP:
4423
4424 if (IS_FC(isp)) {
4727 }
4728 break;
4729
4730 case ISPCTL_SCAN_LOOP:
4731
4732 if (IS_FC(isp)) {
4425 return (isp_scan_loop(isp));
4733 va_start(ap, ctl);
4734 chan = va_arg(ap, int);
4735 va_end(ap);
4736 return (isp_scan_loop(isp, chan));
4426 }
4427 break;
4428
4429 case ISPCTL_PDB_SYNC:
4430
4431 if (IS_FC(isp)) {
4737 }
4738 break;
4739
4740 case ISPCTL_PDB_SYNC:
4741
4742 if (IS_FC(isp)) {
4432 return (isp_pdb_sync(isp));
4743 va_start(ap, ctl);
4744 chan = va_arg(ap, int);
4745 va_end(ap);
4746 return (isp_pdb_sync(isp, chan));
4433 }
4434 break;
4435
4436 case ISPCTL_SEND_LIP:
4437
4438 if (IS_FC(isp) && !IS_24XX(isp)) {
4747 }
4748 break;
4749
4750 case ISPCTL_SEND_LIP:
4751
4752 if (IS_FC(isp) && !IS_24XX(isp)) {
4439 mbs.param[0] = MBOX_INIT_LIP;
4440 if (FCPARAM(isp)->isp_2klogin) {
4753 MBSINIT(&mbs, MBOX_INIT_LIP, MBLOGALL, 0);
4754 if (ISP_CAP_2KLOGIN(isp)) {
4441 mbs.ibits = (1 << 10);
4442 }
4755 mbs.ibits = (1 << 10);
4756 }
4443 mbs.logval = MBLOGALL;
4444 isp_mboxcmd(isp, &mbs);
4445 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
4446 return (0);
4447 }
4448 }
4449 break;
4450
4451 case ISPCTL_GET_PDB:
4757 isp_mboxcmd(isp, &mbs);
4758 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
4759 return (0);
4760 }
4761 }
4762 break;
4763
4764 case ISPCTL_GET_PDB:
4452 if (IS_FC(isp) && arg) {
4453 int id = *((int *)arg);
4454 isp_pdb_t *pdb = arg;
4455 return (isp_getpdb(isp, id, pdb, 1));
4765 if (IS_FC(isp)) {
4766 isp_pdb_t *pdb;
4767 va_start(ap, ctl);
4768 chan = va_arg(ap, int);
4769 tgt = va_arg(ap, int);
4770 pdb = va_arg(ap, isp_pdb_t *);
4771 va_end(ap);
4772 return (isp_getpdb(isp, chan, tgt, pdb, 1));
4456 }
4457 break;
4458
4773 }
4774 break;
4775
4459 case ISPCTL_GET_PORTNAME:
4776 case ISPCTL_GET_NAMES:
4460 {
4777 {
4461 uint64_t *wwnp = arg;
4462 int loopid = *wwnp;
4463 *wwnp = isp_get_portname(isp, loopid, 0);
4464 if (*wwnp == (uint64_t) -1) {
4778 uint64_t *wwnn, *wwnp;
4779 va_start(ap, ctl);
4780 chan = va_arg(ap, int);
4781 tgt = va_arg(ap, int);
4782 wwnn = va_arg(ap, uint64_t *);
4783 wwnp = va_arg(ap, uint64_t *);
4784 va_end(ap);
4785 if (wwnn == NULL && wwnp == NULL) {
4465 break;
4786 break;
4466 } else {
4467 return (0);
4468 }
4787 }
4788 if (wwnn) {
4789 *wwnn = isp_get_wwn(isp, chan, tgt, 1);
4790 if (*wwnn == INI_NONE) {
4791 break;
4792 }
4793 }
4794 if (wwnp) {
4795 *wwnp = isp_get_wwn(isp, chan, tgt, 0);
4796 if (*wwnp == INI_NONE) {
4797 break;
4798 }
4799 }
4800 return (0);
4469 }
4470 case ISPCTL_RUN_MBOXCMD:
4801 }
4802 case ISPCTL_RUN_MBOXCMD:
4471
4472 isp_mboxcmd(isp, arg);
4473 return(0);
4474
4803 {
4804 va_start(ap, ctl);
4805 mbr = va_arg(ap, mbreg_t *);
4806 va_end(ap);
4807 isp_mboxcmd(isp, mbr);
4808 return (0);
4809 }
4475 case ISPCTL_PLOGX:
4476 {
4810 case ISPCTL_PLOGX:
4811 {
4477 isp_plcmd_t *p = arg;
4812 isp_plcmd_t *p;
4478 int r;
4479
4813 int r;
4814
4480 if ((p->flags & PLOGX_FLG_CMD_MASK) != PLOGX_FLG_CMD_PLOGI ||
4481 (p->handle != NIL_HANDLE)) {
4482 return (isp_plogx(isp, p->handle, p->portid,
4483 p->flags, 0));
4815 va_start(ap, ctl);
4816 p = va_arg(ap, isp_plcmd_t *);
4817 va_end(ap);
4818
4819 if ((p->flags & PLOGX_FLG_CMD_MASK) != PLOGX_FLG_CMD_PLOGI || (p->handle != NIL_HANDLE)) {
4820 return (isp_plogx(isp, p->channel, p->handle, p->portid, p->flags, 0));
4484 }
4485 do {
4821 }
4822 do {
4486 p->handle = isp_nxt_handle(isp, p->handle);
4487 r = isp_plogx(isp, p->handle, p->portid, p->flags, 0);
4823 p->handle = isp_nxt_handle(isp, p->channel, p->handle);
4824 r = isp_plogx(isp, p->channel, p->handle, p->portid, p->flags, 0);
4488 if ((r & 0xffff) == MBOX_PORT_ID_USED) {
4489 p->handle = r >> 16;
4490 r = 0;
4491 break;
4492 }
4493 } while ((r & 0xffff) == MBOX_LOOP_ID_USED);
4494 return (r);
4495 }
4825 if ((r & 0xffff) == MBOX_PORT_ID_USED) {
4826 p->handle = r >> 16;
4827 r = 0;
4828 break;
4829 }
4830 } while ((r & 0xffff) == MBOX_LOOP_ID_USED);
4831 return (r);
4832 }
4496#ifdef ISP_TARGET_MODE
4497 case ISPCTL_TOGGLE_TMODE:
4498 {
4833 default:
4834 isp_prt(isp, ISP_LOGERR, "Unknown Control Opcode 0x%x", ctl);
4835 break;
4499
4836
4500 /*
4501 * We don't check/set against role here- that's the
4502 * responsibility for the outer layer to coordinate.
4503 */
4504 if (IS_SCSI(isp)) {
4505 int param = *(int *)arg;
4506 mbs.param[0] = MBOX_ENABLE_TARGET_MODE;
4507 mbs.param[1] = param & 0xffff;
4508 mbs.param[2] = param >> 16;
4509 mbs.logval = MBLOGALL;
4510 isp_mboxcmd(isp, &mbs);
4511 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
4512 break;
4513 }
4514 }
4515 return (0);
4516 }
4837 }
4517#endif
4518 }
4519 return (-1);
4520}
4521
4522/*
4523 * Interrupt Service Routine(s).
4524 *
4525 * External (OS) framework has done the appropriate locking,
4526 * and the locking will be held throughout this function.

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

4543
4544again:
4545 optr = isp->isp_residx;
4546 /*
4547 * Is this a mailbox related interrupt?
4548 * The mailbox semaphore will be nonzero if so.
4549 */
4550 if (sema) {
4838 return (-1);
4839}
4840
4841/*
4842 * Interrupt Service Routine(s).
4843 *
4844 * External (OS) framework has done the appropriate locking,
4845 * and the locking will be held throughout this function.

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

4862
4863again:
4864 optr = isp->isp_residx;
4865 /*
4866 * Is this a mailbox related interrupt?
4867 * The mailbox semaphore will be nonzero if so.
4868 */
4869 if (sema) {
4870 fmbox:
4551 if (mbox & 0x4000) {
4552 isp->isp_intmboxc++;
4553 if (isp->isp_mboxbsy) {
4554 int obits = isp->isp_obits;
4555 isp->isp_mboxtmp[0] = mbox;
4556 for (i = 1; i < MAX_MAILBOX(isp); i++) {
4557 if ((obits & (1 << i)) == 0) {
4558 continue;
4559 }
4871 if (mbox & 0x4000) {
4872 isp->isp_intmboxc++;
4873 if (isp->isp_mboxbsy) {
4874 int obits = isp->isp_obits;
4875 isp->isp_mboxtmp[0] = mbox;
4876 for (i = 1; i < MAX_MAILBOX(isp); i++) {
4877 if ((obits & (1 << i)) == 0) {
4878 continue;
4879 }
4560 isp->isp_mboxtmp[i] =
4561 ISP_READ(isp, MBOX_OFF(i));
4880 isp->isp_mboxtmp[i] = ISP_READ(isp, MBOX_OFF(i));
4562 }
4563 if (isp->isp_mbxwrk0) {
4564 if (isp_mbox_continue(isp) == 0) {
4565 return;
4566 }
4567 }
4568 MBOX_NOTIFY_COMPLETE(isp);
4569 } else {
4881 }
4882 if (isp->isp_mbxwrk0) {
4883 if (isp_mbox_continue(isp) == 0) {
4884 return;
4885 }
4886 }
4887 MBOX_NOTIFY_COMPLETE(isp);
4888 } else {
4570 isp_prt(isp, ISP_LOGWARN,
4571 "mailbox cmd (0x%x) with no waiters", mbox);
4889 isp_prt(isp, ISP_LOGWARN, "mailbox cmd (0x%x) with no waiters", mbox);
4572 }
4573 } else if (isp_parse_async(isp, mbox) < 0) {
4574 return;
4575 }
4890 }
4891 } else if (isp_parse_async(isp, mbox) < 0) {
4892 return;
4893 }
4576 if ((IS_FC(isp) && mbox != ASYNC_RIO_RESP) ||
4577 isp->isp_state != ISP_RUNSTATE) {
4894 if ((IS_FC(isp) && mbox != ASYNC_RIO_RESP) || isp->isp_state != ISP_RUNSTATE) {
4578 goto out;
4579 }
4580 }
4581
4582 /*
4583 * We can't be getting this now.
4584 */
4585 if (isp->isp_state != ISP_RUNSTATE) {
4895 goto out;
4896 }
4897 }
4898
4899 /*
4900 * We can't be getting this now.
4901 */
4902 if (isp->isp_state != ISP_RUNSTATE) {
4586 isp_prt(isp, ISP_LOGINFO,
4587 "interrupt (ISR=%x SEMA=%x) when not ready", isr, sema);
4588 /*
4903 /*
4904 * This seems to happen to 23XX and 24XX cards- don't know why.
4905 */
4906 if (isp->isp_mboxbsy && isp->isp_lastmbxcmd == MBOX_ABOUT_FIRMWARE) {
4907 goto fmbox;
4908 }
4909 isp_prt(isp, ISP_LOGINFO, "interrupt (ISR=%x SEMA=%x) when not ready", isr, sema);
4910 /*
4589 * Thank you very much! *Burrrp*!
4590 */
4911 * Thank you very much! *Burrrp*!
4912 */
4591 ISP_WRITE(isp, isp->isp_respoutrp,
4592 ISP_READ(isp, isp->isp_respinrp));
4913 ISP_WRITE(isp, isp->isp_respoutrp, ISP_READ(isp, isp->isp_respinrp));
4593 if (IS_24XX(isp)) {
4594 ISP_DISABLE_INTS(isp);
4595 }
4596 goto out;
4597 }
4598
4599#ifdef ISP_TARGET_MODE
4600 /*
4601 * Check for ATIO Queue entries.
4602 */
4914 if (IS_24XX(isp)) {
4915 ISP_DISABLE_INTS(isp);
4916 }
4917 goto out;
4918 }
4919
4920#ifdef ISP_TARGET_MODE
4921 /*
4922 * Check for ATIO Queue entries.
4923 */
4603 if (isp->isp_rspbsy == 0 && (isp->isp_role & ISP_ROLE_TARGET) &&
4604 IS_24XX(isp)) {
4605 iptr = ISP_READ(isp, isp->isp_atioinrp);
4606 optr = ISP_READ(isp, isp->isp_atiooutrp);
4924 if (IS_24XX(isp)) {
4925 iptr = ISP_READ(isp, BIU2400_ATIO_RSPINP);
4926 optr = ISP_READ(isp, BIU2400_ATIO_RSPOUTP);
4607
4927
4608 isp->isp_rspbsy = 1;
4609 while (optr != iptr) {
4610 uint8_t qe[QENTRY_LEN];
4611 isphdr_t *hp;
4612 uint32_t oop;
4613 void *addr;
4614
4615 oop = optr;
4616 MEMORYBARRIER(isp, SYNC_ATIOQ, oop, QENTRY_LEN);
4617 addr = ISP_QUEUE_ENTRY(isp->isp_atioq, oop);
4618 isp_get_hdr(isp, addr, (isphdr_t *)qe);
4619 hp = (isphdr_t *)qe;
4620 switch (hp->rqs_entry_type) {
4621 case RQSTYPE_NOTIFY:
4622 case RQSTYPE_ATIO:
4623 (void) isp_target_notify(isp, addr, &oop);
4624 break;
4625 default:
4928 while (optr != iptr) {
4929 uint8_t qe[QENTRY_LEN];
4930 isphdr_t *hp;
4931 uint32_t oop;
4932 void *addr;
4933
4934 oop = optr;
4935 MEMORYBARRIER(isp, SYNC_ATIOQ, oop, QENTRY_LEN);
4936 addr = ISP_QUEUE_ENTRY(isp->isp_atioq, oop);
4937 isp_get_hdr(isp, addr, (isphdr_t *)qe);
4938 hp = (isphdr_t *)qe;
4939 switch (hp->rqs_entry_type) {
4940 case RQSTYPE_NOTIFY:
4941 case RQSTYPE_ATIO:
4942 (void) isp_target_notify(isp, addr, &oop);
4943 break;
4944 default:
4626 isp_print_qentry(isp, "?ATIOQ entry?",
4627 oop, addr);
4945 isp_print_qentry(isp, "?ATIOQ entry?", oop, addr);
4628 break;
4629 }
4630 optr = ISP_NXT_QENTRY(oop, RESULT_QUEUE_LEN(isp));
4946 break;
4947 }
4948 optr = ISP_NXT_QENTRY(oop, RESULT_QUEUE_LEN(isp));
4631 ISP_WRITE(isp, isp->isp_atiooutrp, optr);
4949 ISP_WRITE(isp, BIU2400_ATIO_RSPOUTP, optr);
4632 }
4950 }
4633 isp->isp_rspbsy = 0;
4634 optr = isp->isp_residx;
4635 }
4636#endif
4637
4638 /*
4639 * Get the current Response Queue Out Pointer.
4640 *
4641 * If we're a 2300 or 2400, we can ask what hardware what it thinks.
4642 */
4643 if (IS_23XX(isp) || IS_24XX(isp)) {
4644 optr = ISP_READ(isp, isp->isp_respoutrp);
4645 /*
4646 * Debug: to be taken out eventually
4647 */
4648 if (isp->isp_residx != optr) {
4951 optr = isp->isp_residx;
4952 }
4953#endif
4954
4955 /*
4956 * Get the current Response Queue Out Pointer.
4957 *
4958 * If we're a 2300 or 2400, we can ask what hardware what it thinks.
4959 */
4960 if (IS_23XX(isp) || IS_24XX(isp)) {
4961 optr = ISP_READ(isp, isp->isp_respoutrp);
4962 /*
4963 * Debug: to be taken out eventually
4964 */
4965 if (isp->isp_residx != optr) {
4649 isp_prt(isp, ISP_LOGINFO,
4650 "isp_intr: hard optr=%x, soft optr %x",
4651 optr, isp->isp_residx);
4966 isp_prt(isp, ISP_LOGINFO, "isp_intr: hard optr=%x, soft optr %x", optr, isp->isp_residx);
4652 isp->isp_residx = optr;
4653 }
4654 } else {
4655 optr = isp->isp_residx;
4656 }
4657
4658 /*
4659 * You *must* read the Response Queue In Pointer

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

4664 if (IS_2100(isp) || (IS_2300(isp) && isp->isp_revision < 2)) {
4665 i = 0;
4666 do {
4667 iptr = ISP_READ(isp, isp->isp_respinrp);
4668 junk = ISP_READ(isp, isp->isp_respinrp);
4669 } while (junk != iptr && ++i < 1000);
4670
4671 if (iptr != junk) {
4967 isp->isp_residx = optr;
4968 }
4969 } else {
4970 optr = isp->isp_residx;
4971 }
4972
4973 /*
4974 * You *must* read the Response Queue In Pointer

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

4979 if (IS_2100(isp) || (IS_2300(isp) && isp->isp_revision < 2)) {
4980 i = 0;
4981 do {
4982 iptr = ISP_READ(isp, isp->isp_respinrp);
4983 junk = ISP_READ(isp, isp->isp_respinrp);
4984 } while (junk != iptr && ++i < 1000);
4985
4986 if (iptr != junk) {
4672 isp_prt(isp, ISP_LOGWARN,
4673 "Response Queue Out Pointer Unstable (%x, %x)",
4674 iptr, junk);
4987 isp_prt(isp, ISP_LOGWARN, "Response Queue Out Pointer Unstable (%x, %x)", iptr, junk);
4675 goto out;
4676 }
4677 } else {
4678 iptr = ISP_READ(isp, isp->isp_respinrp);
4679 }
4680 isp->isp_resodx = iptr;
4681
4682

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

4687 *
4688 * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to
4689 * make sure the old interrupt went away (to avoid 'ringing'
4690 * effects), but that didn't stop this from occurring.
4691 */
4692 if (IS_24XX(isp)) {
4693 junk = 0;
4694 } else if (IS_23XX(isp)) {
4988 goto out;
4989 }
4990 } else {
4991 iptr = ISP_READ(isp, isp->isp_respinrp);
4992 }
4993 isp->isp_resodx = iptr;
4994
4995

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

5000 *
5001 * I tried delaying after writing HCCR_CMD_CLEAR_RISC_INT to
5002 * make sure the old interrupt went away (to avoid 'ringing'
5003 * effects), but that didn't stop this from occurring.
5004 */
5005 if (IS_24XX(isp)) {
5006 junk = 0;
5007 } else if (IS_23XX(isp)) {
4695 USEC_DELAY(100);
5008 ISP_DELAY(100);
4696 iptr = ISP_READ(isp, isp->isp_respinrp);
4697 junk = ISP_READ(isp, BIU_R2HSTSLO);
4698 } else {
4699 junk = ISP_READ(isp, BIU_ISR);
4700 }
4701 if (optr == iptr) {
4702 if (IS_23XX(isp) || IS_24XX(isp)) {
4703 ;
4704 } else {
4705 sema = ISP_READ(isp, BIU_SEMA);
4706 mbox = ISP_READ(isp, OUTMAILBOX0);
4707 if ((sema & 0x3) && (mbox & 0x8000)) {
4708 goto again;
4709 }
4710 }
4711 isp->isp_intbogus++;
5009 iptr = ISP_READ(isp, isp->isp_respinrp);
5010 junk = ISP_READ(isp, BIU_R2HSTSLO);
5011 } else {
5012 junk = ISP_READ(isp, BIU_ISR);
5013 }
5014 if (optr == iptr) {
5015 if (IS_23XX(isp) || IS_24XX(isp)) {
5016 ;
5017 } else {
5018 sema = ISP_READ(isp, BIU_SEMA);
5019 mbox = ISP_READ(isp, OUTMAILBOX0);
5020 if ((sema & 0x3) && (mbox & 0x8000)) {
5021 goto again;
5022 }
5023 }
5024 isp->isp_intbogus++;
4712 isp_prt(isp, ISP_LOGDEBUG1,
4713 "bogus intr- isr %x (%x) iptr %x optr %x",
4714 isr, junk, iptr, optr);
5025 isp_prt(isp, ISP_LOGDEBUG1, "bogus intr- isr %x (%x) iptr %x optr %x", isr, junk, iptr, optr);
4715 }
4716 }
4717 isp->isp_resodx = iptr;
4718
5026 }
5027 }
5028 isp->isp_resodx = iptr;
5029
4719
4720 if (isp->isp_rspbsy) {
4721 goto out;
4722 }
4723 isp->isp_rspbsy = 1;
4724 while (optr != iptr) {
4725 uint8_t qe[QENTRY_LEN];
4726 ispstatusreq_t *sp = (ispstatusreq_t *) qe;
4727 isphdr_t *hp;
4728 int buddaboom, etype, scsi_status, completion_status;
4729 int req_status_flags, req_state_flags;
4730 uint8_t *snsp, *resp;
4731 uint32_t rlen, slen;

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

4744 * Synchronize our view of this response queue entry.
4745 */
4746 MEMORYBARRIER(isp, SYNC_RESULT, oop, QENTRY_LEN);
4747 isp_get_hdr(isp, hp, &sp->req_header);
4748 etype = sp->req_header.rqs_entry_type;
4749
4750 if (IS_24XX(isp) && etype == RQSTYPE_RESPONSE) {
4751 isp24xx_statusreq_t *sp2 = (isp24xx_statusreq_t *)qe;
5030 while (optr != iptr) {
5031 uint8_t qe[QENTRY_LEN];
5032 ispstatusreq_t *sp = (ispstatusreq_t *) qe;
5033 isphdr_t *hp;
5034 int buddaboom, etype, scsi_status, completion_status;
5035 int req_status_flags, req_state_flags;
5036 uint8_t *snsp, *resp;
5037 uint32_t rlen, slen;

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

5050 * Synchronize our view of this response queue entry.
5051 */
5052 MEMORYBARRIER(isp, SYNC_RESULT, oop, QENTRY_LEN);
5053 isp_get_hdr(isp, hp, &sp->req_header);
5054 etype = sp->req_header.rqs_entry_type;
5055
5056 if (IS_24XX(isp) && etype == RQSTYPE_RESPONSE) {
5057 isp24xx_statusreq_t *sp2 = (isp24xx_statusreq_t *)qe;
4752 isp_get_24xx_response(isp,
4753 (isp24xx_statusreq_t *)hp, sp2);
5058 isp_get_24xx_response(isp, (isp24xx_statusreq_t *)hp, sp2);
4754 if (isp->isp_dblev & ISP_LOGDEBUG1) {
5059 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4755 isp_print_bytes(isp,
4756 "Response Queue Entry", QENTRY_LEN, sp2);
5060 isp_print_bytes(isp, "Response Queue Entry", QENTRY_LEN, sp2);
4757 }
4758 scsi_status = sp2->req_scsi_status;
4759 completion_status = sp2->req_completion_status;
4760 req_state_flags = 0;
4761 resid = sp2->req_resid;
4762 } else if (etype == RQSTYPE_RESPONSE) {
4763 isp_get_response(isp, (ispstatusreq_t *) hp, sp);
4764 if (isp->isp_dblev & ISP_LOGDEBUG1) {
5061 }
5062 scsi_status = sp2->req_scsi_status;
5063 completion_status = sp2->req_completion_status;
5064 req_state_flags = 0;
5065 resid = sp2->req_resid;
5066 } else if (etype == RQSTYPE_RESPONSE) {
5067 isp_get_response(isp, (ispstatusreq_t *) hp, sp);
5068 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4765 isp_print_bytes(isp,
4766 "Response Queue Entry", QENTRY_LEN, sp);
5069 isp_print_bytes(isp, "Response Queue Entry", QENTRY_LEN, sp);
4767 }
4768 scsi_status = sp->req_scsi_status;
4769 completion_status = sp->req_completion_status;
4770 req_status_flags = sp->req_status_flags;
4771 req_state_flags = sp->req_state_flags;
4772 resid = sp->req_resid;
4773 } else if (etype == RQSTYPE_RIO2) {
4774 isp_rio2_t *rio = (isp_rio2_t *)qe;
4775 isp_get_rio2(isp, (isp_rio2_t *) hp, rio);
4776 if (isp->isp_dblev & ISP_LOGDEBUG1) {
5070 }
5071 scsi_status = sp->req_scsi_status;
5072 completion_status = sp->req_completion_status;
5073 req_status_flags = sp->req_status_flags;
5074 req_state_flags = sp->req_state_flags;
5075 resid = sp->req_resid;
5076 } else if (etype == RQSTYPE_RIO2) {
5077 isp_rio2_t *rio = (isp_rio2_t *)qe;
5078 isp_get_rio2(isp, (isp_rio2_t *) hp, rio);
5079 if (isp->isp_dblev & ISP_LOGDEBUG1) {
4777 isp_print_bytes(isp,
4778 "Response Queue Entry", QENTRY_LEN, rio);
5080 isp_print_bytes(isp, "Response Queue Entry", QENTRY_LEN, rio);
4779 }
4780 for (i = 0; i < rio->req_header.rqs_seqno; i++) {
4781 isp_fastpost_complete(isp, rio->req_handles[i]);
4782 }
4783 if (isp->isp_fpcchiwater < rio->req_header.rqs_seqno) {
5081 }
5082 for (i = 0; i < rio->req_header.rqs_seqno; i++) {
5083 isp_fastpost_complete(isp, rio->req_handles[i]);
5084 }
5085 if (isp->isp_fpcchiwater < rio->req_header.rqs_seqno) {
4784 isp->isp_fpcchiwater =
4785 rio->req_header.rqs_seqno;
5086 isp->isp_fpcchiwater = rio->req_header.rqs_seqno;
4786 }
5087 }
4787 MEMZERO(hp, QENTRY_LEN); /* PERF */
5088 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
4788 continue;
4789 } else {
4790 /*
4791 * Somebody reachable via isp_handle_other_response
4792 * may have updated the response queue pointers for
4793 * us, so we reload our goal index.
4794 */
4795 int r;
5089 continue;
5090 } else {
5091 /*
5092 * Somebody reachable via isp_handle_other_response
5093 * may have updated the response queue pointers for
5094 * us, so we reload our goal index.
5095 */
5096 int r;
4796 r = isp_handle_other_response(isp, etype, hp, &optr);
5097 uint32_t tsto = oop;
5098 r = isp_handle_other_response(isp, etype, hp, &tsto);
4797 if (r < 0) {
4798 goto read_again;
4799 }
5099 if (r < 0) {
5100 goto read_again;
5101 }
5102 /*
5103 * If somebody updated the output pointer, then reset
5104 * optr to be one more than the updated amount.
5105 */
5106 while (tsto != oop) {
5107 optr = ISP_NXT_QENTRY(tsto,
5108 RESULT_QUEUE_LEN(isp));
5109 }
4800 if (r > 0) {
5110 if (r > 0) {
4801 iptr = isp->isp_resodx;
4802 MEMZERO(hp, QENTRY_LEN); /* PERF */
5111 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5112 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
4803 continue;
4804 }
4805
4806 /*
4807 * After this point, we'll just look at the header as
4808 * we don't know how to deal with the rest of the
4809 * response.
4810 */
4811
4812 /*
4813 * It really has to be a bounced request just copied
4814 * from the request queue to the response queue. If
4815 * not, something bad has happened.
4816 */
4817 if (etype != RQSTYPE_REQUEST) {
4818 isp_prt(isp, ISP_LOGERR, notresp,
4819 etype, oop, optr, nlooked);
4820 isp_print_bytes(isp,
4821 "Request Queue Entry", QENTRY_LEN, sp);
5113 continue;
5114 }
5115
5116 /*
5117 * After this point, we'll just look at the header as
5118 * we don't know how to deal with the rest of the
5119 * response.
5120 */
5121
5122 /*
5123 * It really has to be a bounced request just copied
5124 * from the request queue to the response queue. If
5125 * not, something bad has happened.
5126 */
5127 if (etype != RQSTYPE_REQUEST) {
5128 isp_prt(isp, ISP_LOGERR, notresp,
5129 etype, oop, optr, nlooked);
5130 isp_print_bytes(isp,
5131 "Request Queue Entry", QENTRY_LEN, sp);
4822 MEMZERO(hp, QENTRY_LEN); /* PERF */
5132 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
4823 continue;
4824 }
4825 buddaboom = 1;
4826 scsi_status = sp->req_scsi_status;
4827 completion_status = sp->req_completion_status;
4828 req_status_flags = sp->req_status_flags;
4829 req_state_flags = sp->req_state_flags;
4830 resid = sp->req_resid;
4831 }
4832
4833 if (sp->req_header.rqs_flags & RQSFLAG_MASK) {
4834 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
5133 continue;
5134 }
5135 buddaboom = 1;
5136 scsi_status = sp->req_scsi_status;
5137 completion_status = sp->req_completion_status;
5138 req_status_flags = sp->req_status_flags;
5139 req_state_flags = sp->req_state_flags;
5140 resid = sp->req_resid;
5141 }
5142
5143 if (sp->req_header.rqs_flags & RQSFLAG_MASK) {
5144 if (sp->req_header.rqs_flags & RQSFLAG_CONTINUATION) {
4835 isp_prt(isp, ISP_LOGWARN,
4836 "continuation segment");
5145 isp_print_bytes(isp, "unexpected continuation segment", QENTRY_LEN, sp);
4837 ISP_WRITE(isp, isp->isp_respoutrp, optr);
4838 continue;
4839 }
4840 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
5146 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5147 continue;
5148 }
5149 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
4841 isp_prt(isp, ISP_LOGDEBUG1,
4842 "internal queues full");
5150 isp_prt(isp, ISP_LOGDEBUG0, "internal queues full");
4843 /*
4844 * We'll synthesize a QUEUE FULL message below.
4845 */
4846 }
4847 if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) {
5151 /*
5152 * We'll synthesize a QUEUE FULL message below.
5153 */
5154 }
5155 if (sp->req_header.rqs_flags & RQSFLAG_BADHEADER) {
4848 isp_print_bytes(isp, "bad header flag",
4849 QENTRY_LEN, sp);
5156 isp_print_bytes(isp, "bad header flag", QENTRY_LEN, sp);
4850 buddaboom++;
4851 }
4852 if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) {
5157 buddaboom++;
5158 }
5159 if (sp->req_header.rqs_flags & RQSFLAG_BADPACKET) {
4853 isp_print_bytes(isp, "bad request packet",
4854 QENTRY_LEN, sp);
5160 isp_print_bytes(isp, "bad request packet", QENTRY_LEN, sp);
4855 buddaboom++;
4856 }
5161 buddaboom++;
5162 }
5163 if (sp->req_header.rqs_flags & RQSFLAG_BADCOUNT) {
5164 isp_print_bytes(isp, "invalid entry count", QENTRY_LEN, sp);
5165 buddaboom++;
5166 }
5167 if (sp->req_header.rqs_flags & RQSFLAG_BADORDER) {
5168 isp_print_bytes(isp, "invalid IOCB ordering", QENTRY_LEN, sp);
5169 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5170 continue;
5171 }
4857 }
4858
5172 }
5173
4859 if (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1) {
4860 isp_prt(isp, ISP_LOGERR,
4861 "bad request handle %d (type 0x%x)",
4862 sp->req_handle, etype);
4863 MEMZERO(hp, QENTRY_LEN); /* PERF */
5174 if ((sp->req_handle != ISP_SPCL_HANDLE) && (sp->req_handle > isp->isp_maxcmds || sp->req_handle < 1)) {
5175 isp_prt(isp, ISP_LOGERR, "bad request handle %d (type 0x%x)", sp->req_handle, etype);
5176 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
4864 ISP_WRITE(isp, isp->isp_respoutrp, optr);
4865 continue;
4866 }
4867 xs = isp_find_xs(isp, sp->req_handle);
4868 if (xs == NULL) {
4869 uint8_t ts = completion_status & 0xff;
4870 /*
4871 * Only whine if this isn't the expected fallout of
5177 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5178 continue;
5179 }
5180 xs = isp_find_xs(isp, sp->req_handle);
5181 if (xs == NULL) {
5182 uint8_t ts = completion_status & 0xff;
5183 /*
5184 * Only whine if this isn't the expected fallout of
4872 * aborting the command.
5185 * aborting the command or resetting the target.
4873 */
4874 if (etype != RQSTYPE_RESPONSE) {
5186 */
5187 if (etype != RQSTYPE_RESPONSE) {
4875 isp_prt(isp, ISP_LOGERR,
4876 "cannot find handle 0x%x (type 0x%x)",
4877 sp->req_handle, etype);
4878 } else if (ts != RQCS_ABORTED) {
4879 isp_prt(isp, ISP_LOGERR,
4880 "cannot find handle 0x%x (status 0x%x)",
4881 sp->req_handle, ts);
5188 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (type 0x%x)", sp->req_handle, etype);
5189 } else if (ts != RQCS_ABORTED && ts != RQCS_RESET_OCCURRED && sp->req_handle != ISP_SPCL_HANDLE) {
5190 isp_prt(isp, ISP_LOGERR, "cannot find handle 0x%x (status 0x%x)", sp->req_handle, ts);
4882 }
5191 }
4883 MEMZERO(hp, QENTRY_LEN); /* PERF */
5192 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
4884 ISP_WRITE(isp, isp->isp_respoutrp, optr);
4885 continue;
4886 }
4887 isp_destroy_handle(isp, sp->req_handle);
4888 if (req_status_flags & RQSTF_BUS_RESET) {
4889 XS_SETERR(xs, HBA_BUSRESET);
5193 ISP_WRITE(isp, isp->isp_respoutrp, optr);
5194 continue;
5195 }
5196 isp_destroy_handle(isp, sp->req_handle);
5197 if (req_status_flags & RQSTF_BUS_RESET) {
5198 XS_SETERR(xs, HBA_BUSRESET);
4890 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
5199 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 1);
4891 }
4892 if (buddaboom) {
4893 XS_SETERR(xs, HBA_BOTCH);
4894 }
4895
4896 resp = NULL;
4897 rlen = 0;
4898 snsp = NULL;

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

4907 if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) {
4908 /*
4909 * Fibre Channel F/W doesn't say we got status
4910 * if there's Sense Data instead. I guess they
4911 * think it goes w/o saying.
4912 */
4913 req_state_flags |= RQSF_GOT_STATUS|RQSF_GOT_SENSE;
4914 if (IS_24XX(isp)) {
5200 }
5201 if (buddaboom) {
5202 XS_SETERR(xs, HBA_BOTCH);
5203 }
5204
5205 resp = NULL;
5206 rlen = 0;
5207 snsp = NULL;

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

5216 if (IS_FC(isp) && (scsi_status & RQCS_SV) != 0) {
5217 /*
5218 * Fibre Channel F/W doesn't say we got status
5219 * if there's Sense Data instead. I guess they
5220 * think it goes w/o saying.
5221 */
5222 req_state_flags |= RQSF_GOT_STATUS|RQSF_GOT_SENSE;
5223 if (IS_24XX(isp)) {
4915 snsp =
4916 ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
5224 snsp = ((isp24xx_statusreq_t *)sp)->req_rsp_sense;
4917 snsp += rlen;
5225 snsp += rlen;
4918 slen =
4919 ((isp24xx_statusreq_t *)sp)->req_sense_len;
5226 slen = ((isp24xx_statusreq_t *)sp)->req_sense_len;
4920 } else {
4921 snsp = sp->req_sense_data;
4922 slen = sp->req_sense_len;
4923 }
4924 } else if (IS_SCSI(isp) && (req_state_flags & RQSF_GOT_SENSE)) {
4925 snsp = sp->req_sense_data;
4926 slen = sp->req_sense_len;
4927 }
4928 if (req_state_flags & RQSF_GOT_STATUS) {
4929 *XS_STSP(xs) = scsi_status & 0xff;
4930 }
4931
4932 switch (etype) {
4933 case RQSTYPE_RESPONSE:
5227 } else {
5228 snsp = sp->req_sense_data;
5229 slen = sp->req_sense_len;
5230 }
5231 } else if (IS_SCSI(isp) && (req_state_flags & RQSF_GOT_SENSE)) {
5232 snsp = sp->req_sense_data;
5233 slen = sp->req_sense_len;
5234 }
5235 if (req_state_flags & RQSF_GOT_STATUS) {
5236 *XS_STSP(xs) = scsi_status & 0xff;
5237 }
5238
5239 switch (etype) {
5240 case RQSTYPE_RESPONSE:
4934 XS_SET_STATE_STAT(isp, xs, sp);
4935 if (resp && rlen >= 4 &&
4936 resp[FCP_RSPNS_CODE_OFFSET] != 0) {
4937 isp_prt(isp, ISP_LOGWARN,
4938 "%d.%d.%d FCP RESPONSE: 0x%x",
4939 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
4940 resp[FCP_RSPNS_CODE_OFFSET]);
4941 XS_SETERR(xs, HBA_BOTCH);
5241 if (resp && rlen >= 4 && resp[FCP_RSPNS_CODE_OFFSET] != 0) {
5242 const char *ptr;
5243 char lb[64];
5244 const char *rnames[6] = {
5245 "Task Management Function Done",
5246 "Data Length Differs From Burst Length",
5247 "Invalid FCP Cmnd",
5248 "FCP DATA RO mismatch with FCP DATA_XFR_RDY RO",
5249 "Task Management Function Rejected",
5250 "Task Management Function Failed",
5251 };
5252 if (resp[FCP_RSPNS_CODE_OFFSET] > 5) {
5253 ISP_SNPRINTF(lb, sizeof lb, "Unknown FCP Response Code 0x%x", resp[FCP_RSPNS_CODE_OFFSET]);
5254 ptr = lb;
5255 } else {
5256 ptr = rnames[resp[FCP_RSPNS_CODE_OFFSET]];
5257 }
5258 isp_prt(isp, ISP_LOGWARN, "%d.%d.%d FCP RESPONSE, LENGTH %u: %s CDB0=0x%02x", XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), rlen, ptr, XS_CDBP(xs)[0] & 0xff);
5259 if (resp[FCP_RSPNS_CODE_OFFSET] != 0) {
5260 XS_SETERR(xs, HBA_BOTCH);
5261 }
4942 }
4943 if (IS_24XX(isp)) {
5262 }
5263 if (IS_24XX(isp)) {
4944 isp_parse_status_24xx(isp,
4945 (isp24xx_statusreq_t *)sp, xs, &resid);
5264 isp_parse_status_24xx(isp, (isp24xx_statusreq_t *)sp, xs, &resid);
4946 } else {
4947 isp_parse_status(isp, (void *)sp, xs, &resid);
4948 }
5265 } else {
5266 isp_parse_status(isp, (void *)sp, xs, &resid);
5267 }
4949 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) &&
4950 (*XS_STSP(xs) == SCSI_BUSY)) {
5268 if ((XS_NOERR(xs) || XS_ERR(xs) == HBA_NOERROR) && (*XS_STSP(xs) == SCSI_BUSY)) {
4951 XS_SETERR(xs, HBA_TGTBSY);
4952 }
4953 if (IS_SCSI(isp)) {
5269 XS_SETERR(xs, HBA_TGTBSY);
5270 }
5271 if (IS_SCSI(isp)) {
4954 XS_RESID(xs) = resid;
5272 XS_SET_RESID(xs, resid);
4955 /*
4956 * A new synchronous rate was negotiated for
4957 * this target. Mark state such that we'll go
4958 * look up that which has changed later.
4959 */
4960 if (req_status_flags & RQSTF_NEGOTIATION) {
4961 int t = XS_TGT(xs);
5273 /*
5274 * A new synchronous rate was negotiated for
5275 * this target. Mark state such that we'll go
5276 * look up that which has changed later.
5277 */
5278 if (req_status_flags & RQSTF_NEGOTIATION) {
5279 int t = XS_TGT(xs);
4962 sdparam *sdp = isp->isp_param;
4963 sdp += XS_CHANNEL(xs);
5280 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
4964 sdp->isp_devparam[t].dev_refresh = 1;
5281 sdp->isp_devparam[t].dev_refresh = 1;
4965 isp->isp_update |=
4966 (1 << XS_CHANNEL(xs));
5282 sdp->update = 1;
4967 }
4968 } else {
4969 if (req_status_flags & RQSF_XFER_COMPLETE) {
5283 }
5284 } else {
5285 if (req_status_flags & RQSF_XFER_COMPLETE) {
4970 XS_RESID(xs) = 0;
5286 XS_SET_RESID(xs, 0);
4971 } else if (scsi_status & RQCS_RESID) {
5287 } else if (scsi_status & RQCS_RESID) {
4972 XS_RESID(xs) = resid;
5288 XS_SET_RESID(xs, resid);
4973 } else {
5289 } else {
4974 XS_RESID(xs) = 0;
5290 XS_SET_RESID(xs, 0);
4975 }
4976 }
4977 if (snsp && slen) {
4978 XS_SAVE_SENSE(xs, snsp, slen);
5291 }
5292 }
5293 if (snsp && slen) {
5294 XS_SAVE_SENSE(xs, snsp, slen);
5295 } else if ((req_status_flags & RQSF_GOT_STATUS) && (scsi_status & 0xff) == SCSI_CHECK && IS_FC(isp)) {
5296 isp_prt(isp, ISP_LOGWARN, "CHECK CONDITION w/o sense data for CDB=0x%x", XS_CDBP(xs)[0] & 0xff);
5297 isp_print_bytes(isp, "CC with no Sense", QENTRY_LEN, qe);
4979 }
5298 }
4980 isp_prt(isp, ISP_LOGDEBUG2,
4981 "asked for %ld got raw resid %ld settled for %ld",
4982 (long) XS_XFRLEN(xs), resid, (long) XS_RESID(xs));
5299 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));
4983 break;
4984 case RQSTYPE_REQUEST:
4985 case RQSTYPE_A64:
4986 case RQSTYPE_T2RQS:
4987 case RQSTYPE_T3RQS:
4988 case RQSTYPE_T7RQS:
5300 break;
5301 case RQSTYPE_REQUEST:
5302 case RQSTYPE_A64:
5303 case RQSTYPE_T2RQS:
5304 case RQSTYPE_T3RQS:
5305 case RQSTYPE_T7RQS:
4989 if (sp->req_header.rqs_flags & RQSFLAG_FULL) {
5306 if (!IS_24XX(isp) && (sp->req_header.rqs_flags & RQSFLAG_FULL)) {
4990 /*
4991 * Force Queue Full status.
4992 */
4993 *XS_STSP(xs) = SCSI_QFULL;
4994 XS_SETERR(xs, HBA_NOERROR);
4995 } else if (XS_NOERR(xs)) {
5307 /*
5308 * Force Queue Full status.
5309 */
5310 *XS_STSP(xs) = SCSI_QFULL;
5311 XS_SETERR(xs, HBA_NOERROR);
5312 } else if (XS_NOERR(xs)) {
4996 /*
4997 * ????
4998 */
4999 XS_SETERR(xs, HBA_BOTCH);
5313 XS_SETERR(xs, HBA_BOTCH);
5000 isp_prt(isp, ISP_LOGDEBUG0,
5001 "Request Queue Entry bounced back");
5002 if ((isp->isp_dblev & ISP_LOGDEBUG1) == 0) {
5003 isp_print_bytes(isp, "Bounced Request",
5004 QENTRY_LEN, qe);
5005 }
5006 }
5314 }
5007 XS_RESID(xs) = XS_XFRLEN(xs);
5315 XS_SET_RESID(xs, XS_XFRLEN(xs));
5008 break;
5009 default:
5316 break;
5317 default:
5010 isp_print_bytes(isp, "Unhandled Response Type",
5011 QENTRY_LEN, qe);
5318 isp_print_bytes(isp, "Unhandled Response Type", QENTRY_LEN, qe);
5012 if (XS_NOERR(xs)) {
5013 XS_SETERR(xs, HBA_BOTCH);
5014 }
5015 break;
5016 }
5017
5018 /*
5019 * Free any DMA resources. As a side effect, this may
5020 * also do any cache flushing necessary for data coherence.
5021 */
5022 if (XS_XFRLEN(xs)) {
5023 ISP_DMAFREE(isp, xs, sp->req_handle);
5024 }
5025
5319 if (XS_NOERR(xs)) {
5320 XS_SETERR(xs, HBA_BOTCH);
5321 }
5322 break;
5323 }
5324
5325 /*
5326 * Free any DMA resources. As a side effect, this may
5327 * also do any cache flushing necessary for data coherence.
5328 */
5329 if (XS_XFRLEN(xs)) {
5330 ISP_DMAFREE(isp, xs, sp->req_handle);
5331 }
5332
5026 if (((isp->isp_dblev & (ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
5333 if (((isp->isp_dblev & (ISP_LOGDEBUG1|ISP_LOGDEBUG2|ISP_LOGDEBUG3))) ||
5027 ((isp->isp_dblev & ISP_LOGDEBUG0) && ((!XS_NOERR(xs)) ||
5028 (*XS_STSP(xs) != SCSI_GOOD)))) {
5029 char skey;
5030 if (req_state_flags & RQSF_GOT_SENSE) {
5031 skey = XS_SNSKEY(xs) & 0xf;
5032 if (skey < 10)
5033 skey += '0';
5034 else
5035 skey += 'a' - 10;
5036 } else if (*XS_STSP(xs) == SCSI_CHECK) {
5037 skey = '?';
5038 } else {
5039 skey = '.';
5040 }
5041 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
5334 ((isp->isp_dblev & ISP_LOGDEBUG0) && ((!XS_NOERR(xs)) ||
5335 (*XS_STSP(xs) != SCSI_GOOD)))) {
5336 char skey;
5337 if (req_state_flags & RQSF_GOT_SENSE) {
5338 skey = XS_SNSKEY(xs) & 0xf;
5339 if (skey < 10)
5340 skey += '0';
5341 else
5342 skey += 'a' - 10;
5343 } else if (*XS_STSP(xs) == SCSI_CHECK) {
5344 skey = '?';
5345 } else {
5346 skey = '.';
5347 }
5348 isp_prt(isp, ISP_LOGALL, finmsg, XS_CHANNEL(xs),
5042 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), XS_RESID(xs),
5349 XS_TGT(xs), XS_LUN(xs), XS_XFRLEN(xs), (long) XS_GET_RESID(xs),
5043 *XS_STSP(xs), skey, XS_ERR(xs));
5044 }
5045
5350 *XS_STSP(xs), skey, XS_ERR(xs));
5351 }
5352
5046 if (isp->isp_nactive > 0)
5353 if (isp->isp_nactive > 0) {
5047 isp->isp_nactive--;
5354 isp->isp_nactive--;
5355 }
5048 complist[ndone++] = xs; /* defer completion call until later */
5356 complist[ndone++] = xs; /* defer completion call until later */
5049 MEMZERO(hp, QENTRY_LEN); /* PERF */
5357 ISP_MEMZERO(hp, QENTRY_LEN); /* PERF */
5050 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
5051 break;
5052 }
5053 }
5054
5055 /*
5056 * If we looked at any commands, then it's valid to find out
5057 * what the outpointer is. It also is a trigger to update the

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

5073 if (IS_24XX(isp)) {
5074 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
5075 } else {
5076 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
5077 ISP_WRITE(isp, BIU_SEMA, 0);
5078 }
5079
5080 isp->isp_residx = optr;
5358 if (ndone == MAX_REQUESTQ_COMPLETIONS) {
5359 break;
5360 }
5361 }
5362
5363 /*
5364 * If we looked at any commands, then it's valid to find out
5365 * what the outpointer is. It also is a trigger to update the

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

5381 if (IS_24XX(isp)) {
5382 ISP_WRITE(isp, BIU2400_HCCR, HCCR_2400_CMD_CLEAR_RISC_INT);
5383 } else {
5384 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
5385 ISP_WRITE(isp, BIU_SEMA, 0);
5386 }
5387
5388 isp->isp_residx = optr;
5081 isp->isp_rspbsy = 0;
5082 for (i = 0; i < ndone; i++) {
5083 xs = complist[i];
5084 if (xs) {
5085 isp->isp_rsltccmplt++;
5086 isp_done(xs);
5087 }
5088 }
5089}
5090
5091/*
5092 * Support routines.
5093 */
5094
5389 for (i = 0; i < ndone; i++) {
5390 xs = complist[i];
5391 if (xs) {
5392 isp->isp_rsltccmplt++;
5393 isp_done(xs);
5394 }
5395 }
5396}
5397
5398/*
5399 * Support routines.
5400 */
5401
5402#define GET_24XX_BUS(isp, chan, msg) \
5403 if (IS_24XX(isp)) { \
5404 chan = ISP_READ(isp, OUTMAILBOX3) & 0xff; \
5405 if (chan >= isp->isp_nchan) { \
5406 isp_prt(isp, ISP_LOGERR, "bogus channel %u for %s at line %d", chan, msg, __LINE__); \
5407 break; \
5408 } \
5409 }
5410
5095static int
5096isp_parse_async(ispsoftc_t *isp, uint16_t mbox)
5097{
5098 int rval = 0;
5411static int
5412isp_parse_async(ispsoftc_t *isp, uint16_t mbox)
5413{
5414 int rval = 0;
5099 int bus;
5415 int pattern = 0;
5416 uint16_t chan;
5100
5101 if (IS_DUALBUS(isp)) {
5417
5418 if (IS_DUALBUS(isp)) {
5102 bus = ISP_READ(isp, OUTMAILBOX6);
5419 chan = ISP_READ(isp, OUTMAILBOX6);
5103 } else {
5420 } else {
5104 bus = 0;
5421 chan = 0;
5105 }
5106 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
5107
5108 switch (mbox) {
5109 case ASYNC_BUS_RESET:
5422 }
5423 isp_prt(isp, ISP_LOGDEBUG2, "Async Mbox 0x%x", mbox);
5424
5425 switch (mbox) {
5426 case ASYNC_BUS_RESET:
5110 isp->isp_sendmarker |= (1 << bus);
5427 if (IS_FC(isp)) {
5428 isp_prt(isp, ISP_LOGWARN,
5429 "ILLEGAL ASYNC_BUS_RESET for FC card");
5430 break;
5431 }
5432 ISP_SET_SENDMARKER(isp, chan, 1);
5111#ifdef ISP_TARGET_MODE
5433#ifdef ISP_TARGET_MODE
5112 if (isp_target_async(isp, bus, mbox)) {
5434 if (isp_target_async(isp, chan, mbox)) {
5113 rval = -1;
5114 }
5115#endif
5435 rval = -1;
5436 }
5437#endif
5116 isp_async(isp, ISPASYNC_BUS_RESET, &bus);
5438 isp_async(isp, ISPASYNC_BUS_RESET, chan);
5117 break;
5118 case ASYNC_SYSTEM_ERROR:
5439 break;
5440 case ASYNC_SYSTEM_ERROR:
5441 isp->isp_dead = 1;
5119 isp->isp_state = ISP_CRASHED;
5120 if (IS_FC(isp)) {
5442 isp->isp_state = ISP_CRASHED;
5443 if (IS_FC(isp)) {
5121 FCPARAM(isp)->isp_loopstate = LOOP_NIL;
5122 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
5444 FCPARAM(isp, chan)->isp_loopstate = LOOP_NIL;
5445 FCPARAM(isp, chan)->isp_fwstate = FW_CONFIG_WAIT;
5123 }
5124 /*
5125 * Were we waiting for a mailbox command to complete?
5126 * If so, it's dead, so wake up the waiter.
5127 */
5128 if (isp->isp_mboxbsy) {
5129 isp->isp_obits = 1;
5130 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
5131 MBOX_NOTIFY_COMPLETE(isp);
5132 }
5133 /*
5134 * It's up to the handler for isp_async to reinit stuff and
5135 * restart the firmware
5136 */
5446 }
5447 /*
5448 * Were we waiting for a mailbox command to complete?
5449 * If so, it's dead, so wake up the waiter.
5450 */
5451 if (isp->isp_mboxbsy) {
5452 isp->isp_obits = 1;
5453 isp->isp_mboxtmp[0] = MBOX_HOST_INTERFACE_ERROR;
5454 MBOX_NOTIFY_COMPLETE(isp);
5455 }
5456 /*
5457 * It's up to the handler for isp_async to reinit stuff and
5458 * restart the firmware
5459 */
5137 isp_async(isp, ISPASYNC_FW_CRASH, NULL);
5460 isp_async(isp, ISPASYNC_FW_CRASH);
5138 rval = -1;
5139 break;
5140
5141 case ASYNC_RQS_XFER_ERR:
5142 isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error");
5143 break;
5144
5145 case ASYNC_RSP_XFER_ERR:
5146 isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error");
5147 break;
5148
5149 case ASYNC_QWAKEUP:
5461 rval = -1;
5462 break;
5463
5464 case ASYNC_RQS_XFER_ERR:
5465 isp_prt(isp, ISP_LOGERR, "Request Queue Transfer Error");
5466 break;
5467
5468 case ASYNC_RSP_XFER_ERR:
5469 isp_prt(isp, ISP_LOGERR, "Response Queue Transfer Error");
5470 break;
5471
5472 case ASYNC_QWAKEUP:
5473#ifdef ISP_TARGET_MODE
5474 if (IS_24XX(isp)) {
5475 isp_prt(isp, ISP_LOGERR, "ATIO Queue Transfer Error");
5476 break;
5477 }
5478#endif
5479 if (IS_FC(isp)) {
5480 isp_prt(isp, ISP_LOGWARN,
5481 "ILLEGAL ASYNC_QWAKEUP for FC card");
5482 break;
5483 }
5150 /*
5151 * We've just been notified that the Queue has woken up.
5152 * We don't need to be chatty about this- just unlatch things
5153 * and move on.
5154 */
5155 mbox = ISP_READ(isp, isp->isp_rqstoutrp);
5156 break;
5157
5158 case ASYNC_TIMEOUT_RESET:
5484 /*
5485 * We've just been notified that the Queue has woken up.
5486 * We don't need to be chatty about this- just unlatch things
5487 * and move on.
5488 */
5489 mbox = ISP_READ(isp, isp->isp_rqstoutrp);
5490 break;
5491
5492 case ASYNC_TIMEOUT_RESET:
5493 if (IS_FC(isp)) {
5494 isp_prt(isp, ISP_LOGWARN,
5495 "ILLEGAL ASYNC_TIMEOUT_RESET for FC card");
5496 break;
5497 }
5159 isp_prt(isp, ISP_LOGWARN,
5498 isp_prt(isp, ISP_LOGWARN,
5160 "timeout initiated SCSI bus reset of bus %d", bus);
5161 isp->isp_sendmarker |= (1 << bus);
5499 "timeout initiated SCSI bus reset of chan %d", chan);
5500 ISP_SET_SENDMARKER(isp, chan, 1);
5162#ifdef ISP_TARGET_MODE
5501#ifdef ISP_TARGET_MODE
5163 if (isp_target_async(isp, bus, mbox)) {
5502 if (isp_target_async(isp, chan, mbox)) {
5164 rval = -1;
5165 }
5166#endif
5167 break;
5168
5169 case ASYNC_DEVICE_RESET:
5503 rval = -1;
5504 }
5505#endif
5506 break;
5507
5508 case ASYNC_DEVICE_RESET:
5170 isp_prt(isp, ISP_LOGINFO, "device reset on bus %d", bus);
5171 isp->isp_sendmarker |= (1 << bus);
5509 if (IS_FC(isp)) {
5510 isp_prt(isp, ISP_LOGWARN,
5511 "ILLEGAL DEVICE_RESET for FC card");
5512 break;
5513 }
5514 isp_prt(isp, ISP_LOGINFO, "device reset on chan %d", chan);
5515 ISP_SET_SENDMARKER(isp, chan, 1);
5172#ifdef ISP_TARGET_MODE
5516#ifdef ISP_TARGET_MODE
5173 if (isp_target_async(isp, bus, mbox)) {
5517 if (isp_target_async(isp, chan, mbox)) {
5174 rval = -1;
5175 }
5176#endif
5177 break;
5178
5179 case ASYNC_EXTMSG_UNDERRUN:
5518 rval = -1;
5519 }
5520#endif
5521 break;
5522
5523 case ASYNC_EXTMSG_UNDERRUN:
5524 if (IS_FC(isp)) {
5525 isp_prt(isp, ISP_LOGWARN,
5526 "ILLEGAL ASYNC_EXTMSG_UNDERRUN for FC card");
5527 break;
5528 }
5180 isp_prt(isp, ISP_LOGWARN, "extended message underrun");
5181 break;
5182
5183 case ASYNC_SCAM_INT:
5529 isp_prt(isp, ISP_LOGWARN, "extended message underrun");
5530 break;
5531
5532 case ASYNC_SCAM_INT:
5533 if (IS_FC(isp)) {
5534 isp_prt(isp, ISP_LOGWARN,
5535 "ILLEGAL ASYNC_SCAM_INT for FC card");
5536 break;
5537 }
5184 isp_prt(isp, ISP_LOGINFO, "SCAM interrupt");
5185 break;
5186
5187 case ASYNC_HUNG_SCSI:
5538 isp_prt(isp, ISP_LOGINFO, "SCAM interrupt");
5539 break;
5540
5541 case ASYNC_HUNG_SCSI:
5542 if (IS_FC(isp)) {
5543 isp_prt(isp, ISP_LOGWARN,
5544 "ILLEGAL ASYNC_HUNG_SCSI for FC card");
5545 break;
5546 }
5188 isp_prt(isp, ISP_LOGERR,
5189 "stalled SCSI Bus after DATA Overrun");
5190 /* XXX: Need to issue SCSI reset at this point */
5191 break;
5192
5193 case ASYNC_KILLED_BUS:
5547 isp_prt(isp, ISP_LOGERR,
5548 "stalled SCSI Bus after DATA Overrun");
5549 /* XXX: Need to issue SCSI reset at this point */
5550 break;
5551
5552 case ASYNC_KILLED_BUS:
5553 if (IS_FC(isp)) {
5554 isp_prt(isp, ISP_LOGWARN,
5555 "ILLEGAL ASYNC_KILLED_BUS for FC card");
5556 break;
5557 }
5194 isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun");
5195 break;
5196
5197 case ASYNC_BUS_TRANSIT:
5558 isp_prt(isp, ISP_LOGERR, "SCSI Bus reset after DATA Overrun");
5559 break;
5560
5561 case ASYNC_BUS_TRANSIT:
5562 if (IS_FC(isp)) {
5563 isp_prt(isp, ISP_LOGWARN,
5564 "ILLEGAL ASYNC_BUS_TRANSIT for FC card");
5565 break;
5566 }
5198 mbox = ISP_READ(isp, OUTMAILBOX2);
5199 switch (mbox & 0x1c00) {
5200 case SXP_PINS_LVD_MODE:
5201 isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode");
5567 mbox = ISP_READ(isp, OUTMAILBOX2);
5568 switch (mbox & 0x1c00) {
5569 case SXP_PINS_LVD_MODE:
5570 isp_prt(isp, ISP_LOGINFO, "Transition to LVD mode");
5202 SDPARAM(isp)->isp_diffmode = 0;
5203 SDPARAM(isp)->isp_ultramode = 0;
5204 SDPARAM(isp)->isp_lvdmode = 1;
5571 SDPARAM(isp, chan)->isp_diffmode = 0;
5572 SDPARAM(isp, chan)->isp_ultramode = 0;
5573 SDPARAM(isp, chan)->isp_lvdmode = 1;
5205 break;
5206 case SXP_PINS_HVD_MODE:
5207 isp_prt(isp, ISP_LOGINFO,
5208 "Transition to Differential mode");
5574 break;
5575 case SXP_PINS_HVD_MODE:
5576 isp_prt(isp, ISP_LOGINFO,
5577 "Transition to Differential mode");
5209 SDPARAM(isp)->isp_diffmode = 1;
5210 SDPARAM(isp)->isp_ultramode = 0;
5211 SDPARAM(isp)->isp_lvdmode = 0;
5578 SDPARAM(isp, chan)->isp_diffmode = 1;
5579 SDPARAM(isp, chan)->isp_ultramode = 0;
5580 SDPARAM(isp, chan)->isp_lvdmode = 0;
5212 break;
5213 case SXP_PINS_SE_MODE:
5214 isp_prt(isp, ISP_LOGINFO,
5215 "Transition to Single Ended mode");
5581 break;
5582 case SXP_PINS_SE_MODE:
5583 isp_prt(isp, ISP_LOGINFO,
5584 "Transition to Single Ended mode");
5216 SDPARAM(isp)->isp_diffmode = 0;
5217 SDPARAM(isp)->isp_ultramode = 1;
5218 SDPARAM(isp)->isp_lvdmode = 0;
5585 SDPARAM(isp, chan)->isp_diffmode = 0;
5586 SDPARAM(isp, chan)->isp_ultramode = 1;
5587 SDPARAM(isp, chan)->isp_lvdmode = 0;
5219 break;
5220 default:
5221 isp_prt(isp, ISP_LOGWARN,
5222 "Transition to Unknown Mode 0x%x", mbox);
5223 break;
5224 }
5225 /*
5226 * XXX: Set up to renegotiate again!
5227 */
5228 /* Can only be for a 1080... */
5588 break;
5589 default:
5590 isp_prt(isp, ISP_LOGWARN,
5591 "Transition to Unknown Mode 0x%x", mbox);
5592 break;
5593 }
5594 /*
5595 * XXX: Set up to renegotiate again!
5596 */
5597 /* Can only be for a 1080... */
5229 isp->isp_sendmarker |= (1 << bus);
5598 ISP_SET_SENDMARKER(isp, chan, 1);
5230 break;
5231
5599 break;
5600
5232 /*
5233 * We can use bus, which will always be zero for FC cards,
5234 * as a mailbox pattern accumulator to be checked below.
5235 */
5236 case ASYNC_RIO5:
5601 case ASYNC_RIO5:
5237 bus = 0x1ce; /* outgoing mailbox regs 1-3, 6-7 */
5602 pattern = 0xce; /* outgoing mailbox regs 1-3, 6-7 */
5238 break;
5239
5240 case ASYNC_RIO4:
5603 break;
5604
5605 case ASYNC_RIO4:
5241 bus = 0x14e; /* outgoing mailbox regs 1-3, 6 */
5606 pattern = 0x4e; /* outgoing mailbox regs 1-3, 6 */
5242 break;
5243
5244 case ASYNC_RIO3:
5607 break;
5608
5609 case ASYNC_RIO3:
5245 bus = 0x10e; /* outgoing mailbox regs 1-3 */
5610 pattern = 0x0e; /* outgoing mailbox regs 1-3 */
5246 break;
5247
5248 case ASYNC_RIO2:
5611 break;
5612
5613 case ASYNC_RIO2:
5249 bus = 0x106; /* outgoing mailbox regs 1-2 */
5614 pattern = 0x06; /* outgoing mailbox regs 1-2 */
5250 break;
5251
5252 case ASYNC_RIO1:
5253 case ASYNC_CMD_CMPLT:
5615 break;
5616
5617 case ASYNC_RIO1:
5618 case ASYNC_CMD_CMPLT:
5254 bus = 0x102; /* outgoing mailbox regs 1 */
5619 pattern = 0x02; /* outgoing mailbox regs 1 */
5255 break;
5256
5257 case ASYNC_RIO_RESP:
5258 return (rval);
5259
5260 case ASYNC_CTIO_DONE:
5261 {
5262#ifdef ISP_TARGET_MODE
5620 break;
5621
5622 case ASYNC_RIO_RESP:
5623 return (rval);
5624
5625 case ASYNC_CTIO_DONE:
5626 {
5627#ifdef ISP_TARGET_MODE
5263 int handle =
5264 (ISP_READ(isp, OUTMAILBOX2) << 16) |
5628 int handle;
5629 if (IS_SCSI(isp) || IS_24XX(isp)) {
5630 isp_prt(isp, ISP_LOGWARN,
5631 "bad ASYNC_CTIO_DONE for %s cards",
5632 IS_SCSI(isp)? "SCSI" : "24XX");
5633 break;
5634 }
5635 handle =
5636 (ISP_READ(isp, OUTMAILBOX2) << 16) |
5265 (ISP_READ(isp, OUTMAILBOX1));
5266 if (isp_target_async(isp, handle, mbox)) {
5267 rval = -1;
5268 } else {
5269 /* count it as a fast posting intr */
5270 isp->isp_fphccmplt++;
5271 }
5272#else
5637 (ISP_READ(isp, OUTMAILBOX1));
5638 if (isp_target_async(isp, handle, mbox)) {
5639 rval = -1;
5640 } else {
5641 /* count it as a fast posting intr */
5642 isp->isp_fphccmplt++;
5643 }
5644#else
5645 if (IS_SCSI(isp) || IS_24XX(isp)) {
5646 isp_prt(isp, ISP_LOGWARN,
5647 "bad ASYNC_CTIO_DONE for %s cards",
5648 IS_SCSI(isp)? "SCSI" : "24XX");
5649 break;
5650 }
5273 isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done");
5274 isp->isp_fphccmplt++; /* count it as a fast posting intr */
5275#endif
5276 break;
5277 }
5278 case ASYNC_LIP_ERROR:
5279 case ASYNC_LIP_F8:
5280 case ASYNC_LIP_OCCURRED:
5651 isp_prt(isp, ISP_LOGINFO, "Fast Posting CTIO done");
5652 isp->isp_fphccmplt++; /* count it as a fast posting intr */
5653#endif
5654 break;
5655 }
5656 case ASYNC_LIP_ERROR:
5657 case ASYNC_LIP_F8:
5658 case ASYNC_LIP_OCCURRED:
5281 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
5282 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
5283 isp->isp_sendmarker = 1;
5284 ISP_MARK_PORTDB(isp, 1);
5285 isp_async(isp, ISPASYNC_LIP, NULL);
5286#ifdef ISP_TARGET_MODE
5287 if (isp_target_async(isp, bus, mbox)) {
5288 rval = -1;
5659 case ASYNC_PTPMODE:
5660 if (IS_SCSI(isp)) {
5661 isp_prt(isp, ISP_LOGWARN,
5662 "bad LIP event for SCSI cards");
5663 break;
5289 }
5664 }
5290#endif
5291 /*
5665 /*
5292 * We've had problems with data corruption occuring on
5293 * commands that complete (with no apparent error) after
5294 * we receive a LIP. This has been observed mostly on
5295 * Local Loop topologies. To be safe, let's just mark
5296 * all active commands as dead.
5666 * These are broadcast events that have to be sent across
5667 * all active channels.
5297 */
5668 */
5298 if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT ||
5299 FCPARAM(isp)->isp_topo == TOPO_FL_PORT) {
5300 int i, j;
5301 for (i = j = 0; i < isp->isp_maxcmds; i++) {
5302 XS_T *xs;
5303 xs = isp->isp_xflist[i];
5304 if (xs != NULL) {
5669 for (chan = 0; chan < isp->isp_nchan; chan++) {
5670 fcparam *fcp = FCPARAM(isp, chan);
5671 int topo = fcp->isp_topo;
5672
5673 if (fcp->role == ISP_ROLE_NONE) {
5674 continue;
5675 }
5676
5677 fcp->isp_fwstate = FW_CONFIG_WAIT;
5678 fcp->isp_loopstate = LOOP_LIP_RCVD;
5679 ISP_SET_SENDMARKER(isp, chan, 1);
5680 ISP_MARK_PORTDB(isp, chan, 1);
5681 isp_async(isp, ISPASYNC_LIP, chan);
5682#ifdef ISP_TARGET_MODE
5683 if (isp_target_async(isp, chan, mbox)) {
5684 rval = -1;
5685 }
5686#endif
5687 /*
5688 * We've had problems with data corruption occuring on
5689 * commands that complete (with no apparent error) after
5690 * we receive a LIP. This has been observed mostly on
5691 * Local Loop topologies. To be safe, let's just mark
5692 * all active commands as dead.
5693 */
5694 if (topo == TOPO_NL_PORT || topo == TOPO_FL_PORT) {
5695 int i, j;
5696 for (i = j = 0; i < isp->isp_maxcmds; i++) {
5697 XS_T *xs;
5698 xs = isp->isp_xflist[i];
5699 if (xs == NULL) {
5700 continue;
5701 }
5702 if (XS_CHANNEL(xs) != chan) {
5703 continue;
5704 }
5305 j++;
5306 XS_SETERR(xs, HBA_BUSRESET);
5307 }
5705 j++;
5706 XS_SETERR(xs, HBA_BUSRESET);
5707 }
5708 if (j) {
5709 isp_prt(isp, ISP_LOGERR, lipd, chan, j);
5710 }
5308 }
5711 }
5309 if (j) {
5310 isp_prt(isp, ISP_LOGERR,
5311 "LIP destroyed %d active commands", j);
5312 }
5313 }
5314 break;
5315
5316 case ASYNC_LOOP_UP:
5712 }
5713 break;
5714
5715 case ASYNC_LOOP_UP:
5317 isp->isp_sendmarker = 1;
5318 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
5319 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
5320 ISP_MARK_PORTDB(isp, 1);
5321 isp_async(isp, ISPASYNC_LOOP_UP, NULL);
5322#ifdef ISP_TARGET_MODE
5323 if (isp_target_async(isp, bus, mbox)) {
5324 rval = -1;
5716 if (IS_SCSI(isp)) {
5717 isp_prt(isp, ISP_LOGWARN,
5718 "bad LOOP UP event for SCSI cards");
5719 break;
5325 }
5720 }
5721 /*
5722 * This is a broadcast event that has to be sent across
5723 * all active channels.
5724 */
5725 for (chan = 0; chan < isp->isp_nchan; chan++) {
5726 fcparam *fcp = FCPARAM(isp, chan);
5727
5728 if (fcp->role == ISP_ROLE_NONE) {
5729 continue;
5730 }
5731
5732 ISP_SET_SENDMARKER(isp, chan, 1);
5733
5734 fcp->isp_fwstate = FW_CONFIG_WAIT;
5735 fcp->isp_loopstate = LOOP_LIP_RCVD;
5736 ISP_MARK_PORTDB(isp, chan, 1);
5737 isp_async(isp, ISPASYNC_LOOP_UP, chan);
5738#ifdef ISP_TARGET_MODE
5739 if (isp_target_async(isp, chan, mbox)) {
5740 rval = -1;
5741 }
5326#endif
5742#endif
5743 }
5327 break;
5328
5329 case ASYNC_LOOP_DOWN:
5744 break;
5745
5746 case ASYNC_LOOP_DOWN:
5330 isp->isp_sendmarker = 1;
5331 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
5332 FCPARAM(isp)->isp_loopstate = LOOP_NIL;
5333 ISP_MARK_PORTDB(isp, 1);
5334 isp_async(isp, ISPASYNC_LOOP_DOWN, NULL);
5335#ifdef ISP_TARGET_MODE
5336 if (isp_target_async(isp, bus, mbox)) {
5337 rval = -1;
5747 if (IS_SCSI(isp)) {
5748 isp_prt(isp, ISP_LOGWARN,
5749 "bad LOOP DOWN event for SCSI cards");
5750 break;
5338 }
5751 }
5752 /*
5753 * This is a broadcast event that has to be sent across
5754 * all active channels.
5755 */
5756 for (chan = 0; chan < isp->isp_nchan; chan++) {
5757 fcparam *fcp = FCPARAM(isp, chan);
5758
5759 if (fcp->role == ISP_ROLE_NONE) {
5760 continue;
5761 }
5762
5763 ISP_SET_SENDMARKER(isp, chan, 1);
5764 fcp->isp_fwstate = FW_CONFIG_WAIT;
5765 fcp->isp_loopstate = LOOP_NIL;
5766 ISP_MARK_PORTDB(isp, chan, 1);
5767 isp_async(isp, ISPASYNC_LOOP_DOWN, chan);
5768#ifdef ISP_TARGET_MODE
5769 if (isp_target_async(isp, chan, mbox)) {
5770 rval = -1;
5771 }
5339#endif
5772#endif
5773 }
5340 break;
5341
5342 case ASYNC_LOOP_RESET:
5774 break;
5775
5776 case ASYNC_LOOP_RESET:
5343 isp->isp_sendmarker = 1;
5344 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
5345 FCPARAM(isp)->isp_loopstate = LOOP_NIL;
5346 ISP_MARK_PORTDB(isp, 1);
5347 isp_async(isp, ISPASYNC_LOOP_RESET, NULL);
5348#ifdef ISP_TARGET_MODE
5349 if (isp_target_async(isp, bus, mbox)) {
5350 rval = -1;
5777 if (IS_SCSI(isp)) {
5778 isp_prt(isp, ISP_LOGWARN,
5779 "bad LIP RESET event for SCSI cards");
5780 break;
5351 }
5781 }
5782 /*
5783 * This is a broadcast event that has to be sent across
5784 * all active channels.
5785 */
5786 for (chan = 0; chan < isp->isp_nchan; chan++) {
5787 fcparam *fcp = FCPARAM(isp, chan);
5788
5789 if (fcp->role == ISP_ROLE_NONE) {
5790 continue;
5791 }
5792
5793 ISP_SET_SENDMARKER(isp, chan, 1);
5794 fcp->isp_fwstate = FW_CONFIG_WAIT;
5795 fcp->isp_loopstate = LOOP_NIL;
5796 ISP_MARK_PORTDB(isp, chan, 1);
5797 isp_async(isp, ISPASYNC_LOOP_RESET, chan);
5798#ifdef ISP_TARGET_MODE
5799 if (isp_target_async(isp, chan, mbox)) {
5800 rval = -1;
5801 }
5352#endif
5802#endif
5803 }
5353 break;
5354
5355 case ASYNC_PDB_CHANGED:
5804 break;
5805
5806 case ASYNC_PDB_CHANGED:
5356 isp->isp_sendmarker = 1;
5357 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;
5358 ISP_MARK_PORTDB(isp, 1);
5359 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_PDB);
5360 break;
5807 {
5808 int nphdl, nlstate, reason;
5809 if (IS_SCSI(isp)) {
5810 isp_prt(isp, ISP_LOGWARN,
5811 "bad PDB CHANGED event for SCSI cards");
5812 break;
5813 }
5814 /*
5815 * We *should* get a channel out of the 24XX, but we don't seem
5816 * to get more than a PDB CHANGED on channel 0, so turn it into
5817 * a broadcast event.
5818 */
5819 if (IS_24XX(isp)) {
5820 nphdl = ISP_READ(isp, OUTMAILBOX1);
5821 nlstate = ISP_READ(isp, OUTMAILBOX2);
5822 reason = ISP_READ(isp, OUTMAILBOX3) >> 8;
5823 } else {
5824 nphdl = NIL_HANDLE;
5825 nlstate = reason = 0;
5826 }
5827 for (chan = 0; chan < isp->isp_nchan; chan++) {
5828 fcparam *fcp = FCPARAM(isp, chan);
5361
5829
5830 if (fcp->role == ISP_ROLE_NONE) {
5831 continue;
5832 }
5833 ISP_SET_SENDMARKER(isp, chan, 1);
5834 fcp->isp_loopstate = LOOP_PDB_RCVD;
5835 ISP_MARK_PORTDB(isp, chan, 1);
5836 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
5837 ISPASYNC_CHANGE_PDB, nphdl, nlstate, reason);
5838 }
5839 break;
5840 }
5362 case ASYNC_CHANGE_NOTIFY:
5841 case ASYNC_CHANGE_NOTIFY:
5363 if (FCPARAM(isp)->isp_topo == TOPO_F_PORT) {
5364 FCPARAM(isp)->isp_loopstate = LOOP_LSCAN_DONE;
5842 {
5843 int lochan, hichan;
5844
5845 if (IS_SCSI(isp)) {
5846 isp_prt(isp, ISP_LOGWARN,
5847 "bad CHANGE NOTIFY event for SCSI cards");
5848 break;
5849 }
5850 if (ISP_FW_NEWER_THAN(isp, 4, 0, 25) && ISP_CAP_MULTI_ID(isp)) {
5851 GET_24XX_BUS(isp, chan, "ASYNC_CHANGE_NOTIFY");
5852 lochan = chan;
5853 hichan = chan + 1;
5365 } else {
5854 } else {
5366 FCPARAM(isp)->isp_loopstate = LOOP_PDB_RCVD;
5855 lochan = 0;
5856 hichan = isp->isp_nchan;
5367 }
5857 }
5368 ISP_MARK_PORTDB(isp, 1);
5369 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_SNS);
5370 break;
5858 for (chan = lochan; chan < hichan; chan++) {
5859 fcparam *fcp = FCPARAM(isp, chan);
5371
5860
5372 case ASYNC_PTPMODE:
5373 ISP_MARK_PORTDB(isp, 1);
5374 isp->isp_sendmarker = 1;
5375 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
5376 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
5377 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER);
5378#ifdef ISP_TARGET_MODE
5379 if (isp_target_async(isp, bus, mbox)) {
5380 rval = -1;
5861 if (fcp->role == ISP_ROLE_NONE) {
5862 continue;
5863 }
5864
5865 if (fcp->isp_topo == TOPO_F_PORT) {
5866 fcp->isp_loopstate = LOOP_LSCAN_DONE;
5867 } else {
5868 fcp->isp_loopstate = LOOP_PDB_RCVD;
5869 }
5870 ISP_MARK_PORTDB(isp, chan, 1);
5871 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
5872 ISPASYNC_CHANGE_SNS);
5381 }
5873 }
5382#endif
5383 isp_prt(isp, ISP_LOGINFO, "Point-to-Point mode");
5384 break;
5874 break;
5875 }
5385
5386 case ASYNC_CONNMODE:
5876
5877 case ASYNC_CONNMODE:
5878 /*
5879 * This only applies to 2100 amd 2200 cards
5880 */
5881 if (!IS_2200(isp) && !IS_2100(isp)) {
5882 isp_prt(isp, ISP_LOGWARN,
5883 "bad card for ASYNC_CONNMODE event");
5884 break;
5885 }
5886 chan = 0;
5387 mbox = ISP_READ(isp, OUTMAILBOX1);
5887 mbox = ISP_READ(isp, OUTMAILBOX1);
5388 ISP_MARK_PORTDB(isp, 1);
5888 ISP_MARK_PORTDB(isp, chan, 1);
5389 switch (mbox) {
5390 case ISP_CONN_LOOP:
5391 isp_prt(isp, ISP_LOGINFO,
5392 "Point-to-Point -> Loop mode");
5393 break;
5394 case ISP_CONN_PTP:
5395 isp_prt(isp, ISP_LOGINFO,
5396 "Loop -> Point-to-Point mode");
5397 break;
5398 case ISP_CONN_BADLIP:
5399 isp_prt(isp, ISP_LOGWARN,
5400 "Point-to-Point -> Loop mode (BAD LIP)");
5401 break;
5402 case ISP_CONN_FATAL:
5889 switch (mbox) {
5890 case ISP_CONN_LOOP:
5891 isp_prt(isp, ISP_LOGINFO,
5892 "Point-to-Point -> Loop mode");
5893 break;
5894 case ISP_CONN_PTP:
5895 isp_prt(isp, ISP_LOGINFO,
5896 "Loop -> Point-to-Point mode");
5897 break;
5898 case ISP_CONN_BADLIP:
5899 isp_prt(isp, ISP_LOGWARN,
5900 "Point-to-Point -> Loop mode (BAD LIP)");
5901 break;
5902 case ISP_CONN_FATAL:
5903 isp->isp_dead = 1;
5904 isp->isp_state = ISP_CRASHED;
5403 isp_prt(isp, ISP_LOGERR, "FATAL CONNECTION ERROR");
5905 isp_prt(isp, ISP_LOGERR, "FATAL CONNECTION ERROR");
5404 isp_async(isp, ISPASYNC_FW_CRASH, NULL);
5906 isp_async(isp, ISPASYNC_FW_CRASH);
5405 return (-1);
5406 case ISP_CONN_LOOPBACK:
5407 isp_prt(isp, ISP_LOGWARN,
5408 "Looped Back in Point-to-Point mode");
5409 break;
5410 default:
5411 isp_prt(isp, ISP_LOGWARN,
5412 "Unknown connection mode (0x%x)", mbox);
5413 break;
5414 }
5907 return (-1);
5908 case ISP_CONN_LOOPBACK:
5909 isp_prt(isp, ISP_LOGWARN,
5910 "Looped Back in Point-to-Point mode");
5911 break;
5912 default:
5913 isp_prt(isp, ISP_LOGWARN,
5914 "Unknown connection mode (0x%x)", mbox);
5915 break;
5916 }
5415 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, ISPASYNC_CHANGE_OTHER);
5416 isp->isp_sendmarker = 1;
5417 FCPARAM(isp)->isp_fwstate = FW_CONFIG_WAIT;
5418 FCPARAM(isp)->isp_loopstate = LOOP_LIP_RCVD;
5917 isp_async(isp, ISPASYNC_CHANGE_NOTIFY, chan,
5918 ISPASYNC_CHANGE_OTHER);
5919 FCPARAM(isp, chan)->sendmarker = 1;
5920 FCPARAM(isp, chan)->isp_fwstate = FW_CONFIG_WAIT;
5921 FCPARAM(isp, chan)->isp_loopstate = LOOP_LIP_RCVD;
5419 break;
5420
5922 break;
5923
5924 case ASYNC_RCV_ERR:
5925 if (IS_24XX(isp)) {
5926 isp_prt(isp, ISP_LOGWARN, "Receive Error");
5927 } else {
5928 isp_prt(isp, ISP_LOGWARN,
5929 "Unknown Async Code 0x%x", mbox);
5930 }
5931 break;
5421 case ASYNC_RJT_SENT: /* same as ASYNC_QFULL_SENT */
5422 if (IS_24XX(isp)) {
5423 isp_prt(isp, ISP_LOGTDEBUG0, "LS_RJT sent");
5424 break;
5425 } else if (IS_2200(isp)) {
5426 isp_prt(isp, ISP_LOGTDEBUG0, "QFULL sent");
5427 break;
5428 }
5429 /* FALLTHROUGH */
5430 default:
5431 isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox);
5432 break;
5433 }
5434
5932 case ASYNC_RJT_SENT: /* same as ASYNC_QFULL_SENT */
5933 if (IS_24XX(isp)) {
5934 isp_prt(isp, ISP_LOGTDEBUG0, "LS_RJT sent");
5935 break;
5936 } else if (IS_2200(isp)) {
5937 isp_prt(isp, ISP_LOGTDEBUG0, "QFULL sent");
5938 break;
5939 }
5940 /* FALLTHROUGH */
5941 default:
5942 isp_prt(isp, ISP_LOGWARN, "Unknown Async Code 0x%x", mbox);
5943 break;
5944 }
5945
5435 if (bus & 0x100) {
5946 if (pattern) {
5436 int i, nh;
5437 uint16_t handles[16];
5438
5439 for (nh = 0, i = 1; i < MAX_MAILBOX(isp); i++) {
5947 int i, nh;
5948 uint16_t handles[16];
5949
5950 for (nh = 0, i = 1; i < MAX_MAILBOX(isp); i++) {
5440 if ((bus & (1 << i)) == 0) {
5951 if ((pattern & (1 << i)) == 0) {
5441 continue;
5442 }
5443 handles[nh++] = ISP_READ(isp, MBOX_OFF(i));
5444 }
5445 for (i = 0; i < nh; i++) {
5446 isp_fastpost_complete(isp, handles[i]);
5447 isp_prt(isp, ISP_LOGDEBUG3,
5448 "fast post completion of %u", handles[i]);

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

5488 case RQSTYPE_ABTS_RSP:
5489 isp->isp_rsltccmplt++; /* count as a response completion */
5490#ifdef ISP_TARGET_MODE
5491 if (isp_target_notify(isp, (ispstatusreq_t *) hp, optrp)) {
5492 return (1);
5493 }
5494#endif
5495 /* FALLTHROUGH */
5952 continue;
5953 }
5954 handles[nh++] = ISP_READ(isp, MBOX_OFF(i));
5955 }
5956 for (i = 0; i < nh; i++) {
5957 isp_fastpost_complete(isp, handles[i]);
5958 isp_prt(isp, ISP_LOGDEBUG3,
5959 "fast post completion of %u", handles[i]);

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

5999 case RQSTYPE_ABTS_RSP:
6000 isp->isp_rsltccmplt++; /* count as a response completion */
6001#ifdef ISP_TARGET_MODE
6002 if (isp_target_notify(isp, (ispstatusreq_t *) hp, optrp)) {
6003 return (1);
6004 }
6005#endif
6006 /* FALLTHROUGH */
6007 case RQSTYPE_RPT_ID_ACQ:
6008 if (IS_24XX(isp)) {
6009 isp_ridacq_t rid;
6010 isp_get_ridacq(isp, (isp_ridacq_t *)hp, &rid);
6011 if (rid.ridacq_format == 0) {
6012 }
6013 return (1);
6014 }
6015 /* FALLTHROUGH */
5496 case RQSTYPE_REQUEST:
5497 default:
6016 case RQSTYPE_REQUEST:
6017 default:
5498 USEC_DELAY(100);
6018 ISP_DELAY(100);
5499 if (type != isp_get_response_type(isp, hp)) {
5500 /*
5501 * This is questionable- we're just papering over
5502 * something we've seen on SMP linux in target
5503 * mode- we don't really know what's happening
5504 * here that causes us to think we've gotten
5505 * an entry, but that either the entry isn't
5506 * filled out yet or our CPU read data is stale.
5507 */
5508 isp_prt(isp, ISP_LOGINFO,
5509 "unstable type in response queue");
5510 return (-1);
5511 }
5512 isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x",
5513 isp_get_response_type(isp, hp));
6019 if (type != isp_get_response_type(isp, hp)) {
6020 /*
6021 * This is questionable- we're just papering over
6022 * something we've seen on SMP linux in target
6023 * mode- we don't really know what's happening
6024 * here that causes us to think we've gotten
6025 * an entry, but that either the entry isn't
6026 * filled out yet or our CPU read data is stale.
6027 */
6028 isp_prt(isp, ISP_LOGINFO,
6029 "unstable type in response queue");
6030 return (-1);
6031 }
6032 isp_prt(isp, ISP_LOGWARN, "Unhandled Response Type 0x%x",
6033 isp_get_response_type(isp, hp));
5514 if (isp_async(isp, ISPASYNC_UNHANDLED_RESPONSE, hp)) {
5515 return (1);
5516 }
5517 return (0);
5518 }
5519}
5520
5521static void
5522isp_parse_status(ispsoftc_t *isp, ispstatusreq_t *sp, XS_T *xs, long *rp)
5523{
5524 switch (sp->req_completion_status & 0xff) {

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

5549 isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d",
5550 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5551 *rp = XS_XFRLEN(xs);
5552 break;
5553
5554 case RQCS_TRANSPORT_ERROR:
5555 {
5556 char buf[172];
6034 return (0);
6035 }
6036}
6037
6038static void
6039isp_parse_status(ispsoftc_t *isp, ispstatusreq_t *sp, XS_T *xs, long *rp)
6040{
6041 switch (sp->req_completion_status & 0xff) {

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

6066 isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d",
6067 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6068 *rp = XS_XFRLEN(xs);
6069 break;
6070
6071 case RQCS_TRANSPORT_ERROR:
6072 {
6073 char buf[172];
5557 SNPRINTF(buf, sizeof (buf), "states=>");
6074 ISP_SNPRINTF(buf, sizeof (buf), "states=>");
5558 if (sp->req_state_flags & RQSF_GOT_BUS) {
6075 if (sp->req_state_flags & RQSF_GOT_BUS) {
5559 SNPRINTF(buf, sizeof (buf), "%s GOT_BUS", buf);
6076 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_BUS", buf);
5560 }
5561 if (sp->req_state_flags & RQSF_GOT_TARGET) {
6077 }
6078 if (sp->req_state_flags & RQSF_GOT_TARGET) {
5562 SNPRINTF(buf, sizeof (buf), "%s GOT_TGT", buf);
6079 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_TGT", buf);
5563 }
5564 if (sp->req_state_flags & RQSF_SENT_CDB) {
6080 }
6081 if (sp->req_state_flags & RQSF_SENT_CDB) {
5565 SNPRINTF(buf, sizeof (buf), "%s SENT_CDB", buf);
6082 ISP_SNPRINTF(buf, sizeof (buf), "%s SENT_CDB", buf);
5566 }
5567 if (sp->req_state_flags & RQSF_XFRD_DATA) {
6083 }
6084 if (sp->req_state_flags & RQSF_XFRD_DATA) {
5568 SNPRINTF(buf, sizeof (buf), "%s XFRD_DATA", buf);
6085 ISP_SNPRINTF(buf, sizeof (buf), "%s XFRD_DATA", buf);
5569 }
5570 if (sp->req_state_flags & RQSF_GOT_STATUS) {
6086 }
6087 if (sp->req_state_flags & RQSF_GOT_STATUS) {
5571 SNPRINTF(buf, sizeof (buf), "%s GOT_STS", buf);
6088 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_STS", buf);
5572 }
5573 if (sp->req_state_flags & RQSF_GOT_SENSE) {
6089 }
6090 if (sp->req_state_flags & RQSF_GOT_SENSE) {
5574 SNPRINTF(buf, sizeof (buf), "%s GOT_SNS", buf);
6091 ISP_SNPRINTF(buf, sizeof (buf), "%s GOT_SNS", buf);
5575 }
5576 if (sp->req_state_flags & RQSF_XFER_COMPLETE) {
6092 }
6093 if (sp->req_state_flags & RQSF_XFER_COMPLETE) {
5577 SNPRINTF(buf, sizeof (buf), "%s XFR_CMPLT", buf);
6094 ISP_SNPRINTF(buf, sizeof (buf), "%s XFR_CMPLT", buf);
5578 }
6095 }
5579 SNPRINTF(buf, sizeof (buf), "%s\nstatus=>", buf);
6096 ISP_SNPRINTF(buf, sizeof (buf), "%s\nstatus=>", buf);
5580 if (sp->req_status_flags & RQSTF_DISCONNECT) {
6097 if (sp->req_status_flags & RQSTF_DISCONNECT) {
5581 SNPRINTF(buf, sizeof (buf), "%s Disconnect", buf);
6098 ISP_SNPRINTF(buf, sizeof (buf), "%s Disconnect", buf);
5582 }
5583 if (sp->req_status_flags & RQSTF_SYNCHRONOUS) {
6099 }
6100 if (sp->req_status_flags & RQSTF_SYNCHRONOUS) {
5584 SNPRINTF(buf, sizeof (buf), "%s Sync_xfr", buf);
6101 ISP_SNPRINTF(buf, sizeof (buf), "%s Sync_xfr", buf);
5585 }
5586 if (sp->req_status_flags & RQSTF_PARITY_ERROR) {
6102 }
6103 if (sp->req_status_flags & RQSTF_PARITY_ERROR) {
5587 SNPRINTF(buf, sizeof (buf), "%s Parity", buf);
6104 ISP_SNPRINTF(buf, sizeof (buf), "%s Parity", buf);
5588 }
5589 if (sp->req_status_flags & RQSTF_BUS_RESET) {
6105 }
6106 if (sp->req_status_flags & RQSTF_BUS_RESET) {
5590 SNPRINTF(buf, sizeof (buf), "%s Bus_Reset", buf);
6107 ISP_SNPRINTF(buf, sizeof (buf), "%s Bus_Reset", buf);
5591 }
5592 if (sp->req_status_flags & RQSTF_DEVICE_RESET) {
6108 }
6109 if (sp->req_status_flags & RQSTF_DEVICE_RESET) {
5593 SNPRINTF(buf, sizeof (buf), "%s Device_Reset", buf);
6110 ISP_SNPRINTF(buf, sizeof (buf), "%s Device_Reset", buf);
5594 }
5595 if (sp->req_status_flags & RQSTF_ABORTED) {
6111 }
6112 if (sp->req_status_flags & RQSTF_ABORTED) {
5596 SNPRINTF(buf, sizeof (buf), "%s Aborted", buf);
6113 ISP_SNPRINTF(buf, sizeof (buf), "%s Aborted", buf);
5597 }
5598 if (sp->req_status_flags & RQSTF_TIMEOUT) {
6114 }
6115 if (sp->req_status_flags & RQSTF_TIMEOUT) {
5599 SNPRINTF(buf, sizeof (buf), "%s Timeout", buf);
6116 ISP_SNPRINTF(buf, sizeof (buf), "%s Timeout", buf);
5600 }
5601 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
6117 }
6118 if (sp->req_status_flags & RQSTF_NEGOTIATION) {
5602 SNPRINTF(buf, sizeof (buf), "%s Negotiation", buf);
6119 ISP_SNPRINTF(buf, sizeof (buf), "%s Negotiation", buf);
5603 }
5604 isp_prt(isp, ISP_LOGERR, "%s", buf);
5605 isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d:\n%s",
5606 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), buf);
5607 *rp = XS_XFRLEN(xs);
5608 break;
5609 }
5610 case RQCS_RESET_OCCURRED:
6120 }
6121 isp_prt(isp, ISP_LOGERR, "%s", buf);
6122 isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d:\n%s",
6123 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs), buf);
6124 *rp = XS_XFRLEN(xs);
6125 break;
6126 }
6127 case RQCS_RESET_OCCURRED:
6128 {
6129 int chan;
5611 isp_prt(isp, ISP_LOGWARN,
5612 "bus reset destroyed command for %d.%d.%d",
5613 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6130 isp_prt(isp, ISP_LOGWARN,
6131 "bus reset destroyed command for %d.%d.%d",
6132 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5614 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
6133 for (chan = 0; chan < isp->isp_nchan; chan++) {
6134 FCPARAM(isp, chan)->sendmarker = 1;
6135 }
5615 if (XS_NOERR(xs)) {
5616 XS_SETERR(xs, HBA_BUSRESET);
5617 }
5618 *rp = XS_XFRLEN(xs);
5619 return;
6136 if (XS_NOERR(xs)) {
6137 XS_SETERR(xs, HBA_BUSRESET);
6138 }
6139 *rp = XS_XFRLEN(xs);
6140 return;
5620
6141 }
5621 case RQCS_ABORTED:
5622 isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d",
5623 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6142 case RQCS_ABORTED:
6143 isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d",
6144 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5624 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
6145 ISP_SET_SENDMARKER(isp, XS_CHANNEL(xs), 1);
5625 if (XS_NOERR(xs)) {
5626 XS_SETERR(xs, HBA_ABORTED);
5627 }
5628 return;
5629
5630 case RQCS_TIMEOUT:
5631 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
5632 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5633 /*
5634 * XXX: Check to see if we logged out of the device.
5635 */
5636 if (XS_NOERR(xs)) {
5637 XS_SETERR(xs, HBA_CMDTIMEOUT);
5638 }
5639 return;
5640
5641 case RQCS_DATA_OVERRUN:
6146 if (XS_NOERR(xs)) {
6147 XS_SETERR(xs, HBA_ABORTED);
6148 }
6149 return;
6150
6151 case RQCS_TIMEOUT:
6152 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
6153 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6154 /*
6155 * XXX: Check to see if we logged out of the device.
6156 */
6157 if (XS_NOERR(xs)) {
6158 XS_SETERR(xs, HBA_CMDTIMEOUT);
6159 }
6160 return;
6161
6162 case RQCS_DATA_OVERRUN:
5642 XS_RESID(xs) = sp->req_resid;
5643 isp_prt(isp, ISP_LOGERR, "data overrun for command on %d.%d.%d",
5644 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6163 XS_SET_RESID(xs, sp->req_resid);
6164 isp_prt(isp, ISP_LOGERR, "data overrun (%ld) for command on %d.%d.%d",
6165 (long) XS_GET_RESID(xs), XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5645 if (XS_NOERR(xs)) {
5646 XS_SETERR(xs, HBA_DATAOVR);
5647 }
5648 return;
5649
5650 case RQCS_COMMAND_OVERRUN:
5651 isp_prt(isp, ISP_LOGERR,
5652 "command overrun for command on %d.%d.%d",

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

5728 XS_LUN(xs), XS_XFRLEN(xs), sp->req_resid,
5729 (ru_marked)? "marked" : "not marked");
5730 if (XS_NOERR(xs)) {
5731 XS_SETERR(xs, HBA_BOTCH);
5732 }
5733 return;
5734 }
5735 }
6166 if (XS_NOERR(xs)) {
6167 XS_SETERR(xs, HBA_DATAOVR);
6168 }
6169 return;
6170
6171 case RQCS_COMMAND_OVERRUN:
6172 isp_prt(isp, ISP_LOGERR,
6173 "command overrun for command on %d.%d.%d",

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

6249 XS_LUN(xs), XS_XFRLEN(xs), sp->req_resid,
6250 (ru_marked)? "marked" : "not marked");
6251 if (XS_NOERR(xs)) {
6252 XS_SETERR(xs, HBA_BOTCH);
6253 }
6254 return;
6255 }
6256 }
5736 XS_RESID(xs) = sp->req_resid;
6257 XS_SET_RESID(xs, sp->req_resid);
5737 if (XS_NOERR(xs)) {
5738 XS_SETERR(xs, HBA_NOERROR);
5739 }
5740 return;
5741 }
5742
5743 case RQCS_XACT_ERR1:
5744 isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs),

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

5799 }
5800 return;
5801
5802 case RQCS_WIDE_FAILED:
5803 isp_prt(isp, ISP_LOGERR,
5804 "Wide Negotiation failed for %d.%d.%d",
5805 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
5806 if (IS_SCSI(isp)) {
6258 if (XS_NOERR(xs)) {
6259 XS_SETERR(xs, HBA_NOERROR);
6260 }
6261 return;
6262 }
6263
6264 case RQCS_XACT_ERR1:
6265 isp_prt(isp, ISP_LOGERR, xact1, XS_CHANNEL(xs),

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

6320 }
6321 return;
6322
6323 case RQCS_WIDE_FAILED:
6324 isp_prt(isp, ISP_LOGERR,
6325 "Wide Negotiation failed for %d.%d.%d",
6326 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
6327 if (IS_SCSI(isp)) {
5807 sdparam *sdp = isp->isp_param;
5808 sdp += XS_CHANNEL(xs);
6328 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
5809 sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_WIDE;
5810 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
6329 sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_WIDE;
6330 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
5811 isp->isp_update |= (1 << XS_CHANNEL(xs));
6331 sdp->update = 1;
5812 }
5813 if (XS_NOERR(xs)) {
5814 XS_SETERR(xs, HBA_NOERROR);
5815 }
5816 return;
5817
5818 case RQCS_SYNCXFER_FAILED:
5819 isp_prt(isp, ISP_LOGERR,
5820 "SDTR Message failed for target %d.%d.%d",
5821 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
5822 if (IS_SCSI(isp)) {
6332 }
6333 if (XS_NOERR(xs)) {
6334 XS_SETERR(xs, HBA_NOERROR);
6335 }
6336 return;
6337
6338 case RQCS_SYNCXFER_FAILED:
6339 isp_prt(isp, ISP_LOGERR,
6340 "SDTR Message failed for target %d.%d.%d",
6341 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
6342 if (IS_SCSI(isp)) {
5823 sdparam *sdp = isp->isp_param;
6343 sdparam *sdp = SDPARAM(isp, XS_CHANNEL(xs));
5824 sdp += XS_CHANNEL(xs);
5825 sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_SYNC;
5826 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
6344 sdp += XS_CHANNEL(xs);
6345 sdp->isp_devparam[XS_TGT(xs)].goal_flags &= ~DPARM_SYNC;
6346 sdp->isp_devparam[XS_TGT(xs)].dev_update = 1;
5827 isp->isp_update |= (1 << XS_CHANNEL(xs));
6347 sdp->update = 1;
5828 }
5829 break;
5830
5831 case RQCS_LVD_BUSERR:
5832 isp_prt(isp, ISP_LOGERR,
5833 "Bad LVD condition while talking to %d.%d.%d",
5834 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
5835 break;

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

5855 isp_prt(isp, ISP_LOGINFO, "port %s for target %d",
5856 reason, XS_TGT(xs));
5857
5858 /*
5859 * If we're on a local loop, force a LIP (which is overkill)
5860 * to force a re-login of this unit. If we're on fabric,
5861 * then we'll have to log in again as a matter of course.
5862 */
6348 }
6349 break;
6350
6351 case RQCS_LVD_BUSERR:
6352 isp_prt(isp, ISP_LOGERR,
6353 "Bad LVD condition while talking to %d.%d.%d",
6354 XS_TGT(xs), XS_LUN(xs), XS_CHANNEL(xs));
6355 break;

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

6375 isp_prt(isp, ISP_LOGINFO, "port %s for target %d",
6376 reason, XS_TGT(xs));
6377
6378 /*
6379 * If we're on a local loop, force a LIP (which is overkill)
6380 * to force a re-login of this unit. If we're on fabric,
6381 * then we'll have to log in again as a matter of course.
6382 */
5863 if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT ||
5864 FCPARAM(isp)->isp_topo == TOPO_FL_PORT) {
6383 if (FCPARAM(isp, 0)->isp_topo == TOPO_NL_PORT ||
6384 FCPARAM(isp, 0)->isp_topo == TOPO_FL_PORT) {
5865 mbreg_t mbs;
6385 mbreg_t mbs;
5866 MEMZERO(&mbs, sizeof (mbs));
5867 mbs.param[0] = MBOX_INIT_LIP;
5868 if (FCPARAM(isp)->isp_2klogin) {
6386 MBSINIT(&mbs, MBOX_INIT_LIP, MBLOGALL, 0);
6387 if (ISP_CAP_2KLOGIN(isp)) {
5869 mbs.ibits = (1 << 10);
5870 }
6388 mbs.ibits = (1 << 10);
6389 }
5871 mbs.logval = MBLOGALL;
5872 isp_mboxcmd_qnw(isp, &mbs, 1);
5873 }
5874 if (XS_NOERR(xs)) {
5875 XS_SETERR(xs, HBA_SELTIMEOUT);
5876 }
5877 return;
5878 }
5879 case RQCS_PORT_CHANGED:

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

5902 }
5903}
5904
5905static void
5906isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp,
5907 XS_T *xs, long *rp)
5908{
5909 int ru_marked, sv_marked;
6390 isp_mboxcmd_qnw(isp, &mbs, 1);
6391 }
6392 if (XS_NOERR(xs)) {
6393 XS_SETERR(xs, HBA_SELTIMEOUT);
6394 }
6395 return;
6396 }
6397 case RQCS_PORT_CHANGED:

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

6420 }
6421}
6422
6423static void
6424isp_parse_status_24xx(ispsoftc_t *isp, isp24xx_statusreq_t *sp,
6425 XS_T *xs, long *rp)
6426{
6427 int ru_marked, sv_marked;
6428 int chan = XS_CHANNEL(xs);
6429
5910 switch (sp->req_completion_status) {
5911 case RQCS_COMPLETE:
5912 if (XS_NOERR(xs)) {
5913 XS_SETERR(xs, HBA_NOERROR);
5914 }
5915 return;
5916
5917 case RQCS_DMA_ERROR:
5918 isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d",
5919 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5920 break;
5921
5922 case RQCS_TRANSPORT_ERROR:
5923 isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d",
5924 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5925 break;
5926
5927 case RQCS_RESET_OCCURRED:
5928 isp_prt(isp, ISP_LOGWARN,
6430 switch (sp->req_completion_status) {
6431 case RQCS_COMPLETE:
6432 if (XS_NOERR(xs)) {
6433 XS_SETERR(xs, HBA_NOERROR);
6434 }
6435 return;
6436
6437 case RQCS_DMA_ERROR:
6438 isp_prt(isp, ISP_LOGERR, "DMA error for command on %d.%d.%d",
6439 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6440 break;
6441
6442 case RQCS_TRANSPORT_ERROR:
6443 isp_prt(isp, ISP_LOGERR, "transport error for %d.%d.%d",
6444 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6445 break;
6446
6447 case RQCS_RESET_OCCURRED:
6448 isp_prt(isp, ISP_LOGWARN,
5929 "bus reset destroyed command for %d.%d.%d",
6449 "reset destroyed command for %d.%d.%d",
5930 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6450 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5931 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
6451 FCPARAM(isp, chan)->sendmarker = 1;
5932 if (XS_NOERR(xs)) {
5933 XS_SETERR(xs, HBA_BUSRESET);
5934 }
5935 return;
5936
5937 case RQCS_ABORTED:
5938 isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d",
5939 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6452 if (XS_NOERR(xs)) {
6453 XS_SETERR(xs, HBA_BUSRESET);
6454 }
6455 return;
6456
6457 case RQCS_ABORTED:
6458 isp_prt(isp, ISP_LOGERR, "command aborted for %d.%d.%d",
6459 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5940 isp->isp_sendmarker |= (1 << XS_CHANNEL(xs));
6460 FCPARAM(isp, chan)->sendmarker = 1;
5941 if (XS_NOERR(xs)) {
5942 XS_SETERR(xs, HBA_ABORTED);
5943 }
5944 return;
5945
5946 case RQCS_TIMEOUT:
5947 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
5948 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5949 if (XS_NOERR(xs)) {
5950 XS_SETERR(xs, HBA_CMDTIMEOUT);
5951 }
5952 return;
5953
5954 case RQCS_DATA_OVERRUN:
6461 if (XS_NOERR(xs)) {
6462 XS_SETERR(xs, HBA_ABORTED);
6463 }
6464 return;
6465
6466 case RQCS_TIMEOUT:
6467 isp_prt(isp, ISP_LOGWARN, "command timed out for %d.%d.%d",
6468 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6469 if (XS_NOERR(xs)) {
6470 XS_SETERR(xs, HBA_CMDTIMEOUT);
6471 }
6472 return;
6473
6474 case RQCS_DATA_OVERRUN:
5955 XS_RESID(xs) = sp->req_resid;
6475 XS_SET_RESID(xs, sp->req_resid);
5956 isp_prt(isp, ISP_LOGERR,
5957 "data overrun for command on %d.%d.%d",
5958 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
5959 if (XS_NOERR(xs)) {
5960 XS_SETERR(xs, HBA_DATAOVR);
5961 }
5962 return;
5963
5964 case RQCS_24XX_DRE: /* data reassembly error */
6476 isp_prt(isp, ISP_LOGERR,
6477 "data overrun for command on %d.%d.%d",
6478 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs));
6479 if (XS_NOERR(xs)) {
6480 XS_SETERR(xs, HBA_DATAOVR);
6481 }
6482 return;
6483
6484 case RQCS_24XX_DRE: /* data reassembly error */
5965 isp_prt(isp, ISP_LOGERR, "data reassembly error for target %d",
5966 XS_TGT(xs));
6485 isp_prt(isp, ISP_LOGERR,
6486 "Chan %d data reassembly error for target %d",
6487 chan, XS_TGT(xs));
5967 if (XS_NOERR(xs)) {
5968 XS_SETERR(xs, HBA_ABORTED);
5969 }
5970 *rp = XS_XFRLEN(xs);
5971 return;
5972
5973 case RQCS_24XX_TABORT: /* aborted by target */
6488 if (XS_NOERR(xs)) {
6489 XS_SETERR(xs, HBA_ABORTED);
6490 }
6491 *rp = XS_XFRLEN(xs);
6492 return;
6493
6494 case RQCS_24XX_TABORT: /* aborted by target */
5974 isp_prt(isp, ISP_LOGERR, "target %d sent ABTS",
5975 XS_TGT(xs));
6495 isp_prt(isp, ISP_LOGERR, "Chan %d target %d sent ABTS",
6496 chan, XS_TGT(xs));
5976 if (XS_NOERR(xs)) {
5977 XS_SETERR(xs, HBA_ABORTED);
5978 }
5979 return;
5980
5981 case RQCS_DATA_UNDERRUN:
5982 ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
5983 /*
6497 if (XS_NOERR(xs)) {
6498 XS_SETERR(xs, HBA_ABORTED);
6499 }
6500 return;
6501
6502 case RQCS_DATA_UNDERRUN:
6503 ru_marked = (sp->req_scsi_status & RQCS_RU) != 0;
6504 /*
5984 * We can get an underrun w/o things being marked
6505 * We can get an underrun w/o things being marked
5985 * if we got a non-zero status.
5986 */
5987 sv_marked = (sp->req_scsi_status & (RQCS_SV|RQCS_RV)) != 0;
5988 if ((ru_marked == 0 && sv_marked == 0) ||
5989 (sp->req_resid > XS_XFRLEN(xs))) {
5990 isp_prt(isp, ISP_LOGWARN, bun, XS_TGT(xs),
5991 XS_LUN(xs), XS_XFRLEN(xs), sp->req_resid,
5992 (ru_marked)? "marked" : "not marked");
5993 if (XS_NOERR(xs)) {
5994 XS_SETERR(xs, HBA_BOTCH);
5995 }
5996 return;
5997 }
6506 * if we got a non-zero status.
6507 */
6508 sv_marked = (sp->req_scsi_status & (RQCS_SV|RQCS_RV)) != 0;
6509 if ((ru_marked == 0 && sv_marked == 0) ||
6510 (sp->req_resid > XS_XFRLEN(xs))) {
6511 isp_prt(isp, ISP_LOGWARN, bun, XS_TGT(xs),
6512 XS_LUN(xs), XS_XFRLEN(xs), sp->req_resid,
6513 (ru_marked)? "marked" : "not marked");
6514 if (XS_NOERR(xs)) {
6515 XS_SETERR(xs, HBA_BOTCH);
6516 }
6517 return;
6518 }
5998 XS_RESID(xs) = sp->req_resid;
6519 XS_SET_RESID(xs, sp->req_resid);
5999 isp_prt(isp, ISP_LOGDEBUG0,
6000 "%d.%d.%d data underrun (%d) for command 0x%x",
6001 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
6002 sp->req_resid, XS_CDBP(xs)[0] & 0xff);
6003 if (XS_NOERR(xs)) {
6004 XS_SETERR(xs, HBA_NOERROR);
6005 }
6006 return;

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

6018 * It was there (maybe)- treat as a selection timeout.
6019 */
6020 if (sts == RQCS_PORT_UNAVAILABLE) {
6021 reason = "unavailable";
6022 } else {
6023 reason = "logout";
6024 }
6025
6520 isp_prt(isp, ISP_LOGDEBUG0,
6521 "%d.%d.%d data underrun (%d) for command 0x%x",
6522 XS_CHANNEL(xs), XS_TGT(xs), XS_LUN(xs),
6523 sp->req_resid, XS_CDBP(xs)[0] & 0xff);
6524 if (XS_NOERR(xs)) {
6525 XS_SETERR(xs, HBA_NOERROR);
6526 }
6527 return;

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

6539 * It was there (maybe)- treat as a selection timeout.
6540 */
6541 if (sts == RQCS_PORT_UNAVAILABLE) {
6542 reason = "unavailable";
6543 } else {
6544 reason = "logout";
6545 }
6546
6026 isp_prt(isp, ISP_LOGINFO, "port %s for target %d",
6027 reason, XS_TGT(xs));
6547 isp_prt(isp, ISP_LOGINFO, "Chan %d port %s for target %d",
6548 chan, reason, XS_TGT(xs));
6028
6029 /*
6549
6550 /*
6030 * If we're on a local loop, force a LIP (which is overkill)
6031 * to force a re-login of this unit. If we're on fabric,
6032 * then we'll have to log in again as a matter of course.
6551 * There is no MBOX_INIT_LIP for the 24XX.
6033 */
6552 */
6034 if (FCPARAM(isp)->isp_topo == TOPO_NL_PORT ||
6035 FCPARAM(isp)->isp_topo == TOPO_FL_PORT) {
6036 mbreg_t mbs;
6037 MEMZERO(&mbs, sizeof (mbs));
6038 mbs.param[0] = MBOX_INIT_LIP;
6039 if (FCPARAM(isp)->isp_2klogin) {
6040 mbs.ibits = (1 << 10);
6041 }
6042 mbs.logval = MBLOGALL;
6043 isp_mboxcmd_qnw(isp, &mbs, 1);
6044 }
6045 if (XS_NOERR(xs)) {
6046 XS_SETERR(xs, HBA_SELTIMEOUT);
6047 }
6048 return;
6049 }
6050 case RQCS_PORT_CHANGED:
6051 isp_prt(isp, ISP_LOGWARN,
6553 if (XS_NOERR(xs)) {
6554 XS_SETERR(xs, HBA_SELTIMEOUT);
6555 }
6556 return;
6557 }
6558 case RQCS_PORT_CHANGED:
6559 isp_prt(isp, ISP_LOGWARN,
6052 "port changed for target %d", XS_TGT(xs));
6560 "port changed for target %d chan %d", XS_TGT(xs), chan);
6053 if (XS_NOERR(xs)) {
6054 XS_SETERR(xs, HBA_SELTIMEOUT);
6055 }
6056 return;
6057
6058
6059 case RQCS_24XX_ENOMEM: /* f/w resource unavailable */
6060 isp_prt(isp, ISP_LOGWARN,
6561 if (XS_NOERR(xs)) {
6562 XS_SETERR(xs, HBA_SELTIMEOUT);
6563 }
6564 return;
6565
6566
6567 case RQCS_24XX_ENOMEM: /* f/w resource unavailable */
6568 isp_prt(isp, ISP_LOGWARN,
6061 "f/w resource unavailable for target %d", XS_TGT(xs));
6569 "f/w resource unavailable for target %d chan %d",
6570 XS_TGT(xs), chan);
6062 if (XS_NOERR(xs)) {
6063 *XS_STSP(xs) = SCSI_BUSY;
6064 XS_SETERR(xs, HBA_TGTBSY);
6065 }
6066 return;
6067
6068 case RQCS_24XX_TMO: /* task management overrun */
6069 isp_prt(isp, ISP_LOGWARN,
6571 if (XS_NOERR(xs)) {
6572 *XS_STSP(xs) = SCSI_BUSY;
6573 XS_SETERR(xs, HBA_TGTBSY);
6574 }
6575 return;
6576
6577 case RQCS_24XX_TMO: /* task management overrun */
6578 isp_prt(isp, ISP_LOGWARN,
6070 "command for target %d overlapped task management",
6071 XS_TGT(xs));
6579 "command for target %d overlapped task management for "
6580 "chan %d", XS_TGT(xs), chan);
6072 if (XS_NOERR(xs)) {
6073 *XS_STSP(xs) = SCSI_BUSY;
6074 XS_SETERR(xs, HBA_TGTBSY);
6075 }
6076 return;
6077
6078 default:
6581 if (XS_NOERR(xs)) {
6582 *XS_STSP(xs) = SCSI_BUSY;
6583 XS_SETERR(xs, HBA_TGTBSY);
6584 }
6585 return;
6586
6587 default:
6079 isp_prt(isp, ISP_LOGERR, "Unknown Completion Status 0x%x",
6080 sp->req_completion_status);
6588 isp_prt(isp, ISP_LOGERR,
6589 "Unknown Completion Status 0x%x on chan %d",
6590 sp->req_completion_status, chan);
6081 break;
6082 }
6083 if (XS_NOERR(xs)) {
6084 XS_SETERR(xs, HBA_BOTCH);
6085 }
6086}
6087
6088static void
6089isp_fastpost_complete(ispsoftc_t *isp, uint16_t fph)
6090{
6091 XS_T *xs;
6092
6093 if (fph == 0) {
6094 return;
6095 }
6096 xs = isp_find_xs(isp, fph);
6097 if (xs == NULL) {
6591 break;
6592 }
6593 if (XS_NOERR(xs)) {
6594 XS_SETERR(xs, HBA_BOTCH);
6595 }
6596}
6597
6598static void
6599isp_fastpost_complete(ispsoftc_t *isp, uint16_t fph)
6600{
6601 XS_T *xs;
6602
6603 if (fph == 0) {
6604 return;
6605 }
6606 xs = isp_find_xs(isp, fph);
6607 if (xs == NULL) {
6098 isp_prt(isp, ISP_LOGDEBUG1,
6608 isp_prt(isp, ISP_LOGWARN,
6099 "Command for fast post handle 0x%x not found", fph);
6100 return;
6101 }
6102 isp_destroy_handle(isp, fph);
6103
6104 /*
6105 * Since we don't have a result queue entry item,
6106 * we must believe that SCSI status is zero and
6107 * that all data transferred.
6108 */
6609 "Command for fast post handle 0x%x not found", fph);
6610 return;
6611 }
6612 isp_destroy_handle(isp, fph);
6613
6614 /*
6615 * Since we don't have a result queue entry item,
6616 * we must believe that SCSI status is zero and
6617 * that all data transferred.
6618 */
6109 XS_SET_STATE_STAT(isp, xs, NULL);
6110 XS_RESID(xs) = 0;
6619 XS_SET_RESID(xs, 0);
6111 *XS_STSP(xs) = SCSI_GOOD;
6112 if (XS_XFRLEN(xs)) {
6113 ISP_DMAFREE(isp, xs, fph);
6114 }
6620 *XS_STSP(xs) = SCSI_GOOD;
6621 if (XS_XFRLEN(xs)) {
6622 ISP_DMAFREE(isp, xs, fph);
6623 }
6115 if (isp->isp_nactive)
6624 if (isp->isp_nactive) {
6116 isp->isp_nactive--;
6625 isp->isp_nactive--;
6626 }
6117 isp->isp_fphccmplt++;
6118 isp_done(xs);
6119}
6120
6121static int
6122isp_mbox_continue(ispsoftc_t *isp)
6123{
6124 mbreg_t mbs;

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

6147 } else {
6148 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
6149 ISP_WRITE(isp, BIU_SEMA, 0);
6150 }
6151
6152 /*
6153 * Continue with next word.
6154 */
6627 isp->isp_fphccmplt++;
6628 isp_done(xs);
6629}
6630
6631static int
6632isp_mbox_continue(ispsoftc_t *isp)
6633{
6634 mbreg_t mbs;

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

6657 } else {
6658 ISP_WRITE(isp, HCCR, HCCR_CMD_CLEAR_RISC_INT);
6659 ISP_WRITE(isp, BIU_SEMA, 0);
6660 }
6661
6662 /*
6663 * Continue with next word.
6664 */
6155 MEMZERO(&mbs, sizeof (mbs));
6665 ISP_MEMZERO(&mbs, sizeof (mbs));
6156 ptr = isp->isp_mbxworkp;
6157 switch (isp->isp_lastmbxcmd) {
6158 case MBOX_WRITE_RAM_WORD:
6159 mbs.param[1] = isp->isp_mbxwrk1++;;
6160 mbs.param[2] = *ptr++;;
6161 break;
6162 case MBOX_READ_RAM_WORD:
6163 *ptr++ = isp->isp_mboxtmp[2];

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

6392static const uint32_t mbpfc[] = {
6393 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
6394 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
6395 ISPOPMAP(0x0f, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
6396 ISPOPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */
6397 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
6398 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
6399 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
6666 ptr = isp->isp_mbxworkp;
6667 switch (isp->isp_lastmbxcmd) {
6668 case MBOX_WRITE_RAM_WORD:
6669 mbs.param[1] = isp->isp_mbxwrk1++;;
6670 mbs.param[2] = *ptr++;;
6671 break;
6672 case MBOX_READ_RAM_WORD:
6673 *ptr++ = isp->isp_mboxtmp[2];

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

6902static const uint32_t mbpfc[] = {
6903 ISPOPMAP(0x01, 0x01), /* 0x00: MBOX_NO_OP */
6904 ISPOPMAP(0x1f, 0x01), /* 0x01: MBOX_LOAD_RAM */
6905 ISPOPMAP(0x0f, 0x01), /* 0x02: MBOX_EXEC_FIRMWARE */
6906 ISPOPMAP(0xdf, 0x01), /* 0x03: MBOX_DUMP_RAM */
6907 ISPOPMAP(0x07, 0x07), /* 0x04: MBOX_WRITE_RAM_WORD */
6908 ISPOPMAP(0x03, 0x07), /* 0x05: MBOX_READ_RAM_WORD */
6909 ISPOPMAP(0xff, 0xff), /* 0x06: MBOX_MAILBOX_REG_TEST */
6400 ISPOPMAP(0x03, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
6910 ISPOPMAP(0x07, 0x07), /* 0x07: MBOX_VERIFY_CHECKSUM */
6401 ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */
6402 ISPOPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */
6403 ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
6404 ISPOPMAP(0x1ff, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */
6405 ISPOPMAP(0x00, 0x00), /* 0x0c: */
6406 ISPOPMAP(0x10f, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */
6407 ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
6408 ISPOPMAP(0x10f, 0x05), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */

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

6457 ISPOPMAP(0x03, 0x01), /* 0x40: MBOX_LOOP_PORT_BYPASS */
6458 ISPOPMAP(0x03, 0x01), /* 0x41: MBOX_LOOP_PORT_ENABLE */
6459 ISPOPMAP(0x03, 0x07), /* 0x42: MBOX_GET_RESOURCE_COUNT */
6460 ISPOPMAP(0x01, 0x01), /* 0x43: MBOX_REQUEST_OFFLINE_MODE */
6461 ISPOPMAP(0x00, 0x00), /* 0x44: */
6462 ISPOPMAP(0x00, 0x00), /* 0x45: */
6463 ISPOPMAP(0x00, 0x00), /* 0x46: */
6464 ISPOPMAP(0xcf, 0x03), /* 0x47: GET PORT_DATABASE ENHANCED */
6911 ISPOPMAP(0x01, 0x4f), /* 0x08: MBOX_ABOUT_FIRMWARE */
6912 ISPOPMAP(0xdf, 0x01), /* 0x09: MBOX_LOAD_RISC_RAM_2100 */
6913 ISPOPMAP(0xdf, 0x01), /* 0x0a: DUMP RAM */
6914 ISPOPMAP(0x1ff, 0x01), /* 0x0b: MBOX_LOAD_RISC_RAM */
6915 ISPOPMAP(0x00, 0x00), /* 0x0c: */
6916 ISPOPMAP(0x10f, 0x01), /* 0x0d: MBOX_WRITE_RAM_WORD_EXTENDED */
6917 ISPOPMAP(0x01, 0x05), /* 0x0e: MBOX_CHECK_FIRMWARE */
6918 ISPOPMAP(0x10f, 0x05), /* 0x0f: MBOX_READ_RAM_WORD_EXTENDED */

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

6967 ISPOPMAP(0x03, 0x01), /* 0x40: MBOX_LOOP_PORT_BYPASS */
6968 ISPOPMAP(0x03, 0x01), /* 0x41: MBOX_LOOP_PORT_ENABLE */
6969 ISPOPMAP(0x03, 0x07), /* 0x42: MBOX_GET_RESOURCE_COUNT */
6970 ISPOPMAP(0x01, 0x01), /* 0x43: MBOX_REQUEST_OFFLINE_MODE */
6971 ISPOPMAP(0x00, 0x00), /* 0x44: */
6972 ISPOPMAP(0x00, 0x00), /* 0x45: */
6973 ISPOPMAP(0x00, 0x00), /* 0x46: */
6974 ISPOPMAP(0xcf, 0x03), /* 0x47: GET PORT_DATABASE ENHANCED */
6465 ISPOPMAP(0x00, 0x00), /* 0x48: */
6466 ISPOPMAP(0x00, 0x00), /* 0x49: */
6467 ISPOPMAP(0x00, 0x00), /* 0x4a: */
6975 ISPOPMAP(0xcd, 0x01), /* 0x48: MBOX_INIT_FIRMWARE_MULTI_ID */
6976 ISPOPMAP(0xcd, 0x01), /* 0x49: MBOX_GET_VP_DATABASE */
6977 ISPOPMAP(0x2cd, 0x01), /* 0x4a: MBOX_GET_VP_DATABASE_ENTRY */
6468 ISPOPMAP(0x00, 0x00), /* 0x4b: */
6469 ISPOPMAP(0x00, 0x00), /* 0x4c: */
6470 ISPOPMAP(0x00, 0x00), /* 0x4d: */
6471 ISPOPMAP(0x00, 0x00), /* 0x4e: */
6472 ISPOPMAP(0x00, 0x00), /* 0x4f: */
6473 ISPOPMAP(0x00, 0x00), /* 0x50: */
6474 ISPOPMAP(0x00, 0x00), /* 0x51: */
6475 ISPOPMAP(0x00, 0x00), /* 0x52: */

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

6516 ISPOPMAP(0x00, 0x00), /* 0x7b: */
6517 ISPOPMAP(0x4f, 0x03), /* 0x7c: Get ID List */
6518 ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */
6519 ISPOPMAP(0x0f, 0x01) /* 0x7e: LUN RESET */
6520};
6521/*
6522 * Footnotes
6523 *
6978 ISPOPMAP(0x00, 0x00), /* 0x4b: */
6979 ISPOPMAP(0x00, 0x00), /* 0x4c: */
6980 ISPOPMAP(0x00, 0x00), /* 0x4d: */
6981 ISPOPMAP(0x00, 0x00), /* 0x4e: */
6982 ISPOPMAP(0x00, 0x00), /* 0x4f: */
6983 ISPOPMAP(0x00, 0x00), /* 0x50: */
6984 ISPOPMAP(0x00, 0x00), /* 0x51: */
6985 ISPOPMAP(0x00, 0x00), /* 0x52: */

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

7026 ISPOPMAP(0x00, 0x00), /* 0x7b: */
7027 ISPOPMAP(0x4f, 0x03), /* 0x7c: Get ID List */
7028 ISPOPMAP(0xcf, 0x01), /* 0x7d: SEND LFA */
7029 ISPOPMAP(0x0f, 0x01) /* 0x7e: LUN RESET */
7030};
7031/*
7032 * Footnotes
7033 *
6524 * (1): this sets bits 21..16 in mailbox register #8, which we nominally
7034 * (1): this sets bits 21..16 in mailbox register #8, which we nominally
6525 * do not access at this time in the core driver. The caller is
6526 * responsible for setting this register first (Gross!). The assumption
6527 * is that we won't overflow.
6528 */
6529
6530static const char *fc_mbcmd_names[] = {
6531 "NO-OP",
6532 "LOAD RAM",

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

6595 "LOOP PORT BYPASS",
6596 "LOOP PORT ENABLE",
6597 "GET RESOURCE COUNT",
6598 "REQUEST NON PARTICIPATING MODE",
6599 NULL,
6600 NULL,
6601 NULL,
6602 "GET PORT DATABASE ENHANCED",
7035 * do not access at this time in the core driver. The caller is
7036 * responsible for setting this register first (Gross!). The assumption
7037 * is that we won't overflow.
7038 */
7039
7040static const char *fc_mbcmd_names[] = {
7041 "NO-OP",
7042 "LOAD RAM",

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

7105 "LOOP PORT BYPASS",
7106 "LOOP PORT ENABLE",
7107 "GET RESOURCE COUNT",
7108 "REQUEST NON PARTICIPATING MODE",
7109 NULL,
7110 NULL,
7111 NULL,
7112 "GET PORT DATABASE ENHANCED",
7113 "INIT FIRMWARE MULTI ID",
7114 "GET VP DATABASE",
7115 "GET VP DATABASE ENTRY",
6603 NULL,
6604 NULL,
6605 NULL,
6606 NULL,
6607 NULL,
6608 NULL,
6609 NULL,
6610 NULL,
6611 NULL,
7116 NULL,
7117 NULL,
7118 NULL,
7119 NULL,
7120 NULL,
7121 NULL,
7122 NULL,
7123 NULL,
7124 NULL,
6612 NULL,
6613 NULL,
6614 NULL,
6615 "EXECUTE IOCB A64",
6616 NULL,
6617 NULL,
6618 NULL,
6619 NULL,
6620 NULL,
6621 NULL,
6622 "DRIVER HEARTBEAT",

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

6692 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
6693 }
6694 /*
6695 * Oddly enough, if we're not delaying for an answer,
6696 * delay a bit to give the f/w a chance to pick up the
6697 * command.
6698 */
6699 if (nodelay) {
7125 "EXECUTE IOCB A64",
7126 NULL,
7127 NULL,
7128 NULL,
7129 NULL,
7130 NULL,
7131 NULL,
7132 "DRIVER HEARTBEAT",

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

7202 ISP_WRITE(isp, HCCR, HCCR_CMD_SET_HOST_INT);
7203 }
7204 /*
7205 * Oddly enough, if we're not delaying for an answer,
7206 * delay a bit to give the f/w a chance to pick up the
7207 * command.
7208 */
7209 if (nodelay) {
6700 USEC_DELAY(1000);
7210 ISP_DELAY(1000);
6701 }
6702}
6703
6704static void
6705isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mbp)
6706{
6707 const char *cname, *xname;
6708 char tname[16], mname[16];

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

6743 */
6744 if (MBOX_ACQUIRE(isp)) {
6745 mbp->param[0] = MBOX_REGS_BUSY;
6746 goto out;
6747 }
6748
6749 for (box = 0; box < MAX_MAILBOX(isp); box++) {
6750 if (ibits & (1 << box)) {
7211 }
7212}
7213
7214static void
7215isp_mboxcmd(ispsoftc_t *isp, mbreg_t *mbp)
7216{
7217 const char *cname, *xname;
7218 char tname[16], mname[16];

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

7253 */
7254 if (MBOX_ACQUIRE(isp)) {
7255 mbp->param[0] = MBOX_REGS_BUSY;
7256 goto out;
7257 }
7258
7259 for (box = 0; box < MAX_MAILBOX(isp); box++) {
7260 if (ibits & (1 << box)) {
6751 isp_prt(isp, ISP_LOGDEBUG1, "IN mbox %d = 0x%04x", box,
7261 isp_prt(isp, ISP_LOGDEBUG3, "IN mbox %d = 0x%04x", box,
6752 mbp->param[box]);
6753 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
6754 }
6755 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
6756 }
6757
6758 isp->isp_lastmbxcmd = opcode;
6759

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

6776 * While we haven't finished the command, spin our wheels here.
6777 */
6778 MBOX_WAIT_COMPLETE(isp, mbp);
6779
6780 /*
6781 * Did the command time out?
6782 */
6783 if (mbp->param[0] == MBOX_TIMEOUT) {
7262 mbp->param[box]);
7263 ISP_WRITE(isp, MBOX_OFF(box), mbp->param[box]);
7264 }
7265 isp->isp_mboxtmp[box] = mbp->param[box] = 0;
7266 }
7267
7268 isp->isp_lastmbxcmd = opcode;
7269

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

7286 * While we haven't finished the command, spin our wheels here.
7287 */
7288 MBOX_WAIT_COMPLETE(isp, mbp);
7289
7290 /*
7291 * Did the command time out?
7292 */
7293 if (mbp->param[0] == MBOX_TIMEOUT) {
7294 isp->isp_mboxbsy = 0;
6784 MBOX_RELEASE(isp);
6785 goto out;
6786 }
6787
6788 /*
6789 * Copy back output registers.
6790 */
6791 for (box = 0; box < MAX_MAILBOX(isp); box++) {
6792 if (obits & (1 << box)) {
6793 mbp->param[box] = isp->isp_mboxtmp[box];
7295 MBOX_RELEASE(isp);
7296 goto out;
7297 }
7298
7299 /*
7300 * Copy back output registers.
7301 */
7302 for (box = 0; box < MAX_MAILBOX(isp); box++) {
7303 if (obits & (1 << box)) {
7304 mbp->param[box] = isp->isp_mboxtmp[box];
6794 isp_prt(isp, ISP_LOGDEBUG1, "OUT mbox %d = 0x%04x", box,
7305 isp_prt(isp, ISP_LOGDEBUG3, "OUT mbox %d = 0x%04x", box,
6795 mbp->param[box]);
6796 }
6797 }
6798
7306 mbp->param[box]);
7307 }
7308 }
7309
7310 isp->isp_mboxbsy = 0;
6799 MBOX_RELEASE(isp);
6800 out:
7311 MBOX_RELEASE(isp);
7312 out:
6801 isp->isp_mboxbsy = 0;
6802 if (mbp->logval == 0 || opcode == MBOX_EXEC_FIRMWARE) {
6803 return;
6804 }
6805 cname = (IS_FC(isp))? fc_mbcmd_names[opcode] : scsi_mbcmd_names[opcode];
6806 if (cname == NULL) {
6807 cname = tname;
7313 if (mbp->logval == 0 || opcode == MBOX_EXEC_FIRMWARE) {
7314 return;
7315 }
7316 cname = (IS_FC(isp))? fc_mbcmd_names[opcode] : scsi_mbcmd_names[opcode];
7317 if (cname == NULL) {
7318 cname = tname;
6808 SNPRINTF(tname, sizeof tname, "opcode %x", opcode);
7319 ISP_SNPRINTF(tname, sizeof tname, "opcode %x", opcode);
6809 }
6810
6811 /*
6812 * Just to be chatty here...
6813 */
6814 xname = NULL;
6815 switch (mbp->param[0]) {
6816 case MBOX_COMMAND_COMPLETE:

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

6857 break;
6858 case MBOX_REGS_BUSY:
6859 xname = "REGISTERS BUSY";
6860 break;
6861 case MBOX_TIMEOUT:
6862 xname = "TIMEOUT";
6863 break;
6864 default:
7320 }
7321
7322 /*
7323 * Just to be chatty here...
7324 */
7325 xname = NULL;
7326 switch (mbp->param[0]) {
7327 case MBOX_COMMAND_COMPLETE:

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

7368 break;
7369 case MBOX_REGS_BUSY:
7370 xname = "REGISTERS BUSY";
7371 break;
7372 case MBOX_TIMEOUT:
7373 xname = "TIMEOUT";
7374 break;
7375 default:
6865 SNPRINTF(mname, sizeof mname, "error 0x%x", mbp->param[0]);
7376 ISP_SNPRINTF(mname, sizeof mname, "error 0x%x", mbp->param[0]);
6866 xname = mname;
6867 break;
6868 }
6869 if (xname) {
6870 isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s)",
6871 cname, xname);
6872 }
6873}
6874
6875static void
7377 xname = mname;
7378 break;
7379 }
7380 if (xname) {
7381 isp_prt(isp, ISP_LOGALL, "Mailbox Command '%s' failed (%s)",
7382 cname, xname);
7383 }
7384}
7385
7386static void
6876isp_fw_state(ispsoftc_t *isp)
7387isp_fw_state(ispsoftc_t *isp, int chan)
6877{
6878 if (IS_FC(isp)) {
6879 mbreg_t mbs;
7388{
7389 if (IS_FC(isp)) {
7390 mbreg_t mbs;
6880 fcparam *fcp = isp->isp_param;
7391 fcparam *fcp = FCPARAM(isp, chan);
6881
7392
6882 MEMZERO(&mbs, sizeof (mbs));
6883 mbs.param[0] = MBOX_GET_FW_STATE;
6884 mbs.logval = MBLOGALL;
7393 MBSINIT(&mbs, MBOX_GET_FW_STATE, MBLOGALL, 0);
6885 isp_mboxcmd(isp, &mbs);
6886 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
6887 fcp->isp_fwstate = mbs.param[1];
6888 }
6889 }
6890}
6891
6892static void
7394 isp_mboxcmd(isp, &mbs);
7395 if (mbs.param[0] == MBOX_COMMAND_COMPLETE) {
7396 fcp->isp_fwstate = mbs.param[1];
7397 }
7398 }
7399}
7400
7401static void
6893isp_update(ispsoftc_t *isp)
7402isp_spi_update(ispsoftc_t *isp, int chan)
6894{
7403{
6895 int bus, upmask;
6896
6897 for (bus = 0, upmask = isp->isp_update; upmask != 0; bus++) {
6898 if (upmask & (1 << bus)) {
6899 isp_update_bus(isp, bus);
6900 }
6901 upmask &= ~(1 << bus);
6902 }
6903}
6904
6905static void
6906isp_update_bus(ispsoftc_t *isp, int bus)
6907{
6908 int tgt;
6909 mbreg_t mbs;
6910 sdparam *sdp;
6911
7404 int tgt;
7405 mbreg_t mbs;
7406 sdparam *sdp;
7407
6912 isp->isp_update &= ~(1 << bus);
6913 if (IS_FC(isp)) {
6914 /*
6915 * There are no 'per-bus' settings for Fibre Channel.
6916 */
6917 return;
6918 }
7408 if (IS_FC(isp)) {
7409 /*
7410 * There are no 'per-bus' settings for Fibre Channel.
7411 */
7412 return;
7413 }
6919 sdp = isp->isp_param;
6920 sdp += bus;
7414 sdp = SDPARAM(isp, chan);
7415 sdp->update = 0;
6921
6922 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
6923 uint16_t flags, period, offset;
6924 int get;
6925
6926 if (sdp->isp_devparam[tgt].dev_enable == 0) {
6927 sdp->isp_devparam[tgt].dev_update = 0;
6928 sdp->isp_devparam[tgt].dev_refresh = 0;
6929 isp_prt(isp, ISP_LOGDEBUG0,
7416
7417 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7418 uint16_t flags, period, offset;
7419 int get;
7420
7421 if (sdp->isp_devparam[tgt].dev_enable == 0) {
7422 sdp->isp_devparam[tgt].dev_update = 0;
7423 sdp->isp_devparam[tgt].dev_refresh = 0;
7424 isp_prt(isp, ISP_LOGDEBUG0,
6930 "skipping target %d bus %d update", tgt, bus);
7425 "skipping target %d bus %d update", tgt, chan);
6931 continue;
6932 }
6933 /*
6934 * If the goal is to update the status of the device,
6935 * take what's in goal_flags and try and set the device
6936 * toward that. Otherwise, if we're just refreshing the
6937 * current device state, get the current parameters.
6938 */
6939
7426 continue;
7427 }
7428 /*
7429 * If the goal is to update the status of the device,
7430 * take what's in goal_flags and try and set the device
7431 * toward that. Otherwise, if we're just refreshing the
7432 * current device state, get the current parameters.
7433 */
7434
6940 MEMZERO(&mbs, sizeof (mbs));
7435 MBSINIT(&mbs, 0, MBLOGALL, 0);
6941
6942 /*
6943 * Refresh overrides set
6944 */
6945 if (sdp->isp_devparam[tgt].dev_refresh) {
6946 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
6947 get = 1;
6948 } else if (sdp->isp_devparam[tgt].dev_update) {

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

6980 * when we have it all turned off. So change it here
6981 * to say that current already matches goal.
6982 */
6983 sdp->isp_devparam[tgt].actv_flags &= ~DPARM_TQING;
6984 sdp->isp_devparam[tgt].actv_flags |=
6985 (sdp->isp_devparam[tgt].goal_flags & DPARM_TQING);
6986 isp_prt(isp, ISP_LOGDEBUG0,
6987 "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
7436
7437 /*
7438 * Refresh overrides set
7439 */
7440 if (sdp->isp_devparam[tgt].dev_refresh) {
7441 mbs.param[0] = MBOX_GET_TARGET_PARAMS;
7442 get = 1;
7443 } else if (sdp->isp_devparam[tgt].dev_update) {

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

7475 * when we have it all turned off. So change it here
7476 * to say that current already matches goal.
7477 */
7478 sdp->isp_devparam[tgt].actv_flags &= ~DPARM_TQING;
7479 sdp->isp_devparam[tgt].actv_flags |=
7480 (sdp->isp_devparam[tgt].goal_flags & DPARM_TQING);
7481 isp_prt(isp, ISP_LOGDEBUG0,
7482 "bus %d set tgt %d flags 0x%x off 0x%x period 0x%x",
6988 bus, tgt, mbs.param[2], mbs.param[3] >> 8,
7483 chan, tgt, mbs.param[2], mbs.param[3] >> 8,
6989 mbs.param[3] & 0xff);
6990 get = 0;
6991 } else {
6992 continue;
6993 }
7484 mbs.param[3] & 0xff);
7485 get = 0;
7486 } else {
7487 continue;
7488 }
6994 mbs.param[1] = (bus << 15) | (tgt << 8);
6995 mbs.logval = MBLOGALL;
7489 mbs.param[1] = (chan << 15) | (tgt << 8);
6996 isp_mboxcmd(isp, &mbs);
6997 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
6998 continue;
6999 }
7000 if (get == 0) {
7490 isp_mboxcmd(isp, &mbs);
7491 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
7492 continue;
7493 }
7494 if (get == 0) {
7001 isp->isp_sendmarker |= (1 << bus);
7495 sdp->sendmarker = 1;
7002 sdp->isp_devparam[tgt].dev_update = 0;
7003 sdp->isp_devparam[tgt].dev_refresh = 1;
7004 } else {
7005 sdp->isp_devparam[tgt].dev_refresh = 0;
7006 flags = mbs.param[2];
7007 period = mbs.param[3] & 0xff;
7008 offset = mbs.param[3] >> 8;
7009 sdp->isp_devparam[tgt].actv_flags = flags;
7010 sdp->isp_devparam[tgt].actv_period = period;
7011 sdp->isp_devparam[tgt].actv_offset = offset;
7496 sdp->isp_devparam[tgt].dev_update = 0;
7497 sdp->isp_devparam[tgt].dev_refresh = 1;
7498 } else {
7499 sdp->isp_devparam[tgt].dev_refresh = 0;
7500 flags = mbs.param[2];
7501 period = mbs.param[3] & 0xff;
7502 offset = mbs.param[3] >> 8;
7503 sdp->isp_devparam[tgt].actv_flags = flags;
7504 sdp->isp_devparam[tgt].actv_period = period;
7505 sdp->isp_devparam[tgt].actv_offset = offset;
7012 get = (bus << 16) | tgt;
7013 (void) isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, &get);
7506 isp_async(isp, ISPASYNC_NEW_TGT_PARAMS, chan, tgt);
7014 }
7015 }
7016
7017 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7018 if (sdp->isp_devparam[tgt].dev_update ||
7019 sdp->isp_devparam[tgt].dev_refresh) {
7507 }
7508 }
7509
7510 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7511 if (sdp->isp_devparam[tgt].dev_update ||
7512 sdp->isp_devparam[tgt].dev_refresh) {
7020 isp->isp_update |= (1 << bus);
7513 sdp->update = 1;
7021 break;
7022 }
7023 }
7024}
7025
7514 break;
7515 }
7516 }
7517}
7518
7026#ifndef DEFAULT_EXEC_THROTTLE
7027#define DEFAULT_EXEC_THROTTLE(isp) ISP_EXEC_THROTTLE
7028#endif
7029
7030static void
7519static void
7031isp_setdfltparm(ispsoftc_t *isp, int channel)
7520isp_setdfltsdparm(ispsoftc_t *isp)
7032{
7033 int tgt;
7521{
7522 int tgt;
7034 sdparam *sdp;
7523 sdparam *sdp, *sdp1;
7035
7524
7036 sdp = (sdparam *) isp->isp_param;
7037 sdp += channel;
7525 sdp = SDPARAM(isp, 0);
7526 sdp->role = GET_DEFAULT_ROLE(isp, 0);
7527 if (IS_DUALBUS(isp)) {
7528 sdp1 = sdp + 1;
7529 sdp1->role = GET_DEFAULT_ROLE(isp, 1);
7530 } else {
7531 sdp1 = NULL;
7532 }
7038
7039 /*
7533
7534 /*
7040 * Been there, done that, got the T-shirt...
7041 */
7042 if (sdp->isp_gotdparms) {
7043 return;
7044 }
7045 sdp->isp_gotdparms = 1;
7046 sdp->isp_bad_nvram = 0;
7047 /*
7048 * Establish some default parameters.
7049 */
7050 sdp->isp_cmd_dma_burst_enable = 0;
7051 sdp->isp_data_dma_burst_enabl = 1;
7052 sdp->isp_fifo_threshold = 0;
7535 * Establish some default parameters.
7536 */
7537 sdp->isp_cmd_dma_burst_enable = 0;
7538 sdp->isp_data_dma_burst_enabl = 1;
7539 sdp->isp_fifo_threshold = 0;
7053 sdp->isp_initiator_id = DEFAULT_IID(isp);
7540 sdp->isp_initiator_id = DEFAULT_IID(isp, 0);
7054 if (isp->isp_type >= ISP_HA_SCSI_1040) {
7055 sdp->isp_async_data_setup = 9;
7056 } else {
7057 sdp->isp_async_data_setup = 6;
7058 }
7059 sdp->isp_selection_timeout = 250;
7060 sdp->isp_max_queue_depth = MAXISPREQUEST(isp);
7061 sdp->isp_tag_aging = 8;

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

7068 sdp->isp_retry_delay = 0;
7069
7070 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7071 sdp->isp_devparam[tgt].exc_throttle = ISP_EXEC_THROTTLE;
7072 sdp->isp_devparam[tgt].dev_enable = 1;
7073 }
7074
7075 /*
7541 if (isp->isp_type >= ISP_HA_SCSI_1040) {
7542 sdp->isp_async_data_setup = 9;
7543 } else {
7544 sdp->isp_async_data_setup = 6;
7545 }
7546 sdp->isp_selection_timeout = 250;
7547 sdp->isp_max_queue_depth = MAXISPREQUEST(isp);
7548 sdp->isp_tag_aging = 8;

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

7555 sdp->isp_retry_delay = 0;
7556
7557 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7558 sdp->isp_devparam[tgt].exc_throttle = ISP_EXEC_THROTTLE;
7559 sdp->isp_devparam[tgt].dev_enable = 1;
7560 }
7561
7562 /*
7076 * If we've not been told to avoid reading NVRAM, try and read it.
7077 * If we're successful reading it, we can then return because NVRAM
7078 * will tell us what the desired settings are. Otherwise, we establish
7079 * some reasonable 'fake' nvram and goal defaults.
7080 */
7081
7082 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
7083 if (isp_read_nvram(isp) == 0) {
7084 return;
7085 }
7086 sdp->isp_bad_nvram = 1;
7087 }
7088
7089 /*
7090 * Now try and see whether we have specific values for them.
7091 */
7092 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
7093 mbreg_t mbs;
7094
7095 MEMZERO(&mbs, sizeof (mbs));
7096 mbs.param[0] = MBOX_GET_ACT_NEG_STATE;
7097 mbs.logval = MBLOGNONE;
7098 isp_mboxcmd(isp, &mbs);
7099 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
7100 sdp->isp_req_ack_active_neg = 1;
7101 sdp->isp_data_line_active_neg = 1;
7102 } else {
7103 sdp->isp_req_ack_active_neg =
7104 (mbs.param[1+channel] >> 4) & 0x1;
7105 sdp->isp_data_line_active_neg =
7106 (mbs.param[1+channel] >> 5) & 0x1;
7107 }
7108 }
7109
7110 isp_prt(isp, ISP_LOGDEBUG0, sc0, sc3,
7111 0, sdp->isp_fifo_threshold, sdp->isp_initiator_id,
7112 sdp->isp_bus_reset_delay, sdp->isp_retry_count,
7113 sdp->isp_retry_delay, sdp->isp_async_data_setup);
7114 isp_prt(isp, ISP_LOGDEBUG0, sc1, sc3,
7115 sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg,
7116 sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable,
7117 sdp->isp_selection_timeout, sdp->isp_max_queue_depth);
7118
7119 /*
7120 * The trick here is to establish a default for the default (honk!)
7121 * state (goal_flags). Then try and get the current status from
7122 * the card to fill in the current state. We don't, in fact, set
7123 * the default to the SAFE default state- that's not the goal state.
7124 */
7125 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7126 uint8_t off, per;
7127 sdp->isp_devparam[tgt].actv_offset = 0;

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

7156 off = ISP_20M_SYNCPARMS_1040 >> 8;
7157 per = ISP_20M_SYNCPARMS_1040 & 0xff;
7158 }
7159 sdp->isp_devparam[tgt].goal_offset =
7160 sdp->isp_devparam[tgt].nvrm_offset = off;
7161 sdp->isp_devparam[tgt].goal_period =
7162 sdp->isp_devparam[tgt].nvrm_period = per;
7163
7563 * The trick here is to establish a default for the default (honk!)
7564 * state (goal_flags). Then try and get the current status from
7565 * the card to fill in the current state. We don't, in fact, set
7566 * the default to the SAFE default state- that's not the goal state.
7567 */
7568 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7569 uint8_t off, per;
7570 sdp->isp_devparam[tgt].actv_offset = 0;

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

7599 off = ISP_20M_SYNCPARMS_1040 >> 8;
7600 per = ISP_20M_SYNCPARMS_1040 & 0xff;
7601 }
7602 sdp->isp_devparam[tgt].goal_offset =
7603 sdp->isp_devparam[tgt].nvrm_offset = off;
7604 sdp->isp_devparam[tgt].goal_period =
7605 sdp->isp_devparam[tgt].nvrm_period = per;
7606
7164 isp_prt(isp, ISP_LOGDEBUG0, sc2, sc3,
7165 channel, tgt, sdp->isp_devparam[tgt].nvrm_flags,
7166 sdp->isp_devparam[tgt].nvrm_offset,
7167 sdp->isp_devparam[tgt].nvrm_period);
7168 }
7607 }
7608
7609 /*
7610 * If we're a dual bus card, just copy the data over
7611 */
7612 if (sdp1) {
7613 *sdp1 = *sdp;
7614 sdp1->isp_initiator_id = DEFAULT_IID(isp, 1);
7615 }
7616
7617 /*
7618 * If we've not been told to avoid reading NVRAM, try and read it.
7619 * If we're successful reading it, we can then return because NVRAM
7620 * will tell us what the desired settings are. Otherwise, we establish
7621 * some reasonable 'fake' nvram and goal defaults.
7622 */
7623 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
7624 mbreg_t mbs;
7625
7626 if (isp_read_nvram(isp, 0) == 0) {
7627 if (IS_DUALBUS(isp)) {
7628 if (isp_read_nvram(isp, 1) == 0) {
7629 return;
7630 }
7631 }
7632 }
7633 MBSINIT(&mbs, MBOX_GET_ACT_NEG_STATE, MBLOGNONE, 0);
7634 isp_mboxcmd(isp, &mbs);
7635 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
7636 sdp->isp_req_ack_active_neg = 1;
7637 sdp->isp_data_line_active_neg = 1;
7638 if (sdp1) {
7639 sdp1->isp_req_ack_active_neg = 1;
7640 sdp1->isp_data_line_active_neg = 1;
7641 }
7642 } else {
7643 sdp->isp_req_ack_active_neg =
7644 (mbs.param[1] >> 4) & 0x1;
7645 sdp->isp_data_line_active_neg =
7646 (mbs.param[1] >> 5) & 0x1;
7647 if (sdp1) {
7648 sdp1->isp_req_ack_active_neg =
7649 (mbs.param[2] >> 4) & 0x1;
7650 sdp1->isp_data_line_active_neg =
7651 (mbs.param[2] >> 5) & 0x1;
7652 }
7653 }
7654 }
7655
7169}
7170
7656}
7657
7171#ifndef DEFAULT_FRAMESIZE
7172#define DEFAULT_FRAMESIZE(isp) ICB_DFLT_FRMLEN
7173#endif
7174static void
7658static void
7175isp_setdfltfcparm(ispsoftc_t *isp)
7659isp_setdfltfcparm(ispsoftc_t *isp, int chan)
7176{
7660{
7177 fcparam *fcp = FCPARAM(isp);
7661 fcparam *fcp = FCPARAM(isp, chan);
7178
7662
7179 if (fcp->isp_gotdparms) {
7180 return;
7181 }
7182 fcp->isp_gotdparms = 1;
7183 fcp->isp_bad_nvram = 0;
7184 fcp->isp_maxfrmlen = DEFAULT_FRAMESIZE(isp);
7663 /*
7664 * Establish some default parameters.
7665 */
7666 fcp->role = GET_DEFAULT_ROLE(isp, chan);
7185 fcp->isp_maxalloc = ICB_DFLT_ALLOC;
7667 fcp->isp_maxalloc = ICB_DFLT_ALLOC;
7186 fcp->isp_execthrottle = DEFAULT_EXEC_THROTTLE(isp);
7187 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
7188 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
7668 fcp->isp_retry_delay = ICB_DFLT_RDELAY;
7669 fcp->isp_retry_count = ICB_DFLT_RCOUNT;
7189 /* Platform specific.... */
7190 fcp->isp_loopid = DEFAULT_LOOPID(isp);
7191 fcp->isp_wwnn_nvram = DEFAULT_NODEWWN(isp);
7192 fcp->isp_wwpn_nvram = DEFAULT_PORTWWN(isp);
7670 fcp->isp_loopid = DEFAULT_LOOPID(isp, chan);
7671 fcp->isp_wwnn_nvram = DEFAULT_NODEWWN(isp, chan);
7672 fcp->isp_wwpn_nvram = DEFAULT_PORTWWN(isp, chan);
7193 fcp->isp_fwoptions = 0;
7673 fcp->isp_fwoptions = 0;
7194 fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
7195 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
7196 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
7197 fcp->isp_fwoptions |= ICBOPT_FAST_POST;
7198 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX) {
7199 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
7674 fcp->isp_lasthdl = NIL_HANDLE;
7675
7676 if (IS_24XX(isp)) {
7677 fcp->isp_fwoptions |= ICB2400_OPT1_FAIRNESS;
7678 fcp->isp_fwoptions |= ICB2400_OPT1_HARD_ADDRESS;
7679 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX) {
7680 fcp->isp_fwoptions |= ICB2400_OPT1_FULL_DUPLEX;
7681 }
7682 fcp->isp_fwoptions |= ICB2400_OPT1_BOTH_WWNS;
7683 } else {
7684 fcp->isp_fwoptions |= ICBOPT_FAIRNESS;
7685 fcp->isp_fwoptions |= ICBOPT_PDBCHANGE_AE;
7686 fcp->isp_fwoptions |= ICBOPT_HARD_ADDRESS;
7687 fcp->isp_fwoptions |= ICBOPT_FAST_POST;
7688 if (isp->isp_confopts & ISP_CFG_FULL_DUPLEX) {
7689 fcp->isp_fwoptions |= ICBOPT_FULL_DUPLEX;
7690 }
7691 /*
7692 * Make sure this is turned off now until we get
7693 * extended options from NVRAM
7694 */
7695 fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
7200 }
7201
7696 }
7697
7202 /*
7203 * Make sure this is turned off now until we get
7204 * extended options from NVRAM
7205 */
7206 fcp->isp_fwoptions &= ~ICBOPT_EXTENDED;
7207
7208 /*
7209 * Now try and read NVRAM unless told to not do so.
7210 * This will set fcparam's isp_wwnn_nvram && isp_wwpn_nvram.
7211 */
7212 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
7213 int i, j = 0;
7214 /*
7215 * Give a couple of tries at reading NVRAM.
7216 */
7217 for (i = 0; i < 2; i++) {
7698
7699 /*
7700 * Now try and read NVRAM unless told to not do so.
7701 * This will set fcparam's isp_wwnn_nvram && isp_wwpn_nvram.
7702 */
7703 if ((isp->isp_confopts & ISP_CFG_NONVRAM) == 0) {
7704 int i, j = 0;
7705 /*
7706 * Give a couple of tries at reading NVRAM.
7707 */
7708 for (i = 0; i < 2; i++) {
7218 j = isp_read_nvram(isp);
7709 j = isp_read_nvram(isp, chan);
7219 if (j == 0) {
7220 break;
7221 }
7222 }
7223 if (j) {
7710 if (j == 0) {
7711 break;
7712 }
7713 }
7714 if (j) {
7224 fcp->isp_bad_nvram = 1;
7225 isp->isp_confopts |= ISP_CFG_NONVRAM;
7715 isp->isp_confopts |= ISP_CFG_NONVRAM;
7226 isp->isp_confopts |= ISP_CFG_OWNWWPN;
7227 isp->isp_confopts |= ISP_CFG_OWNWWNN;
7228 }
7716 }
7229 } else {
7230 isp->isp_confopts |= ISP_CFG_OWNWWPN|ISP_CFG_OWNWWNN;
7231 }
7232
7717 }
7718
7233 /*
7234 * Set node && port to override platform set defaults
7235 * unless the nvram read failed (or none was done),
7236 * or the platform code wants to use what had been
7237 * set in the defaults.
7238 */
7239 if (isp->isp_confopts & ISP_CFG_OWNWWNN) {
7240 isp_prt(isp, ISP_LOGCONFIG, "Using Node WWN 0x%08x%08x",
7241 (uint32_t) (DEFAULT_NODEWWN(isp) >> 32),
7242 (uint32_t) (DEFAULT_NODEWWN(isp) & 0xffffffff));
7243 ISP_NODEWWN(isp) = DEFAULT_NODEWWN(isp);
7244 } else {
7245 /*
7246 * We always start out with values derived
7247 * from NVRAM or our platform default.
7248 */
7249 ISP_NODEWWN(isp) = fcp->isp_wwnn_nvram;
7250 if (fcp->isp_wwnn_nvram == 0) {
7251 isp_prt(isp, ISP_LOGCONFIG,
7252 "bad WWNN- using default");
7253 ISP_NODEWWN(isp) = DEFAULT_NODEWWN(isp);
7254 }
7255 }
7256 if (isp->isp_confopts & ISP_CFG_OWNWWPN) {
7257 isp_prt(isp, ISP_LOGCONFIG, "Using Port WWN 0x%08x%08x",
7258 (uint32_t) (DEFAULT_PORTWWN(isp) >> 32),
7259 (uint32_t) (DEFAULT_PORTWWN(isp) & 0xffffffff));
7260 ISP_PORTWWN(isp) = DEFAULT_PORTWWN(isp);
7261 } else {
7262 /*
7263 * We always start out with values derived
7264 * from NVRAM or our platform default.
7265 */
7266 ISP_PORTWWN(isp) = fcp->isp_wwpn_nvram;
7267 if (fcp->isp_wwpn_nvram == 0) {
7268 isp_prt(isp, ISP_LOGCONFIG,
7269 "bad WWPN- using default");
7270 ISP_PORTWWN(isp) = DEFAULT_PORTWWN(isp);
7271 }
7272 }
7719 fcp->isp_wwnn = ACTIVE_NODEWWN(isp, chan);
7720 fcp->isp_wwpn = ACTIVE_PORTWWN(isp, chan);
7721 isp_prt(isp, ISP_LOGCONFIG, "Chan %d 0x%08x%08x/0x%08x%08x Role %s",
7722 chan, (uint32_t) (fcp->isp_wwnn >> 32), (uint32_t) (fcp->isp_wwnn),
7723 (uint32_t) (fcp->isp_wwpn >> 32), (uint32_t) (fcp->isp_wwpn),
7724 isp_class3_roles[fcp->role]);
7273}
7274
7275/*
7276 * Re-initialize the ISP and complete all orphaned commands
7277 * with a 'botched' notice. The reset/init routines should
7278 * not disturb an already active list of commands.
7279 */
7280
7281void
7725}
7726
7727/*
7728 * Re-initialize the ISP and complete all orphaned commands
7729 * with a 'botched' notice. The reset/init routines should
7730 * not disturb an already active list of commands.
7731 */
7732
7733void
7282isp_reinit(ispsoftc_t *isp)
7734isp_reinit(ispsoftc_t *isp, int do_load_defaults)
7283{
7735{
7284 XS_T *xs;
7285 uint32_t tmp;
7736 int i;
7286
7737
7287 if (IS_FC(isp)) {
7288 ISP_MARK_PORTDB(isp, 0);
7289 }
7290 isp_reset(isp);
7738 isp_reset(isp, do_load_defaults);
7739
7291 if (isp->isp_state != ISP_RESETSTATE) {
7740 if (isp->isp_state != ISP_RESETSTATE) {
7292 isp_prt(isp, ISP_LOGERR, "isp_reinit cannot reset card");
7293 } else if (isp->isp_role != ISP_ROLE_NONE) {
7294 isp_init(isp);
7295 if (isp->isp_state == ISP_INITSTATE) {
7296 isp->isp_state = ISP_RUNSTATE;
7297 }
7298 if (isp->isp_state != ISP_RUNSTATE) {
7299 isp_prt(isp, ISP_LOGERR,
7300 "isp_reinit cannot restart card");
7301 ISP_DISABLE_INTS(isp);
7302 }
7303 } else {
7741 isp_prt(isp, ISP_LOGERR, "%s: cannot reset card", __func__);
7304 ISP_DISABLE_INTS(isp);
7742 ISP_DISABLE_INTS(isp);
7743 goto cleanup;
7744 }
7745
7746 isp_init(isp);
7747
7748 if (isp->isp_state == ISP_INITSTATE) {
7749 isp->isp_state = ISP_RUNSTATE;
7750 }
7751
7752 if (isp->isp_state != ISP_RUNSTATE) {
7753#ifndef ISP_TARGET_MODE
7754 isp_prt(isp, ISP_LOGWARN, "%s: not at runstate", __func__);
7755#endif
7756 ISP_DISABLE_INTS(isp);
7305 if (IS_FC(isp)) {
7306 /*
7307 * If we're in ISP_ROLE_NONE, turn off the lasers.
7308 */
7309 if (!IS_24XX(isp)) {
7310 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
7311 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
7312 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
7313 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
7314 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
7315 }
7316 }
7317 }
7757 if (IS_FC(isp)) {
7758 /*
7759 * If we're in ISP_ROLE_NONE, turn off the lasers.
7760 */
7761 if (!IS_24XX(isp)) {
7762 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FPM0_REGS);
7763 ISP_WRITE(isp, FPM_DIAG_CONFIG, FPM_SOFT_RESET);
7764 ISP_WRITE(isp, BIU2100_CSR, BIU2100_FB_REGS);
7765 ISP_WRITE(isp, FBM_CMD, FBMCMD_FIFO_RESET_ALL);
7766 ISP_WRITE(isp, BIU2100_CSR, BIU2100_RISC_REGS);
7767 }
7768 }
7769 }
7318 isp->isp_nactive = 0;
7319
7770
7320 for (tmp = 0; tmp < isp->isp_maxcmds; tmp++) {
7321 uint32_t handle;
7771 cleanup:
7322
7772
7323 xs = isp->isp_xflist[tmp];
7324 if (xs == NULL) {
7325 continue;
7773 isp->isp_nactive = 0;
7774
7775 isp_clear_commands(isp);
7776 if (IS_FC(isp)) {
7777 for (i = 0; i < isp->isp_nchan; i++) {
7778 ISP_MARK_PORTDB(isp, i, -1);
7326 }
7779 }
7327 handle = isp_find_handle(isp, xs);
7328 if (handle == 0) {
7329 continue;
7330 }
7331 isp_destroy_handle(isp, handle);
7332 if (XS_XFRLEN(xs)) {
7333 ISP_DMAFREE(isp, xs, handle);
7334 XS_RESID(xs) = XS_XFRLEN(xs);
7335 } else {
7336 XS_RESID(xs) = 0;
7337 }
7338 XS_SETERR(xs, HBA_BUSRESET);
7339 isp_done(xs);
7340 }
7780 }
7341#ifdef ISP_TARGET_MODE
7342 MEMZERO(isp->isp_tgtlist, isp->isp_maxcmds * sizeof (void **));
7343#endif
7344}
7345
7346/*
7347 * NVRAM Routines
7348 */
7349static int
7781}
7782
7783/*
7784 * NVRAM Routines
7785 */
7786static int
7350isp_read_nvram(ispsoftc_t *isp)
7787isp_read_nvram(ispsoftc_t *isp, int bus)
7351{
7352 int i, amt, retval;
7353 uint8_t csum, minversion;
7354 union {
7788{
7789 int i, amt, retval;
7790 uint8_t csum, minversion;
7791 union {
7355 uint8_t _x[ISP2100_NVRAM_SIZE];
7356 uint16_t _s[ISP2100_NVRAM_SIZE>>1];
7792 uint8_t _x[ISP2400_NVRAM_SIZE];
7793 uint16_t _s[ISP2400_NVRAM_SIZE>>1];
7357 } _n;
7358#define nvram_data _n._x
7359#define nvram_words _n._s
7360
7361 if (IS_24XX(isp)) {
7794 } _n;
7795#define nvram_data _n._x
7796#define nvram_words _n._s
7797
7798 if (IS_24XX(isp)) {
7362 return (isp_read_nvram_2400(isp));
7799 return (isp_read_nvram_2400(isp, nvram_data));
7363 } else if (IS_FC(isp)) {
7364 amt = ISP2100_NVRAM_SIZE;
7365 minversion = 1;
7366 } else if (IS_ULTRA2(isp)) {
7367 amt = ISP1080_NVRAM_SIZE;
7368 minversion = 0;
7369 } else {
7370 amt = ISP_NVRAM_SIZE;

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

7398 if (ISP_NVRAM_VERSION(nvram_data) < minversion) {
7399 isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood",
7400 ISP_NVRAM_VERSION(nvram_data));
7401 retval = -1;
7402 goto out;
7403 }
7404
7405 if (IS_ULTRA3(isp)) {
7800 } else if (IS_FC(isp)) {
7801 amt = ISP2100_NVRAM_SIZE;
7802 minversion = 1;
7803 } else if (IS_ULTRA2(isp)) {
7804 amt = ISP1080_NVRAM_SIZE;
7805 minversion = 0;
7806 } else {
7807 amt = ISP_NVRAM_SIZE;

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

7835 if (ISP_NVRAM_VERSION(nvram_data) < minversion) {
7836 isp_prt(isp, ISP_LOGWARN, "version %d NVRAM not understood",
7837 ISP_NVRAM_VERSION(nvram_data));
7838 retval = -1;
7839 goto out;
7840 }
7841
7842 if (IS_ULTRA3(isp)) {
7406 isp_parse_nvram_12160(isp, 0, nvram_data);
7407 if (IS_12160(isp))
7408 isp_parse_nvram_12160(isp, 1, nvram_data);
7843 isp_parse_nvram_12160(isp, bus, nvram_data);
7409 } else if (IS_1080(isp)) {
7844 } else if (IS_1080(isp)) {
7410 isp_parse_nvram_1080(isp, 0, nvram_data);
7845 isp_parse_nvram_1080(isp, bus, nvram_data);
7411 } else if (IS_1280(isp) || IS_1240(isp)) {
7846 } else if (IS_1280(isp) || IS_1240(isp)) {
7412 isp_parse_nvram_1080(isp, 0, nvram_data);
7413 isp_parse_nvram_1080(isp, 1, nvram_data);
7847 isp_parse_nvram_1080(isp, bus, nvram_data);
7414 } else if (IS_SCSI(isp)) {
7415 isp_parse_nvram_1020(isp, nvram_data);
7416 } else {
7417 isp_parse_nvram_2100(isp, nvram_data);
7418 }
7419 retval = 0;
7420out:
7421 return (retval);
7422#undef nvram_data
7423#undef nvram_words
7424}
7425
7426static int
7848 } else if (IS_SCSI(isp)) {
7849 isp_parse_nvram_1020(isp, nvram_data);
7850 } else {
7851 isp_parse_nvram_2100(isp, nvram_data);
7852 }
7853 retval = 0;
7854out:
7855 return (retval);
7856#undef nvram_data
7857#undef nvram_words
7858}
7859
7860static int
7427isp_read_nvram_2400(ispsoftc_t *isp)
7861isp_read_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
7428{
7862{
7429 uint8_t *nvram_data = FCPARAM(isp)->isp_scratch;
7430 int retval = 0;
7431 uint32_t addr, csum, lwrds, *dptr;
7863 int retval = 0;
7864 uint32_t addr, csum, lwrds, *dptr;
7432
7865
7433 if (isp->isp_port) {
7434 addr = ISP2400_NVRAM_PORT1_ADDR;
7435 } else {
7436 addr = ISP2400_NVRAM_PORT0_ADDR;
7437 }
7866 if (isp->isp_port) {
7867 addr = ISP2400_NVRAM_PORT1_ADDR;
7868 } else {
7869 addr = ISP2400_NVRAM_PORT0_ADDR;
7870 }
7438
7871
7439 dptr = (uint32_t *) nvram_data;
7440 for (lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
7441 isp_rd_2400_nvram(isp, addr++, dptr++);
7442 }
7443 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
7444 nvram_data[2] != 'P') {
7445 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header (%x %x %x)",
7446 nvram_data[0], nvram_data[1], nvram_data[2]);

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

7465
7466static void
7467isp_rdnvram_word(ispsoftc_t *isp, int wo, uint16_t *rp)
7468{
7469 int i, cbits;
7470 uint16_t bit, rqst, junk;
7471
7472 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
7872 dptr = (uint32_t *) nvram_data;
7873 for (lwrds = 0; lwrds < ISP2400_NVRAM_SIZE >> 2; lwrds++) {
7874 isp_rd_2400_nvram(isp, addr++, dptr++);
7875 }
7876 if (nvram_data[0] != 'I' || nvram_data[1] != 'S' ||
7877 nvram_data[2] != 'P') {
7878 isp_prt(isp, ISP_LOGWARN, "invalid NVRAM header (%x %x %x)",
7879 nvram_data[0], nvram_data[1], nvram_data[2]);

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

7898
7899static void
7900isp_rdnvram_word(ispsoftc_t *isp, int wo, uint16_t *rp)
7901{
7902 int i, cbits;
7903 uint16_t bit, rqst, junk;
7904
7905 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
7473 USEC_DELAY(10);
7906 ISP_DELAY(10);
7474 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
7907 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
7475 USEC_DELAY(10);
7908 ISP_DELAY(10);
7476
7477 if (IS_FC(isp)) {
7909
7910 if (IS_FC(isp)) {
7478 wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1);
7911 wo &= ((ISP2100_NVRAM_SIZE >> 1) - 1);
7479 if (IS_2312(isp) && isp->isp_port) {
7480 wo += 128;
7481 }
7482 rqst = (ISP_NVRAM_READ << 8) | wo;
7483 cbits = 10;
7484 } else if (IS_ULTRA2(isp)) {
7485 wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1);
7486 rqst = (ISP_NVRAM_READ << 8) | wo;

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

7496 */
7497 for (i = cbits; i >= 0; i--) {
7498 if ((rqst >> i) & 1) {
7499 bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT;
7500 } else {
7501 bit = BIU_NVRAM_SELECT;
7502 }
7503 ISP_WRITE(isp, BIU_NVRAM, bit);
7912 if (IS_2312(isp) && isp->isp_port) {
7913 wo += 128;
7914 }
7915 rqst = (ISP_NVRAM_READ << 8) | wo;
7916 cbits = 10;
7917 } else if (IS_ULTRA2(isp)) {
7918 wo &= ((ISP1080_NVRAM_SIZE >> 1) - 1);
7919 rqst = (ISP_NVRAM_READ << 8) | wo;

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

7929 */
7930 for (i = cbits; i >= 0; i--) {
7931 if ((rqst >> i) & 1) {
7932 bit = BIU_NVRAM_SELECT | BIU_NVRAM_DATAOUT;
7933 } else {
7934 bit = BIU_NVRAM_SELECT;
7935 }
7936 ISP_WRITE(isp, BIU_NVRAM, bit);
7504 USEC_DELAY(10);
7937 ISP_DELAY(10);
7505 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7506 ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK);
7938 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7939 ISP_WRITE(isp, BIU_NVRAM, bit | BIU_NVRAM_CLOCK);
7507 USEC_DELAY(10);
7940 ISP_DELAY(10);
7508 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7509 ISP_WRITE(isp, BIU_NVRAM, bit);
7941 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7942 ISP_WRITE(isp, BIU_NVRAM, bit);
7510 USEC_DELAY(10);
7943 ISP_DELAY(10);
7511 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7512 }
7513 /*
7514 * Now read the result back in (bits come back in MSB format).
7515 */
7516 *rp = 0;
7517 for (i = 0; i < 16; i++) {
7518 uint16_t rv;
7519 *rp <<= 1;
7520 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
7944 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7945 }
7946 /*
7947 * Now read the result back in (bits come back in MSB format).
7948 */
7949 *rp = 0;
7950 for (i = 0; i < 16; i++) {
7951 uint16_t rv;
7952 *rp <<= 1;
7953 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT|BIU_NVRAM_CLOCK);
7521 USEC_DELAY(10);
7954 ISP_DELAY(10);
7522 rv = ISP_READ(isp, BIU_NVRAM);
7523 if (rv & BIU_NVRAM_DATAIN) {
7524 *rp |= 1;
7525 }
7955 rv = ISP_READ(isp, BIU_NVRAM);
7956 if (rv & BIU_NVRAM_DATAIN) {
7957 *rp |= 1;
7958 }
7526 USEC_DELAY(10);
7959 ISP_DELAY(10);
7527 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
7960 ISP_WRITE(isp, BIU_NVRAM, BIU_NVRAM_SELECT);
7528 USEC_DELAY(10);
7961 ISP_DELAY(10);
7529 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7530 }
7531 ISP_WRITE(isp, BIU_NVRAM, 0);
7962 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7963 }
7964 ISP_WRITE(isp, BIU_NVRAM, 0);
7532 USEC_DELAY(10);
7965 ISP_DELAY(10);
7533 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7534 ISP_SWIZZLE_NVRAM_WORD(isp, rp);
7535}
7536
7537static void
7538isp_rd_2400_nvram(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
7539{
7540 int loops = 0;
7966 junk = ISP_READ(isp, BIU_NVRAM); /* force PCI flush */
7967 ISP_SWIZZLE_NVRAM_WORD(isp, rp);
7968}
7969
7970static void
7971isp_rd_2400_nvram(ispsoftc_t *isp, uint32_t addr, uint32_t *rp)
7972{
7973 int loops = 0;
7541 const uint32_t base = 0x7ffe0000;
7974 uint32_t base = 0x7ffe0000;
7542 uint32_t tmp = 0;
7543
7975 uint32_t tmp = 0;
7976
7977 if (IS_25XX(isp)) {
7978 base = 0x7ff00000 | 0x48000;
7979 }
7544 ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
7545 for (loops = 0; loops < 5000; loops++) {
7980 ISP_WRITE(isp, BIU2400_FLASH_ADDR, base | addr);
7981 for (loops = 0; loops < 5000; loops++) {
7546 USEC_DELAY(10);
7982 ISP_DELAY(10);
7547 tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
7548 if ((tmp & (1U << 31)) != 0) {
7549 break;
7550 }
7551 }
7552 if (tmp & (1U << 31)) {
7553 *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
7554 ISP_SWIZZLE_NVRAM_LONG(isp, rp);
7555 } else {
7556 *rp = 0xffffffff;
7557 }
7558}
7559
7560static void
7561isp_parse_nvram_1020(ispsoftc_t *isp, uint8_t *nvram_data)
7562{
7983 tmp = ISP_READ(isp, BIU2400_FLASH_ADDR);
7984 if ((tmp & (1U << 31)) != 0) {
7985 break;
7986 }
7987 }
7988 if (tmp & (1U << 31)) {
7989 *rp = ISP_READ(isp, BIU2400_FLASH_DATA);
7990 ISP_SWIZZLE_NVRAM_LONG(isp, rp);
7991 } else {
7992 *rp = 0xffffffff;
7993 }
7994}
7995
7996static void
7997isp_parse_nvram_1020(ispsoftc_t *isp, uint8_t *nvram_data)
7998{
7563 sdparam *sdp = (sdparam *) isp->isp_param;
7999 sdparam *sdp = SDPARAM(isp, 0);
7564 int tgt;
7565
7566 sdp->isp_fifo_threshold =
7567 ISP_NVRAM_FIFO_THRESHOLD(nvram_data) |
7568 (ISP_NVRAM_FIFO_THRESHOLD_128(nvram_data) << 2);
7569
7570 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
7571 sdp->isp_initiator_id =

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

7611 sdp->isp_selection_timeout =
7612 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data);
7613
7614 sdp->isp_max_queue_depth =
7615 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data);
7616
7617 sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
7618
8000 int tgt;
8001
8002 sdp->isp_fifo_threshold =
8003 ISP_NVRAM_FIFO_THRESHOLD(nvram_data) |
8004 (ISP_NVRAM_FIFO_THRESHOLD_128(nvram_data) << 2);
8005
8006 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
8007 sdp->isp_initiator_id =

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

8047 sdp->isp_selection_timeout =
8048 ISP_NVRAM_SELECTION_TIMEOUT(nvram_data);
8049
8050 sdp->isp_max_queue_depth =
8051 ISP_NVRAM_MAX_QUEUE_DEPTH(nvram_data);
8052
8053 sdp->isp_fast_mttr = ISP_NVRAM_FAST_MTTR_ENABLE(nvram_data);
8054
7619 isp_prt(isp, ISP_LOGDEBUG0, sc0, sc4,
7620 0, sdp->isp_fifo_threshold, sdp->isp_initiator_id,
7621 sdp->isp_bus_reset_delay, sdp->isp_retry_count,
7622 sdp->isp_retry_delay, sdp->isp_async_data_setup);
7623 isp_prt(isp, ISP_LOGDEBUG0, sc1, sc4,
7624 sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg,
7625 sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable,
7626 sdp->isp_selection_timeout, sdp->isp_max_queue_depth);
7627
7628 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7629 sdp->isp_devparam[tgt].dev_enable =
7630 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt);
7631 sdp->isp_devparam[tgt].exc_throttle =
7632 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt);
7633 sdp->isp_devparam[tgt].nvrm_offset =
7634 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt);
7635 sdp->isp_devparam[tgt].nvrm_period =

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

7665 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
7666 if (ISP_NVRAM_TGT_WIDE(nvram_data, tgt))
7667 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
7668 if (ISP_NVRAM_TGT_PARITY(nvram_data, tgt))
7669 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
7670 if (ISP_NVRAM_TGT_DISC(nvram_data, tgt))
7671 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
7672 sdp->isp_devparam[tgt].actv_flags = 0; /* we don't know */
8055 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
8056 sdp->isp_devparam[tgt].dev_enable =
8057 ISP_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt);
8058 sdp->isp_devparam[tgt].exc_throttle =
8059 ISP_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt);
8060 sdp->isp_devparam[tgt].nvrm_offset =
8061 ISP_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt);
8062 sdp->isp_devparam[tgt].nvrm_period =

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

8092 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
8093 if (ISP_NVRAM_TGT_WIDE(nvram_data, tgt))
8094 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
8095 if (ISP_NVRAM_TGT_PARITY(nvram_data, tgt))
8096 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
8097 if (ISP_NVRAM_TGT_DISC(nvram_data, tgt))
8098 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
8099 sdp->isp_devparam[tgt].actv_flags = 0; /* we don't know */
7673 isp_prt(isp, ISP_LOGDEBUG0, sc2, sc4,
7674 0, tgt, sdp->isp_devparam[tgt].nvrm_flags,
7675 sdp->isp_devparam[tgt].nvrm_offset,
7676 sdp->isp_devparam[tgt].nvrm_period);
7677 sdp->isp_devparam[tgt].goal_offset =
7678 sdp->isp_devparam[tgt].nvrm_offset;
7679 sdp->isp_devparam[tgt].goal_period =
7680 sdp->isp_devparam[tgt].nvrm_period;
7681 sdp->isp_devparam[tgt].goal_flags =
7682 sdp->isp_devparam[tgt].nvrm_flags;
7683 }
7684}
7685
7686static void
7687isp_parse_nvram_1080(ispsoftc_t *isp, int bus, uint8_t *nvram_data)
7688{
8100 sdp->isp_devparam[tgt].goal_offset =
8101 sdp->isp_devparam[tgt].nvrm_offset;
8102 sdp->isp_devparam[tgt].goal_period =
8103 sdp->isp_devparam[tgt].nvrm_period;
8104 sdp->isp_devparam[tgt].goal_flags =
8105 sdp->isp_devparam[tgt].nvrm_flags;
8106 }
8107}
8108
8109static void
8110isp_parse_nvram_1080(ispsoftc_t *isp, int bus, uint8_t *nvram_data)
8111{
7689 sdparam *sdp = (sdparam *) isp->isp_param;
8112 sdparam *sdp = SDPARAM(isp, bus);
7690 int tgt;
7691
8113 int tgt;
8114
7692 sdp += bus;
7693
7694 sdp->isp_fifo_threshold =
7695 ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data);
7696
7697 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
7698 sdp->isp_initiator_id =
7699 ISP1080_NVRAM_INITIATOR_ID(nvram_data, bus);
7700
7701 sdp->isp_bus_reset_delay =

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

7723 ISP1080_NVRAM_BURST_ENABLE(nvram_data);
7724
7725 sdp->isp_selection_timeout =
7726 ISP1080_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
7727
7728 sdp->isp_max_queue_depth =
7729 ISP1080_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
7730
8115 sdp->isp_fifo_threshold =
8116 ISP1080_NVRAM_FIFO_THRESHOLD(nvram_data);
8117
8118 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
8119 sdp->isp_initiator_id =
8120 ISP1080_NVRAM_INITIATOR_ID(nvram_data, bus);
8121
8122 sdp->isp_bus_reset_delay =

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

8144 ISP1080_NVRAM_BURST_ENABLE(nvram_data);
8145
8146 sdp->isp_selection_timeout =
8147 ISP1080_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
8148
8149 sdp->isp_max_queue_depth =
8150 ISP1080_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
8151
7731 isp_prt(isp, ISP_LOGDEBUG0, sc0, sc4,
7732 bus, sdp->isp_fifo_threshold, sdp->isp_initiator_id,
7733 sdp->isp_bus_reset_delay, sdp->isp_retry_count,
7734 sdp->isp_retry_delay, sdp->isp_async_data_setup);
7735 isp_prt(isp, ISP_LOGDEBUG0, sc1, sc4,
7736 sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg,
7737 sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable,
7738 sdp->isp_selection_timeout, sdp->isp_max_queue_depth);
7739
7740
7741 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7742 sdp->isp_devparam[tgt].dev_enable =
7743 ISP1080_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus);
7744 sdp->isp_devparam[tgt].exc_throttle =
7745 ISP1080_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus);
7746 sdp->isp_devparam[tgt].nvrm_offset =
7747 ISP1080_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus);
7748 sdp->isp_devparam[tgt].nvrm_period =

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

7757 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
7758 if (ISP1080_NVRAM_TGT_WIDE(nvram_data, tgt, bus))
7759 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
7760 if (ISP1080_NVRAM_TGT_PARITY(nvram_data, tgt, bus))
7761 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
7762 if (ISP1080_NVRAM_TGT_DISC(nvram_data, tgt, bus))
7763 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
7764 sdp->isp_devparam[tgt].actv_flags = 0;
8152 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
8153 sdp->isp_devparam[tgt].dev_enable =
8154 ISP1080_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus);
8155 sdp->isp_devparam[tgt].exc_throttle =
8156 ISP1080_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus);
8157 sdp->isp_devparam[tgt].nvrm_offset =
8158 ISP1080_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus);
8159 sdp->isp_devparam[tgt].nvrm_period =

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

8168 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
8169 if (ISP1080_NVRAM_TGT_WIDE(nvram_data, tgt, bus))
8170 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
8171 if (ISP1080_NVRAM_TGT_PARITY(nvram_data, tgt, bus))
8172 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
8173 if (ISP1080_NVRAM_TGT_DISC(nvram_data, tgt, bus))
8174 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
8175 sdp->isp_devparam[tgt].actv_flags = 0;
7765 isp_prt(isp, ISP_LOGDEBUG0, sc2, sc4,
7766 bus, tgt, sdp->isp_devparam[tgt].nvrm_flags,
7767 sdp->isp_devparam[tgt].nvrm_offset,
7768 sdp->isp_devparam[tgt].nvrm_period);
7769 sdp->isp_devparam[tgt].goal_offset =
7770 sdp->isp_devparam[tgt].nvrm_offset;
7771 sdp->isp_devparam[tgt].goal_period =
7772 sdp->isp_devparam[tgt].nvrm_period;
7773 sdp->isp_devparam[tgt].goal_flags =
7774 sdp->isp_devparam[tgt].nvrm_flags;
7775 }
7776}
7777
7778static void
7779isp_parse_nvram_12160(ispsoftc_t *isp, int bus, uint8_t *nvram_data)
7780{
8176 sdp->isp_devparam[tgt].goal_offset =
8177 sdp->isp_devparam[tgt].nvrm_offset;
8178 sdp->isp_devparam[tgt].goal_period =
8179 sdp->isp_devparam[tgt].nvrm_period;
8180 sdp->isp_devparam[tgt].goal_flags =
8181 sdp->isp_devparam[tgt].nvrm_flags;
8182 }
8183}
8184
8185static void
8186isp_parse_nvram_12160(ispsoftc_t *isp, int bus, uint8_t *nvram_data)
8187{
7781 sdparam *sdp = (sdparam *) isp->isp_param;
8188 sdparam *sdp = SDPARAM(isp, bus);
7782 int tgt;
7783
8189 int tgt;
8190
7784 sdp += bus;
7785
7786 sdp->isp_fifo_threshold =
7787 ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data);
7788
7789 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
7790 sdp->isp_initiator_id =
7791 ISP12160_NVRAM_INITIATOR_ID(nvram_data, bus);
7792
7793 sdp->isp_bus_reset_delay =

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

7815 ISP12160_NVRAM_BURST_ENABLE(nvram_data);
7816
7817 sdp->isp_selection_timeout =
7818 ISP12160_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
7819
7820 sdp->isp_max_queue_depth =
7821 ISP12160_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
7822
8191 sdp->isp_fifo_threshold =
8192 ISP12160_NVRAM_FIFO_THRESHOLD(nvram_data);
8193
8194 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0)
8195 sdp->isp_initiator_id =
8196 ISP12160_NVRAM_INITIATOR_ID(nvram_data, bus);
8197
8198 sdp->isp_bus_reset_delay =

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

8220 ISP12160_NVRAM_BURST_ENABLE(nvram_data);
8221
8222 sdp->isp_selection_timeout =
8223 ISP12160_NVRAM_SELECTION_TIMEOUT(nvram_data, bus);
8224
8225 sdp->isp_max_queue_depth =
8226 ISP12160_NVRAM_MAX_QUEUE_DEPTH(nvram_data, bus);
8227
7823 isp_prt(isp, ISP_LOGDEBUG0, sc0, sc4,
7824 bus, sdp->isp_fifo_threshold, sdp->isp_initiator_id,
7825 sdp->isp_bus_reset_delay, sdp->isp_retry_count,
7826 sdp->isp_retry_delay, sdp->isp_async_data_setup);
7827 isp_prt(isp, ISP_LOGDEBUG0, sc1, sc4,
7828 sdp->isp_req_ack_active_neg, sdp->isp_data_line_active_neg,
7829 sdp->isp_data_dma_burst_enabl, sdp->isp_cmd_dma_burst_enable,
7830 sdp->isp_selection_timeout, sdp->isp_max_queue_depth);
7831
7832 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
7833 sdp->isp_devparam[tgt].dev_enable =
7834 ISP12160_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus);
7835 sdp->isp_devparam[tgt].exc_throttle =
7836 ISP12160_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus);
7837 sdp->isp_devparam[tgt].nvrm_offset =
7838 ISP12160_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus);
7839 sdp->isp_devparam[tgt].nvrm_period =

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

7848 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
7849 if (ISP12160_NVRAM_TGT_WIDE(nvram_data, tgt, bus))
7850 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
7851 if (ISP12160_NVRAM_TGT_PARITY(nvram_data, tgt, bus))
7852 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
7853 if (ISP12160_NVRAM_TGT_DISC(nvram_data, tgt, bus))
7854 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
7855 sdp->isp_devparam[tgt].actv_flags = 0;
8228 for (tgt = 0; tgt < MAX_TARGETS; tgt++) {
8229 sdp->isp_devparam[tgt].dev_enable =
8230 ISP12160_NVRAM_TGT_DEVICE_ENABLE(nvram_data, tgt, bus);
8231 sdp->isp_devparam[tgt].exc_throttle =
8232 ISP12160_NVRAM_TGT_EXEC_THROTTLE(nvram_data, tgt, bus);
8233 sdp->isp_devparam[tgt].nvrm_offset =
8234 ISP12160_NVRAM_TGT_SYNC_OFFSET(nvram_data, tgt, bus);
8235 sdp->isp_devparam[tgt].nvrm_period =

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

8244 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_SYNC;
8245 if (ISP12160_NVRAM_TGT_WIDE(nvram_data, tgt, bus))
8246 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_WIDE;
8247 if (ISP12160_NVRAM_TGT_PARITY(nvram_data, tgt, bus))
8248 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_PARITY;
8249 if (ISP12160_NVRAM_TGT_DISC(nvram_data, tgt, bus))
8250 sdp->isp_devparam[tgt].nvrm_flags |= DPARM_DISC;
8251 sdp->isp_devparam[tgt].actv_flags = 0;
7856 isp_prt(isp, ISP_LOGDEBUG0, sc2, sc4,
7857 bus, tgt, sdp->isp_devparam[tgt].nvrm_flags,
7858 sdp->isp_devparam[tgt].nvrm_offset,
7859 sdp->isp_devparam[tgt].nvrm_period);
7860 sdp->isp_devparam[tgt].goal_offset =
7861 sdp->isp_devparam[tgt].nvrm_offset;
7862 sdp->isp_devparam[tgt].goal_period =
7863 sdp->isp_devparam[tgt].nvrm_period;
7864 sdp->isp_devparam[tgt].goal_flags =
7865 sdp->isp_devparam[tgt].nvrm_flags;
7866 }
7867}
7868
7869static void
8252 sdp->isp_devparam[tgt].goal_offset =
8253 sdp->isp_devparam[tgt].nvrm_offset;
8254 sdp->isp_devparam[tgt].goal_period =
8255 sdp->isp_devparam[tgt].nvrm_period;
8256 sdp->isp_devparam[tgt].goal_flags =
8257 sdp->isp_devparam[tgt].nvrm_flags;
8258 }
8259}
8260
8261static void
7870isp_fix_nvram_wwns(ispsoftc_t *isp)
7871{
7872 fcparam *fcp = FCPARAM(isp);
7873
7874 /*
7875 * Make sure we have both Node and Port as non-zero values.
7876 */
7877 if (fcp->isp_wwnn_nvram != 0 && fcp->isp_wwpn_nvram == 0) {
7878 fcp->isp_wwpn_nvram = fcp->isp_wwnn_nvram;
7879 } else if (fcp->isp_wwnn_nvram == 0 && fcp->isp_wwpn_nvram != 0) {
7880 fcp->isp_wwnn_nvram = fcp->isp_wwpn_nvram;
7881 }
7882
7883 /*
7884 * Make the Node and Port values sane if they're NAA == 2.
7885 * This means to clear bits 48..56 for the Node WWN and
7886 * make sure that there's some non-zero value in 48..56
7887 * for the Port WWN.
7888 */
7889 if (fcp->isp_wwnn_nvram && fcp->isp_wwpn_nvram) {
7890 if ((fcp->isp_wwnn_nvram & (((uint64_t) 0xfff) << 48)) != 0 &&
7891 (fcp->isp_wwnn_nvram >> 60) == 2) {
7892 fcp->isp_wwnn_nvram &= ~((uint64_t) 0xfff << 48);
7893 }
7894 if ((fcp->isp_wwpn_nvram & (((uint64_t) 0xfff) << 48)) == 0 &&
7895 (fcp->isp_wwpn_nvram >> 60) == 2) {
7896 fcp->isp_wwpn_nvram |= ((uint64_t) 1 << 56);
7897 }
7898 }
7899}
7900
7901static void
7902isp_parse_nvram_2100(ispsoftc_t *isp, uint8_t *nvram_data)
7903{
8262isp_parse_nvram_2100(ispsoftc_t *isp, uint8_t *nvram_data)
8263{
7904 fcparam *fcp = FCPARAM(isp);
8264 fcparam *fcp = FCPARAM(isp, 0);
7905 uint64_t wwn;
7906
7907 /*
7908 * There is NVRAM storage for both Port and Node entities-
7909 * but the Node entity appears to be unused on all the cards
7910 * I can find. However, we should account for this being set
7911 * at some point in the future.
7912 *
7913 * Qlogic WWNs have an NAA of 2, but usually nothing shows up in
7914 * bits 48..60. In the case of the 2202, it appears that they do
7915 * use bit 48 to distinguish between the two instances on the card.
7916 * The 2204, which I've never seen, *probably* extends this method.
7917 */
7918 wwn = ISP2100_NVRAM_PORT_NAME(nvram_data);
7919 if (wwn) {
7920 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Port WWN 0x%08x%08x",
8265 uint64_t wwn;
8266
8267 /*
8268 * There is NVRAM storage for both Port and Node entities-
8269 * but the Node entity appears to be unused on all the cards
8270 * I can find. However, we should account for this being set
8271 * at some point in the future.
8272 *
8273 * Qlogic WWNs have an NAA of 2, but usually nothing shows up in
8274 * bits 48..60. In the case of the 2202, it appears that they do
8275 * use bit 48 to distinguish between the two instances on the card.
8276 * The 2204, which I've never seen, *probably* extends this method.
8277 */
8278 wwn = ISP2100_NVRAM_PORT_NAME(nvram_data);
8279 if (wwn) {
8280 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Port WWN 0x%08x%08x",
7921 (uint32_t) (wwn >> 32), (uint32_t) (wwn & 0xffffffff));
8281 (uint32_t) (wwn >> 32), (uint32_t) (wwn));
7922 if ((wwn >> 60) == 0) {
7923 wwn |= (((uint64_t) 2)<< 60);
7924 }
7925 }
7926 fcp->isp_wwpn_nvram = wwn;
7927 if (IS_2200(isp) || IS_23XX(isp)) {
7928 wwn = ISP2100_NVRAM_NODE_NAME(nvram_data);
7929 if (wwn) {
7930 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Node WWN 0x%08x%08x",
7931 (uint32_t) (wwn >> 32),
8282 if ((wwn >> 60) == 0) {
8283 wwn |= (((uint64_t) 2)<< 60);
8284 }
8285 }
8286 fcp->isp_wwpn_nvram = wwn;
8287 if (IS_2200(isp) || IS_23XX(isp)) {
8288 wwn = ISP2100_NVRAM_NODE_NAME(nvram_data);
8289 if (wwn) {
8290 isp_prt(isp, ISP_LOGCONFIG, "NVRAM Node WWN 0x%08x%08x",
8291 (uint32_t) (wwn >> 32),
7932 (uint32_t) (wwn & 0xffffffff));
8292 (uint32_t) (wwn));
7933 if ((wwn >> 60) == 0) {
7934 wwn |= (((uint64_t) 2)<< 60);
7935 }
7936 }
7937 } else {
7938 wwn &= ~((uint64_t) 0xfff << 48);
7939 }
7940 fcp->isp_wwnn_nvram = wwn;
7941
8293 if ((wwn >> 60) == 0) {
8294 wwn |= (((uint64_t) 2)<< 60);
8295 }
8296 }
8297 } else {
8298 wwn &= ~((uint64_t) 0xfff << 48);
8299 }
8300 fcp->isp_wwnn_nvram = wwn;
8301
7942 isp_fix_nvram_wwns(isp);
7943
7944 fcp->isp_maxalloc = ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data);
7945 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
8302 fcp->isp_maxalloc = ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data);
8303 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
7946 fcp->isp_maxfrmlen = ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data);
8304 DEFAULT_FRAMESIZE(isp) =
8305 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data);
7947 }
7948 fcp->isp_retry_delay = ISP2100_NVRAM_RETRY_DELAY(nvram_data);
7949 fcp->isp_retry_count = ISP2100_NVRAM_RETRY_COUNT(nvram_data);
7950 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
7951 fcp->isp_loopid = ISP2100_NVRAM_HARDLOOPID(nvram_data);
7952 }
7953 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0) {
8306 }
8307 fcp->isp_retry_delay = ISP2100_NVRAM_RETRY_DELAY(nvram_data);
8308 fcp->isp_retry_count = ISP2100_NVRAM_RETRY_COUNT(nvram_data);
8309 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
8310 fcp->isp_loopid = ISP2100_NVRAM_HARDLOOPID(nvram_data);
8311 }
8312 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0) {
7954 fcp->isp_execthrottle =
8313 DEFAULT_EXEC_THROTTLE(isp) =
7955 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data);
7956 }
7957 fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data);
7958 isp_prt(isp, ISP_LOGDEBUG0,
7959 "NVRAM 0x%08x%08x 0x%08x%08x maxalloc %d maxframelen %d",
8314 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data);
8315 }
8316 fcp->isp_fwoptions = ISP2100_NVRAM_OPTIONS(nvram_data);
8317 isp_prt(isp, ISP_LOGDEBUG0,
8318 "NVRAM 0x%08x%08x 0x%08x%08x maxalloc %d maxframelen %d",
7960 (uint32_t) (fcp->isp_wwnn_nvram >> 32), (uint32_t) fcp->isp_wwnn_nvram,
7961 (uint32_t) (fcp->isp_wwpn_nvram >> 32), (uint32_t) fcp->isp_wwpn_nvram,
8319 (uint32_t) (fcp->isp_wwnn_nvram >> 32),
8320 (uint32_t) fcp->isp_wwnn_nvram,
8321 (uint32_t) (fcp->isp_wwpn_nvram >> 32),
8322 (uint32_t) fcp->isp_wwpn_nvram,
7962 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data),
7963 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data));
7964 isp_prt(isp, ISP_LOGDEBUG0,
7965 "execthrottle %d fwoptions 0x%x hardloop %d tov %d",
7966 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data),
7967 ISP2100_NVRAM_OPTIONS(nvram_data),
7968 ISP2100_NVRAM_HARDLOOPID(nvram_data),
7969 ISP2100_NVRAM_TOV(nvram_data));
7970 fcp->isp_xfwoptions = ISP2100_XFW_OPTIONS(nvram_data);
7971 fcp->isp_zfwoptions = ISP2100_ZFW_OPTIONS(nvram_data);
7972 isp_prt(isp, ISP_LOGDEBUG0,
7973 "xfwoptions 0x%x zfw options 0x%x",
7974 ISP2100_XFW_OPTIONS(nvram_data), ISP2100_ZFW_OPTIONS(nvram_data));
7975}
7976
7977static void
7978isp_parse_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
7979{
8323 ISP2100_NVRAM_MAXIOCBALLOCATION(nvram_data),
8324 ISP2100_NVRAM_MAXFRAMELENGTH(nvram_data));
8325 isp_prt(isp, ISP_LOGDEBUG0,
8326 "execthrottle %d fwoptions 0x%x hardloop %d tov %d",
8327 ISP2100_NVRAM_EXECUTION_THROTTLE(nvram_data),
8328 ISP2100_NVRAM_OPTIONS(nvram_data),
8329 ISP2100_NVRAM_HARDLOOPID(nvram_data),
8330 ISP2100_NVRAM_TOV(nvram_data));
8331 fcp->isp_xfwoptions = ISP2100_XFW_OPTIONS(nvram_data);
8332 fcp->isp_zfwoptions = ISP2100_ZFW_OPTIONS(nvram_data);
8333 isp_prt(isp, ISP_LOGDEBUG0,
8334 "xfwoptions 0x%x zfw options 0x%x",
8335 ISP2100_XFW_OPTIONS(nvram_data), ISP2100_ZFW_OPTIONS(nvram_data));
8336}
8337
8338static void
8339isp_parse_nvram_2400(ispsoftc_t *isp, uint8_t *nvram_data)
8340{
7980 fcparam *fcp = FCPARAM(isp);
8341 fcparam *fcp = FCPARAM(isp, 0);
7981 uint64_t wwn;
7982
7983 isp_prt(isp, ISP_LOGDEBUG0,
7984 "NVRAM 0x%08x%08x 0x%08x%08x exchg_cnt %d maxframelen %d",
7985 (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data) >> 32),
7986 (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data)),
7987 (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data) >> 32),
7988 (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data)),

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

8007 wwn = ISP2400_NVRAM_NODE_NAME(nvram_data);
8008 if (wwn) {
8009 if ((wwn >> 60) != 2 && (wwn >> 60) != 5) {
8010 wwn = 0;
8011 }
8012 }
8013 fcp->isp_wwnn_nvram = wwn;
8014
8342 uint64_t wwn;
8343
8344 isp_prt(isp, ISP_LOGDEBUG0,
8345 "NVRAM 0x%08x%08x 0x%08x%08x exchg_cnt %d maxframelen %d",
8346 (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data) >> 32),
8347 (uint32_t) (ISP2400_NVRAM_NODE_NAME(nvram_data)),
8348 (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data) >> 32),
8349 (uint32_t) (ISP2400_NVRAM_PORT_NAME(nvram_data)),

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

8368 wwn = ISP2400_NVRAM_NODE_NAME(nvram_data);
8369 if (wwn) {
8370 if ((wwn >> 60) != 2 && (wwn >> 60) != 5) {
8371 wwn = 0;
8372 }
8373 }
8374 fcp->isp_wwnn_nvram = wwn;
8375
8015 isp_fix_nvram_wwns(isp);
8016
8017 if (ISP2400_NVRAM_EXCHANGE_COUNT(nvram_data)) {
8018 fcp->isp_maxalloc = ISP2400_NVRAM_EXCHANGE_COUNT(nvram_data);
8019 }
8020 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
8376 if (ISP2400_NVRAM_EXCHANGE_COUNT(nvram_data)) {
8377 fcp->isp_maxalloc = ISP2400_NVRAM_EXCHANGE_COUNT(nvram_data);
8378 }
8379 if ((isp->isp_confopts & ISP_CFG_OWNFSZ) == 0) {
8021 fcp->isp_maxfrmlen = ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data);
8380 DEFAULT_FRAMESIZE(isp) =
8381 ISP2400_NVRAM_MAXFRAMELENGTH(nvram_data);
8022 }
8023 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
8024 fcp->isp_loopid = ISP2400_NVRAM_HARDLOOPID(nvram_data);
8025 }
8026 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0) {
8382 }
8383 if ((isp->isp_confopts & ISP_CFG_OWNLOOPID) == 0) {
8384 fcp->isp_loopid = ISP2400_NVRAM_HARDLOOPID(nvram_data);
8385 }
8386 if ((isp->isp_confopts & ISP_CFG_OWNEXCTHROTTLE) == 0) {
8027 fcp->isp_execthrottle =
8387 DEFAULT_EXEC_THROTTLE(isp) =
8028 ISP2400_NVRAM_EXECUTION_THROTTLE(nvram_data);
8029 }
8030 fcp->isp_fwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data);
8031 fcp->isp_xfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data);
8032 fcp->isp_zfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data);
8033}
8388 ISP2400_NVRAM_EXECUTION_THROTTLE(nvram_data);
8389 }
8390 fcp->isp_fwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS1(nvram_data);
8391 fcp->isp_xfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS2(nvram_data);
8392 fcp->isp_zfwoptions = ISP2400_NVRAM_FIRMWARE_OPTIONS3(nvram_data);
8393}
8034
8035#ifdef ISP_FW_CRASH_DUMP
8036static void isp2200_fw_dump(ispsoftc_t *);
8037static void isp2300_fw_dump(ispsoftc_t *);
8038
8039static void
8040isp2200_fw_dump(ispsoftc_t *isp)
8041{
8042 int i, j;
8043 mbreg_t mbs;
8044 uint16_t *ptr;
8045
8046 MEMZERO(&mbs, sizeof (mbs));
8047 ptr = FCPARAM(isp)->isp_dump_data;
8048 if (ptr == NULL) {
8049 isp_prt(isp, ISP_LOGERR,
8050 "No place to dump RISC registers and SRAM");
8051 return;
8052 }
8053 if (*ptr++) {
8054 isp_prt(isp, ISP_LOGERR,
8055 "dump area for RISC registers and SRAM already used");
8056 return;
8057 }
8058 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
8059 for (i = 0; i < 100; i++) {
8060 USEC_DELAY(100);
8061 if (ISP_READ(isp, HCCR) & HCCR_PAUSE) {
8062 break;
8063 }
8064 }
8065 if (ISP_READ(isp, HCCR) & HCCR_PAUSE) {
8066 /*
8067 * PBIU Registers
8068 */
8069 for (i = 0; i < 8; i++) {
8070 *ptr++ = ISP_READ(isp, BIU_BLOCK + (i << 1));
8071 }
8072
8073 /*
8074 * Mailbox Registers
8075 */
8076 for (i = 0; i < 8; i++) {
8077 *ptr++ = ISP_READ(isp, MBOX_BLOCK + (i << 1));
8078 }
8079
8080 /*
8081 * DMA Registers
8082 */
8083 for (i = 0; i < 48; i++) {
8084 *ptr++ = ISP_READ(isp, DMA_BLOCK + 0x20 + (i << 1));
8085 }
8086
8087 /*
8088 * RISC H/W Registers
8089 */
8090 ISP_WRITE(isp, BIU2100_CSR, 0);
8091 for (i = 0; i < 16; i++) {
8092 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0xA0 + (i << 1));
8093 }
8094
8095 /*
8096 * RISC GP Registers
8097 */
8098 for (j = 0; j < 8; j++) {
8099 ISP_WRITE(isp, BIU_BLOCK + 0xA4, 0x2000 + (j << 8));
8100 for (i = 0; i < 16; i++) {
8101 *ptr++ =
8102 ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8103 }
8104 }
8105
8106 /*
8107 * Frame Buffer Hardware Registers
8108 */
8109 ISP_WRITE(isp, BIU2100_CSR, 0x10);
8110 for (i = 0; i < 16; i++) {
8111 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8112 }
8113
8114 /*
8115 * Fibre Protocol Module 0 Hardware Registers
8116 */
8117 ISP_WRITE(isp, BIU2100_CSR, 0x20);
8118 for (i = 0; i < 64; i++) {
8119 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8120 }
8121
8122 /*
8123 * Fibre Protocol Module 1 Hardware Registers
8124 */
8125 ISP_WRITE(isp, BIU2100_CSR, 0x30);
8126 for (i = 0; i < 64; i++) {
8127 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8128 }
8129 } else {
8130 isp_prt(isp, ISP_LOGERR, "RISC Would Not Pause");
8131 return;
8132 }
8133 isp_prt(isp, ISP_LOGALL,
8134 "isp_fw_dump: RISC registers dumped successfully");
8135 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
8136 for (i = 0; i < 100; i++) {
8137 USEC_DELAY(100);
8138 if (ISP_READ(isp, OUTMAILBOX0) == 0) {
8139 break;
8140 }
8141 }
8142 if (ISP_READ(isp, OUTMAILBOX0) != 0) {
8143 isp_prt(isp, ISP_LOGERR, "Board Would Not Reset");
8144 return;
8145 }
8146 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
8147 for (i = 0; i < 100; i++) {
8148 USEC_DELAY(100);
8149 if (ISP_READ(isp, HCCR) & HCCR_PAUSE) {
8150 break;
8151 }
8152 }
8153 if ((ISP_READ(isp, HCCR) & HCCR_PAUSE) == 0) {
8154 isp_prt(isp, ISP_LOGERR, "RISC Would Not Pause After Reset");
8155 return;
8156 }
8157 ISP_WRITE(isp, RISC_EMB, 0xf2);
8158 ISP_WRITE(isp, HCCR, HCCR_CMD_RELEASE);
8159 for (i = 0; i < 100; i++) {
8160 USEC_DELAY(100);
8161 if ((ISP_READ(isp, HCCR) & HCCR_PAUSE) == 0) {
8162 break;
8163 }
8164 }
8165 ISP_ENABLE_INTS(isp);
8166 mbs.param[0] = MBOX_READ_RAM_WORD;
8167 mbs.param[1] = 0x1000;
8168 isp->isp_mbxworkp = (void *) ptr;
8169 isp->isp_mbxwrk0 = 0xefff; /* continuation count */
8170 isp->isp_mbxwrk1 = 0x1001; /* next SRAM address */
8171 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
8172 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
8173 isp_prt(isp, ISP_LOGWARN,
8174 "RAM DUMP FAILED @ WORD %x", isp->isp_mbxwrk1);
8175 return;
8176 }
8177 ptr = isp->isp_mbxworkp; /* finish fetch of final word */
8178 *ptr++ = isp->isp_mboxtmp[2];
8179 isp_prt(isp, ISP_LOGALL, "isp_fw_dump: SRAM dumped successfully");
8180 FCPARAM(isp)->isp_dump_data[0] = isp->isp_type; /* now used */
8181 (void) isp_async(isp, ISPASYNC_FW_DUMPED, 0);
8182}
8183
8184static void
8185isp2300_fw_dump(ispsoftc_t *isp)
8186{
8187 int i, j;
8188 mbreg_t mbs;
8189 uint16_t *ptr;
8190
8191 MEMZERO(&mbs, sizeof (mbs));
8192 ptr = FCPARAM(isp)->isp_dump_data;
8193 if (ptr == NULL) {
8194 isp_prt(isp, ISP_LOGERR,
8195 "No place to dump RISC registers and SRAM");
8196 return;
8197 }
8198 if (*ptr++) {
8199 isp_prt(isp, ISP_LOGERR,
8200 "dump area for RISC registers and SRAM already used");
8201 return;
8202 }
8203 ISP_WRITE(isp, HCCR, HCCR_CMD_PAUSE);
8204 for (i = 0; i < 100; i++) {
8205 USEC_DELAY(100);
8206 if (ISP_READ(isp, HCCR) & HCCR_PAUSE) {
8207 break;
8208 }
8209 }
8210 if (ISP_READ(isp, HCCR) & HCCR_PAUSE) {
8211 /*
8212 * PBIU registers
8213 */
8214 for (i = 0; i < 8; i++) {
8215 *ptr++ = ISP_READ(isp, BIU_BLOCK + (i << 1));
8216 }
8217
8218 /*
8219 * ReqQ-RspQ-Risc2Host Status registers
8220 */
8221 for (i = 0; i < 8; i++) {
8222 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x10 + (i << 1));
8223 }
8224
8225 /*
8226 * Mailbox Registers
8227 */
8228 for (i = 0; i < 32; i++) {
8229 *ptr++ =
8230 ISP_READ(isp, PCI_MBOX_REGS2300_OFF + (i << 1));
8231 }
8232
8233 /*
8234 * Auto Request Response DMA registers
8235 */
8236 ISP_WRITE(isp, BIU2100_CSR, 0x40);
8237 for (i = 0; i < 32; i++) {
8238 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8239 }
8240
8241 /*
8242 * DMA registers
8243 */
8244 ISP_WRITE(isp, BIU2100_CSR, 0x50);
8245 for (i = 0; i < 48; i++) {
8246 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8247 }
8248
8249 /*
8250 * RISC hardware registers
8251 */
8252 ISP_WRITE(isp, BIU2100_CSR, 0);
8253 for (i = 0; i < 16; i++) {
8254 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0xA0 + (i << 1));
8255 }
8256
8257 /*
8258 * RISC GP? registers
8259 */
8260 for (j = 0; j < 8; j++) {
8261 ISP_WRITE(isp, BIU_BLOCK + 0xA4, 0x2000 + (j << 9));
8262 for (i = 0; i < 16; i++) {
8263 *ptr++ =
8264 ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8265 }
8266 }
8267
8268 /*
8269 * frame buffer hardware registers
8270 */
8271 ISP_WRITE(isp, BIU2100_CSR, 0x10);
8272 for (i = 0; i < 64; i++) {
8273 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8274 }
8275
8276 /*
8277 * FPM B0 hardware registers
8278 */
8279 ISP_WRITE(isp, BIU2100_CSR, 0x20);
8280 for (i = 0; i < 64; i++) {
8281 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8282 }
8283
8284 /*
8285 * FPM B1 hardware registers
8286 */
8287 ISP_WRITE(isp, BIU2100_CSR, 0x30);
8288 for (i = 0; i < 64; i++) {
8289 *ptr++ = ISP_READ(isp, BIU_BLOCK + 0x80 + (i << 1));
8290 }
8291 } else {
8292 isp_prt(isp, ISP_LOGERR, "RISC Would Not Pause");
8293 return;
8294 }
8295 isp_prt(isp, ISP_LOGALL,
8296 "isp_fw_dump: RISC registers dumped successfully");
8297 ISP_WRITE(isp, BIU2100_CSR, BIU2100_SOFT_RESET);
8298 for (i = 0; i < 100; i++) {
8299 USEC_DELAY(100);
8300 if (ISP_READ(isp, OUTMAILBOX0) == 0) {
8301 break;
8302 }
8303 }
8304 if (ISP_READ(isp, OUTMAILBOX0) != 0) {
8305 isp_prt(isp, ISP_LOGERR, "Board Would Not Reset");
8306 return;
8307 }
8308 ISP_ENABLE_INTS(isp);
8309 MEMZERO(&mbs, sizeof (mbs));
8310 mbs.param[0] = MBOX_READ_RAM_WORD;
8311 mbs.param[1] = 0x800;
8312 isp->isp_mbxworkp = (void *) ptr;
8313 isp->isp_mbxwrk0 = 0xf7ff; /* continuation count */
8314 isp->isp_mbxwrk1 = 0x801; /* next SRAM address */
8315 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
8316 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
8317 isp_prt(isp, ISP_LOGWARN,
8318 "RAM DUMP FAILED @ WORD %x", isp->isp_mbxwrk1);
8319 return;
8320 }
8321 ptr = isp->isp_mbxworkp; /* finish fetch of final word */
8322 *ptr++ = isp->isp_mboxtmp[2];
8323 MEMZERO(&mbs, sizeof (mbs));
8324 mbs.param[0] = MBOX_READ_RAM_WORD_EXTENDED;
8325 mbs.param[8] = 1;
8326 isp->isp_mbxworkp = (void *) ptr;
8327 isp->isp_mbxwrk0 = 0xffff; /* continuation count */
8328 isp->isp_mbxwrk1 = 0x1; /* next SRAM address */
8329 isp->isp_mbxwrk8 = 0x1;
8330 isp_control(isp, ISPCTL_RUN_MBOXCMD, &mbs);
8331 if (mbs.param[0] != MBOX_COMMAND_COMPLETE) {
8332 isp_prt(isp, ISP_LOGWARN,
8333 "RAM DUMP FAILED @ WORD %x", 0x10000 + isp->isp_mbxwrk1);
8334 return;
8335 }
8336 ptr = isp->isp_mbxworkp; /* finish final word */
8337 *ptr++ = mbs.param[2];
8338 isp_prt(isp, ISP_LOGALL, "isp_fw_dump: SRAM dumped successfully");
8339 FCPARAM(isp)->isp_dump_data[0] = isp->isp_type; /* now used */
8340 (void) isp_async(isp, ISPASYNC_FW_DUMPED, 0);
8341}
8342
8343void
8344isp_fw_dump(ispsoftc_t *isp)
8345{
8346 if (IS_2200(isp))
8347 isp2200_fw_dump(isp);
8348 else if (IS_23XX(isp))
8349 isp2300_fw_dump(isp);
8350 else if (IS_24XX(isp))
8351 isp_prt(isp, ISP_LOGERR, "24XX dump method undefined");
8352
8353}
8354#endif