isp_target.c (140651) | isp_target.c (154704) |
---|---|
1/* $FreeBSD: head/sys/dev/isp/isp_target.c 140651 2005-01-23 06:28:08Z mjacob $ */ | |
2/*- 3 * Machine and OS Independent Target Mode Code for the Qlogic SCSI/FC adapters. 4 * | 1/*- 2 * Machine and OS Independent Target Mode Code for the Qlogic SCSI/FC adapters. 3 * |
5 * Copyright (c) 1999, 2000, 2001 by Matthew Jacob | 4 * Copyright (c) 1997-2006 by Matthew Jacob |
6 * All rights reserved. | 5 * All rights reserved. |
7 * mjacob@feral.com | |
8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice immediately at the beginning of the file, without modification, 14 * this list of conditions, and the following disclaimer. 15 * 2. The name of the author may not be used to endorse or promote products --- 19 unchanged lines hidden (view full) --- 35/* 36 * Include header file appropriate for platform we're building on. 37 */ 38 39#ifdef __NetBSD__ 40#include <dev/ic/isp_netbsd.h> 41#endif 42#ifdef __FreeBSD__ | 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice immediately at the beginning of the file, without modification, 12 * this list of conditions, and the following disclaimer. 13 * 2. The name of the author may not be used to endorse or promote products --- 19 unchanged lines hidden (view full) --- 33/* 34 * Include header file appropriate for platform we're building on. 35 */ 36 37#ifdef __NetBSD__ 38#include <dev/ic/isp_netbsd.h> 39#endif 40#ifdef __FreeBSD__ |
41#include <sys/cdefs.h> 42__FBSDID("$FreeBSD: head/sys/dev/isp/isp_target.c 154704 2006-01-23 06:23:37Z mjacob $"); 43 |
|
43#include <dev/isp/isp_freebsd.h> 44#endif 45#ifdef __OpenBSD__ 46#include <dev/ic/isp_openbsd.h> 47#endif 48#ifdef __linux__ 49#include "isp_linux.h" 50#endif 51 52#ifdef ISP_TARGET_MODE 53static const char atiocope[] = 54 "ATIO returned for lun %d because it was in the middle of Bus Device Reset " 55 "on bus %d"; 56static const char atior[] = 57 "ATIO returned on for lun %d on from IID %d because a Bus Reset occurred " 58 "on bus %d"; 59 | 44#include <dev/isp/isp_freebsd.h> 45#endif 46#ifdef __OpenBSD__ 47#include <dev/ic/isp_openbsd.h> 48#endif 49#ifdef __linux__ 50#include "isp_linux.h" 51#endif 52 53#ifdef ISP_TARGET_MODE 54static const char atiocope[] = 55 "ATIO returned for lun %d because it was in the middle of Bus Device Reset " 56 "on bus %d"; 57static const char atior[] = 58 "ATIO returned on for lun %d on from IID %d because a Bus Reset occurred " 59 "on bus %d"; 60 |
60static void isp_got_msg(struct ispsoftc *, int, in_entry_t *); 61static void isp_got_msg_fc(struct ispsoftc *, int, in_fcentry_t *); 62static void isp_notify_ack(struct ispsoftc *, void *); | 61static void isp_got_msg(struct ispsoftc *, in_entry_t *); 62static void isp_got_msg_fc(struct ispsoftc *, in_fcentry_t *); |
63static void isp_handle_atio(struct ispsoftc *, at_entry_t *); 64static void isp_handle_atio2(struct ispsoftc *, at2_entry_t *); 65static void isp_handle_ctio(struct ispsoftc *, ct_entry_t *); 66static void isp_handle_ctio2(struct ispsoftc *, ct2_entry_t *); 67 68/* 69 * The Qlogic driver gets an interrupt to look at response queue entries. 70 * Some of these are status completions for initiatior mode commands, but --- 42 unchanged lines hidden (view full) --- 113 114int 115isp_target_notify(struct ispsoftc *isp, void *vptr, u_int16_t *optrp) 116{ 117 u_int16_t status, seqid; 118 union { 119 at_entry_t *atiop; 120 at2_entry_t *at2iop; | 63static void isp_handle_atio(struct ispsoftc *, at_entry_t *); 64static void isp_handle_atio2(struct ispsoftc *, at2_entry_t *); 65static void isp_handle_ctio(struct ispsoftc *, ct_entry_t *); 66static void isp_handle_ctio2(struct ispsoftc *, ct2_entry_t *); 67 68/* 69 * The Qlogic driver gets an interrupt to look at response queue entries. 70 * Some of these are status completions for initiatior mode commands, but --- 42 unchanged lines hidden (view full) --- 113 114int 115isp_target_notify(struct ispsoftc *isp, void *vptr, u_int16_t *optrp) 116{ 117 u_int16_t status, seqid; 118 union { 119 at_entry_t *atiop; 120 at2_entry_t *at2iop; |
121 at2e_entry_t *at2eiop; |
|
121 ct_entry_t *ctiop; 122 ct2_entry_t *ct2iop; | 122 ct_entry_t *ctiop; 123 ct2_entry_t *ct2iop; |
124 ct2e_entry_t *ct2eiop; |
|
123 lun_entry_t *lunenp; 124 in_entry_t *inotp; 125 in_fcentry_t *inot_fcp; | 125 lun_entry_t *lunenp; 126 in_entry_t *inotp; 127 in_fcentry_t *inot_fcp; |
128 in_fcentry_e_t *inote_fcp; |
|
126 na_entry_t *nackp; 127 na_fcentry_t *nack_fcp; | 129 na_entry_t *nackp; 130 na_fcentry_t *nack_fcp; |
131 na_fcentry_e_t *nacke_fcp; |
|
128 isphdr_t *hp; 129 void * *vp; 130#define atiop unp.atiop 131#define at2iop unp.at2iop | 132 isphdr_t *hp; 133 void * *vp; 134#define atiop unp.atiop 135#define at2iop unp.at2iop |
136#define at2eiop unp.at2eiop |
|
132#define ctiop unp.ctiop 133#define ct2iop unp.ct2iop | 137#define ctiop unp.ctiop 138#define ct2iop unp.ct2iop |
139#define ct2eiop unp.ct2eiop |
|
134#define lunenp unp.lunenp 135#define inotp unp.inotp 136#define inot_fcp unp.inot_fcp | 140#define lunenp unp.lunenp 141#define inotp unp.inotp 142#define inot_fcp unp.inot_fcp |
143#define inote_fcp unp.inote_fcp |
|
137#define nackp unp.nackp 138#define nack_fcp unp.nack_fcp | 144#define nackp unp.nackp 145#define nack_fcp unp.nack_fcp |
146#define nacke_fcp unp.nacke_fcp |
|
139#define hdrp unp.hp 140 } unp; 141 u_int8_t local[QENTRY_LEN]; 142 int bus, type, rval = 1; 143 144 type = isp_get_response_type(isp, (isphdr_t *)vptr); 145 unp.vp = vptr; 146 --- 4 unchanged lines hidden (view full) --- 151 isp_get_atio(isp, atiop, (at_entry_t *) local); 152 isp_handle_atio(isp, (at_entry_t *) local); 153 break; 154 case RQSTYPE_CTIO: 155 isp_get_ctio(isp, ctiop, (ct_entry_t *) local); 156 isp_handle_ctio(isp, (ct_entry_t *) local); 157 break; 158 case RQSTYPE_ATIO2: | 147#define hdrp unp.hp 148 } unp; 149 u_int8_t local[QENTRY_LEN]; 150 int bus, type, rval = 1; 151 152 type = isp_get_response_type(isp, (isphdr_t *)vptr); 153 unp.vp = vptr; 154 --- 4 unchanged lines hidden (view full) --- 159 isp_get_atio(isp, atiop, (at_entry_t *) local); 160 isp_handle_atio(isp, (at_entry_t *) local); 161 break; 162 case RQSTYPE_CTIO: 163 isp_get_ctio(isp, ctiop, (ct_entry_t *) local); 164 isp_handle_ctio(isp, (ct_entry_t *) local); 165 break; 166 case RQSTYPE_ATIO2: |
159 isp_get_atio2(isp, at2iop, (at2_entry_t *) local); | 167 if (IS_2KLOGIN(isp)) 168 isp_get_atio2e(isp, at2eiop, (at2e_entry_t *) local); 169 else 170 isp_get_atio2(isp, at2iop, (at2_entry_t *) local); |
160 isp_handle_atio2(isp, (at2_entry_t *) local); 161 break; 162 case RQSTYPE_CTIO3: 163 case RQSTYPE_CTIO2: | 171 isp_handle_atio2(isp, (at2_entry_t *) local); 172 break; 173 case RQSTYPE_CTIO3: 174 case RQSTYPE_CTIO2: |
164 isp_get_ctio2(isp, ct2iop, (ct2_entry_t *) local); | 175 if (IS_2KLOGIN(isp)) 176 isp_get_ctio2e(isp, ct2eiop, (ct2e_entry_t *) local); 177 else 178 isp_get_ctio2(isp, ct2iop, (ct2_entry_t *) local); |
165 isp_handle_ctio2(isp, (ct2_entry_t *) local); 166 break; 167 case RQSTYPE_ENABLE_LUN: 168 case RQSTYPE_MODIFY_LUN: 169 isp_get_enable_lun(isp, lunenp, (lun_entry_t *) local); 170 (void) isp_async(isp, ISPASYNC_TARGET_ACTION, local); 171 break; 172 173 case RQSTYPE_NOTIFY: 174 /* 175 * Either the ISP received a SCSI message it can't 176 * handle, or it's returning an Immed. Notify entry 177 * we sent. We can send Immed. Notify entries to 178 * increment the firmware's resource count for them 179 * (we set this initially in the Enable Lun entry). 180 */ 181 bus = 0; 182 if (IS_FC(isp)) { | 179 isp_handle_ctio2(isp, (ct2_entry_t *) local); 180 break; 181 case RQSTYPE_ENABLE_LUN: 182 case RQSTYPE_MODIFY_LUN: 183 isp_get_enable_lun(isp, lunenp, (lun_entry_t *) local); 184 (void) isp_async(isp, ISPASYNC_TARGET_ACTION, local); 185 break; 186 187 case RQSTYPE_NOTIFY: 188 /* 189 * Either the ISP received a SCSI message it can't 190 * handle, or it's returning an Immed. Notify entry 191 * we sent. We can send Immed. Notify entries to 192 * increment the firmware's resource count for them 193 * (we set this initially in the Enable Lun entry). 194 */ 195 bus = 0; 196 if (IS_FC(isp)) { |
183 isp_get_notify_fc(isp, inot_fcp, (in_fcentry_t *)local); | 197 if (IS_2KLOGIN(isp)) 198 isp_get_notify_fc_e(isp, inote_fcp, (in_fcentry_e_t *)local); 199 isp_get_notify_fc(isp, inot_fcp, (in_fcentry_t *)local); |
184 inot_fcp = (in_fcentry_t *) local; 185 status = inot_fcp->in_status; 186 seqid = inot_fcp->in_seqid; 187 } else { 188 isp_get_notify(isp, inotp, (in_entry_t *)local); 189 inotp = (in_entry_t *) local; 190 status = inotp->in_status & 0xff; 191 seqid = inotp->in_seqid; 192 if (IS_DUALBUS(isp)) { 193 bus = GET_BUS_VAL(inotp->in_iid); 194 SET_BUS_VAL(inotp->in_iid, 0); 195 } 196 } 197 isp_prt(isp, ISP_LOGTDEBUG0, 198 "Immediate Notify On Bus %d, status=0x%x seqid=0x%x", 199 bus, status, seqid); 200 | 200 inot_fcp = (in_fcentry_t *) local; 201 status = inot_fcp->in_status; 202 seqid = inot_fcp->in_seqid; 203 } else { 204 isp_get_notify(isp, inotp, (in_entry_t *)local); 205 inotp = (in_entry_t *) local; 206 status = inotp->in_status & 0xff; 207 seqid = inotp->in_seqid; 208 if (IS_DUALBUS(isp)) { 209 bus = GET_BUS_VAL(inotp->in_iid); 210 SET_BUS_VAL(inotp->in_iid, 0); 211 } 212 } 213 isp_prt(isp, ISP_LOGTDEBUG0, 214 "Immediate Notify On Bus %d, status=0x%x seqid=0x%x", 215 bus, status, seqid); 216 |
201 /* 202 * ACK it right away. 203 */ 204 isp_notify_ack(isp, (status == IN_RESET)? NULL : local); | |
205 switch (status) { | 217 switch (status) { |
206 case IN_RESET: 207 (void) isp_async(isp, ISPASYNC_BUS_RESET, &bus); 208 break; | |
209 case IN_MSG_RECEIVED: 210 case IN_IDE_RECEIVED: 211 if (IS_FC(isp)) { | 218 case IN_MSG_RECEIVED: 219 case IN_IDE_RECEIVED: 220 if (IS_FC(isp)) { |
212 isp_got_msg_fc(isp, bus, (in_fcentry_t *)local); | 221 isp_got_msg_fc(isp, (in_fcentry_t *)local); |
213 } else { | 222 } else { |
214 isp_got_msg(isp, bus, (in_entry_t *)local); | 223 isp_got_msg(isp, (in_entry_t *)local); |
215 } 216 break; 217 case IN_RSRC_UNAVAIL: 218 isp_prt(isp, ISP_LOGWARN, "Firmware out of ATIOs"); | 224 } 225 break; 226 case IN_RSRC_UNAVAIL: 227 isp_prt(isp, ISP_LOGWARN, "Firmware out of ATIOs"); |
228 isp_notify_ack(isp, local); |
|
219 break; | 229 break; |
230 case IN_RESET: 231 isp_target_async(isp, 0, ASYNC_BUS_RESET); 232 break; |
|
220 case IN_PORT_LOGOUT: 221 case IN_ABORT_TASK: 222 case IN_PORT_CHANGED: 223 case IN_GLOBAL_LOGO: 224 (void) isp_async(isp, ISPASYNC_TARGET_ACTION, &local); 225 break; 226 default: 227 isp_prt(isp, ISP_LOGERR, 228 "bad status (0x%x) in isp_target_notify", status); | 233 case IN_PORT_LOGOUT: 234 case IN_ABORT_TASK: 235 case IN_PORT_CHANGED: 236 case IN_GLOBAL_LOGO: 237 (void) isp_async(isp, ISPASYNC_TARGET_ACTION, &local); 238 break; 239 default: 240 isp_prt(isp, ISP_LOGERR, 241 "bad status (0x%x) in isp_target_notify", status); |
242 isp_notify_ack(isp, local); |
|
229 break; 230 } 231 break; 232 233 case RQSTYPE_NOTIFY_ACK: 234 /* 235 * The ISP is acknowledging our acknowledgement of an 236 * Immediate Notify entry for some asynchronous event. 237 */ 238 if (IS_FC(isp)) { | 243 break; 244 } 245 break; 246 247 case RQSTYPE_NOTIFY_ACK: 248 /* 249 * The ISP is acknowledging our acknowledgement of an 250 * Immediate Notify entry for some asynchronous event. 251 */ 252 if (IS_FC(isp)) { |
239 isp_get_notify_ack_fc(isp, nack_fcp, 240 (na_fcentry_t *)local); | 253 if (IS_2KLOGIN(isp)) 254 isp_get_notify_ack_fc_e(isp, nacke_fcp, 255 (na_fcentry_e_t *)local); 256 else 257 isp_get_notify_ack_fc(isp, nack_fcp, 258 (na_fcentry_t *)local); |
241 nack_fcp = (na_fcentry_t *)local; 242 isp_prt(isp, ISP_LOGTDEBUG1, 243 "Notify Ack status=0x%x seqid 0x%x", 244 nack_fcp->na_status, nack_fcp->na_seqid); 245 } else { 246 isp_get_notify_ack(isp, nackp, (na_entry_t *)local); 247 nackp = (na_entry_t *)local; 248 isp_prt(isp, ISP_LOGTDEBUG1, --- 4 unchanged lines hidden (view full) --- 253 default: 254 isp_prt(isp, ISP_LOGERR, 255 "Unknown entry type 0x%x in isp_target_notify", type); 256 rval = 0; 257 break; 258 } 259#undef atiop 260#undef at2iop | 259 nack_fcp = (na_fcentry_t *)local; 260 isp_prt(isp, ISP_LOGTDEBUG1, 261 "Notify Ack status=0x%x seqid 0x%x", 262 nack_fcp->na_status, nack_fcp->na_seqid); 263 } else { 264 isp_get_notify_ack(isp, nackp, (na_entry_t *)local); 265 nackp = (na_entry_t *)local; 266 isp_prt(isp, ISP_LOGTDEBUG1, --- 4 unchanged lines hidden (view full) --- 271 default: 272 isp_prt(isp, ISP_LOGERR, 273 "Unknown entry type 0x%x in isp_target_notify", type); 274 rval = 0; 275 break; 276 } 277#undef atiop 278#undef at2iop |
279#undef at2eiop |
|
261#undef ctiop 262#undef ct2iop | 280#undef ctiop 281#undef ct2iop |
282#undef ct2eiop |
|
263#undef lunenp 264#undef inotp 265#undef inot_fcp | 283#undef lunenp 284#undef inotp 285#undef inot_fcp |
286#undef inote_fcp |
|
266#undef nackp 267#undef nack_fcp | 287#undef nackp 288#undef nack_fcp |
289#undef nacke_fcp |
|
268#undef hdrp 269 return (rval); 270} 271 272 273/* 274 * Toggle (on/off) target mode for bus/target/lun 275 * --- 94 unchanged lines hidden (view full) --- 370} 371 372int 373isp_target_put_atio(struct ispsoftc *isp, void *arg) 374{ 375 union { 376 at_entry_t _atio; 377 at2_entry_t _atio2; | 290#undef hdrp 291 return (rval); 292} 293 294 295/* 296 * Toggle (on/off) target mode for bus/target/lun 297 * --- 94 unchanged lines hidden (view full) --- 392} 393 394int 395isp_target_put_atio(struct ispsoftc *isp, void *arg) 396{ 397 union { 398 at_entry_t _atio; 399 at2_entry_t _atio2; |
400 at2e_entry_t _atio2e; |
|
378 } atun; 379 380 MEMZERO(&atun, sizeof atun); 381 if (IS_FC(isp)) { 382 at2_entry_t *aep = arg; 383 atun._atio2.at_header.rqs_entry_type = RQSTYPE_ATIO2; 384 atun._atio2.at_header.rqs_entry_count = 1; 385 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { 386 atun._atio2.at_scclun = (u_int16_t) aep->at_scclun; 387 } else { 388 atun._atio2.at_lun = (u_int8_t) aep->at_lun; 389 } | 401 } atun; 402 403 MEMZERO(&atun, sizeof atun); 404 if (IS_FC(isp)) { 405 at2_entry_t *aep = arg; 406 atun._atio2.at_header.rqs_entry_type = RQSTYPE_ATIO2; 407 atun._atio2.at_header.rqs_entry_count = 1; 408 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { 409 atun._atio2.at_scclun = (u_int16_t) aep->at_scclun; 410 } else { 411 atun._atio2.at_lun = (u_int8_t) aep->at_lun; 412 } |
390 atun._atio2.at_iid = aep->at_iid; | 413 if (IS_2KLOGIN(isp)) { 414 atun._atio2e.at_iid = ((at2e_entry_t *)aep)->at_iid; 415 } else { 416 atun._atio2.at_iid = aep->at_iid; 417 } |
391 atun._atio2.at_rxid = aep->at_rxid; 392 atun._atio2.at_status = CT_OK; 393 } else { 394 at_entry_t *aep = arg; 395 atun._atio.at_header.rqs_entry_type = RQSTYPE_ATIO; 396 atun._atio.at_header.rqs_entry_count = 1; 397 atun._atio.at_handle = aep->at_handle; 398 atun._atio.at_iid = aep->at_iid; --- 27 unchanged lines hidden (view full) --- 426 427int 428isp_endcmd(struct ispsoftc *isp, void *arg, u_int32_t code, u_int16_t hdl) 429{ 430 int sts; 431 union { 432 ct_entry_t _ctio; 433 ct2_entry_t _ctio2; | 418 atun._atio2.at_rxid = aep->at_rxid; 419 atun._atio2.at_status = CT_OK; 420 } else { 421 at_entry_t *aep = arg; 422 atun._atio.at_header.rqs_entry_type = RQSTYPE_ATIO; 423 atun._atio.at_header.rqs_entry_count = 1; 424 atun._atio.at_handle = aep->at_handle; 425 atun._atio.at_iid = aep->at_iid; --- 27 unchanged lines hidden (view full) --- 453 454int 455isp_endcmd(struct ispsoftc *isp, void *arg, u_int32_t code, u_int16_t hdl) 456{ 457 int sts; 458 union { 459 ct_entry_t _ctio; 460 ct2_entry_t _ctio2; |
461 ct2e_entry_t _ctio2e; |
|
434 } un; 435 436 MEMZERO(&un, sizeof un); 437 sts = code & 0xff; 438 439 if (IS_FC(isp)) { 440 at2_entry_t *aep = arg; 441 ct2_entry_t *cto = &un._ctio2; 442 443 cto->ct_header.rqs_entry_type = RQSTYPE_CTIO2; 444 cto->ct_header.rqs_entry_count = 1; | 462 } un; 463 464 MEMZERO(&un, sizeof un); 465 sts = code & 0xff; 466 467 if (IS_FC(isp)) { 468 at2_entry_t *aep = arg; 469 ct2_entry_t *cto = &un._ctio2; 470 471 cto->ct_header.rqs_entry_type = RQSTYPE_CTIO2; 472 cto->ct_header.rqs_entry_count = 1; |
445 cto->ct_iid = aep->at_iid; | |
446 if ((FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) == 0) { 447 cto->ct_lun = aep->at_lun; 448 } | 473 if ((FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) == 0) { 474 cto->ct_lun = aep->at_lun; 475 } |
476 if (IS_2KLOGIN(isp)) { 477 un._ctio2e.ct_iid = ((at2e_entry_t *)aep)->at_iid; 478 } else { 479 cto->ct_iid = aep->at_iid; 480 } |
|
449 cto->ct_rxid = aep->at_rxid; 450 cto->rsp.m1.ct_scsi_status = sts; 451 cto->ct_flags = CT2_SENDSTATUS | CT2_NO_DATA | CT2_FLAG_MODE1; 452 if (hdl == 0) { 453 cto->ct_flags |= CT2_CCINCR; 454 } 455 if (aep->at_datalen) { 456 cto->ct_resid = aep->at_datalen; --- 32 unchanged lines hidden (view full) --- 489 cto->ct_syshandle = hdl; 490 } 491 return (isp_target_put_entry(isp, &un)); 492} 493 494int 495isp_target_async(struct ispsoftc *isp, int bus, int event) 496{ | 481 cto->ct_rxid = aep->at_rxid; 482 cto->rsp.m1.ct_scsi_status = sts; 483 cto->ct_flags = CT2_SENDSTATUS | CT2_NO_DATA | CT2_FLAG_MODE1; 484 if (hdl == 0) { 485 cto->ct_flags |= CT2_CCINCR; 486 } 487 if (aep->at_datalen) { 488 cto->ct_resid = aep->at_datalen; --- 32 unchanged lines hidden (view full) --- 521 cto->ct_syshandle = hdl; 522 } 523 return (isp_target_put_entry(isp, &un)); 524} 525 526int 527isp_target_async(struct ispsoftc *isp, int bus, int event) 528{ |
497 tmd_event_t evt; 498 tmd_msg_t msg; | 529 tmd_notify_t notify; |
499 | 530 |
531 MEMZERO(¬ify, sizeof (tmd_notify_t)); 532 notify.nt_hba = isp; 533 /* nt_str set in outer layers */ 534 notify.nt_iid = INI_ANY; 535 /* nt_tgt set in outer layers */ 536 notify.nt_lun = LUN_ANY; 537 notify.nt_tagval = TAG_ANY; 538 539 if (IS_SCSI(isp)) { 540 TAG_INSERT_BUS(notify.nt_tagval, bus); 541 } 542 |
|
500 switch (event) { | 543 switch (event) { |
501 /* 502 * These three we handle here to propagate an effective bus reset 503 * upstream, but these do not require any immediate notify actions 504 * so we return when done. 505 */ 506 case ASYNC_LIP_F8: 507 case ASYNC_LIP_OCCURRED: | |
508 case ASYNC_LOOP_UP: | 544 case ASYNC_LOOP_UP: |
545 case ASYNC_PTPMODE: 546 notify.nt_ncode = NT_LINK_UP; 547 (void) isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify); 548 break; |
|
509 case ASYNC_LOOP_DOWN: | 549 case ASYNC_LOOP_DOWN: |
550 notify.nt_ncode = NT_LINK_DOWN; 551 (void) isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify); 552 break; 553 case ASYNC_LIP_F8: 554 case ASYNC_LIP_OCCURRED: |
|
510 case ASYNC_LOOP_RESET: | 555 case ASYNC_LOOP_RESET: |
511 case ASYNC_PTPMODE: 512 /* 513 * These don't require any immediate notify actions. We used 514 * treat them like SCSI Bus Resets, but that was just plain 515 * wrong. Let the normal CTIO completion report what occurred. 516 */ 517 return (0); 518 | 556 notify.nt_ncode = NT_LIP_RESET; 557 (void) isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify); 558 break; |
519 case ASYNC_BUS_RESET: | 559 case ASYNC_BUS_RESET: |
520 case ASYNC_TIMEOUT_RESET: 521 if (IS_FC(isp)) { 522 return (0); /* we'll be getting an inotify instead */ 523 } 524 evt.ev_bus = bus; 525 evt.ev_event = event; 526 (void) isp_async(isp, ISPASYNC_TARGET_EVENT, &evt); | 560 case ASYNC_TIMEOUT_RESET: /* XXX: where does this come from ? */ 561 notify.nt_ncode = NT_BUS_RESET; 562 (void) isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify); |
527 break; 528 case ASYNC_DEVICE_RESET: | 563 break; 564 case ASYNC_DEVICE_RESET: |
529 /* 530 * Bus Device Reset resets a specific target, so 531 * we pass this as a synthesized message. 532 */ 533 MEMZERO(&msg, sizeof msg); | 565 notify.nt_ncode = NT_TARGET_RESET; 566 (void) isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify); 567 break; 568 case ASYNC_CTIO_DONE: 569 { 570 uint8_t storage[QENTRY_LEN]; 571 memset(storage, 0, QENTRY_LEN); |
534 if (IS_FC(isp)) { | 572 if (IS_FC(isp)) { |
535 msg.nt_iid = FCPARAM(isp)->isp_loopid; | 573 ct2_entry_t *ct = (ct2_entry_t *) storage; 574 ct->ct_header.rqs_entry_type = RQSTYPE_CTIO2; 575 ct->ct_status = CT_OK; 576 ct->ct_syshandle = bus; 577 ct->ct_flags = CT2_SENDSTATUS|CT2_FASTPOST; |
536 } else { | 578 } else { |
537 msg.nt_iid = SDPARAM(isp)->isp_initiator_id; | 579 ct_entry_t *ct = (ct_entry_t *) storage; 580 ct->ct_header.rqs_entry_type = RQSTYPE_CTIO; 581 ct->ct_status = CT_OK; 582 ct->ct_fwhandle = bus; 583 ct->ct_flags = CT_SENDSTATUS; |
538 } | 584 } |
539 msg.nt_bus = bus; 540 msg.nt_msg[0] = MSG_BUS_DEV_RESET; 541 (void) isp_async(isp, ISPASYNC_TARGET_MESSAGE, &msg); 542 break; 543 case ASYNC_CTIO_DONE: 544 evt.ev_bus = bus; 545 evt.ev_event = event; 546 (void) isp_async(isp, ISPASYNC_TARGET_EVENT, &evt); | 585 (void) isp_async(isp, ISPASYNC_TARGET_ACTION, storage); |
547 return (0); | 586 return (0); |
587 } |
|
548 default: 549 isp_prt(isp, ISP_LOGERR, 550 "isp_target_async: unknown event 0x%x", event); | 588 default: 589 isp_prt(isp, ISP_LOGERR, 590 "isp_target_async: unknown event 0x%x", event); |
591 if (isp->isp_state == ISP_RUNSTATE) { 592 isp_notify_ack(isp, NULL); 593 } |
|
551 break; 552 } | 594 break; 595 } |
553 if (isp->isp_state == ISP_RUNSTATE) 554 isp_notify_ack(isp, NULL); 555 return(0); | 596 return (0); |
556} 557 558 559/* 560 * Process a received message. 561 * The ISP firmware can handle most messages, there are only 562 * a few that we need to deal with: 563 * - abort: clean up the current command 564 * - abort tag and clear queue 565 */ 566 567static void | 597} 598 599 600/* 601 * Process a received message. 602 * The ISP firmware can handle most messages, there are only 603 * a few that we need to deal with: 604 * - abort: clean up the current command 605 * - abort tag and clear queue 606 */ 607 608static void |
568isp_got_msg(struct ispsoftc *isp, int bus, in_entry_t *inp) | 609isp_got_msg(struct ispsoftc *isp, in_entry_t *inp) |
569{ | 610{ |
611 tmd_notify_t nt; |
|
570 u_int8_t status = inp->in_status & ~QLTM_SVALID; 571 | 612 u_int8_t status = inp->in_status & ~QLTM_SVALID; 613 |
572 if (status == IN_IDE_RECEIVED || status == IN_MSG_RECEIVED) { 573 tmd_msg_t msg; | 614 MEMZERO(&nt, sizeof (nt)); 615 nt.nt_hba = isp; 616 /* nt_str set in outer layers */ 617 nt.nt_iid = GET_IID_VAL(inp->in_iid); 618 nt.nt_tgt = inp->in_tgt; 619 nt.nt_lun = inp->in_lun; 620 IN_MAKE_TAGID(nt.nt_tagval, 0, inp); 621 nt.nt_lreserved = inp; |
574 | 622 |
575 MEMZERO(&msg, sizeof (msg)); 576 msg.nt_bus = bus; 577 msg.nt_iid = inp->in_iid; 578 msg.nt_tgt = inp->in_tgt; 579 msg.nt_lun = inp->in_lun; 580 msg.nt_tagtype = inp->in_tag_type; 581 IN_MAKE_TAGID(msg.nt_tagval, 0, inp); 582 MEMCPY(msg.nt_msg, inp->in_msg, IN_MSGLEN); 583 (void) isp_async(isp, ISPASYNC_TARGET_MESSAGE, &msg); | 623 if (status == IN_IDE_RECEIVED || status == IN_MSG_RECEIVED) { 624 switch (inp->in_msg[0]) { 625 case MSG_ABORT: 626 nt.nt_ncode = NT_ABORT_TASK_SET; 627 break; 628 case MSG_BUS_DEV_RESET: 629 nt.nt_ncode = NT_TARGET_RESET; 630 break; 631 case MSG_ABORT_TAG: 632 nt.nt_ncode = NT_ABORT_TASK; 633 break; 634 case MSG_CLEAR_QUEUE: 635 nt.nt_ncode = NT_CLEAR_TASK_SET; 636 break; 637 case MSG_REL_RECOVERY: 638 nt.nt_ncode = NT_CLEAR_ACA; 639 break; 640 case MSG_TERM_IO_PROC: 641 nt.nt_ncode = NT_ABORT_TASK; 642 break; 643 case MSG_LUN_RESET: 644 nt.nt_ncode = NT_LUN_RESET; 645 break; 646 default: 647 isp_prt(isp, ISP_LOGERR, 648 "unhandled message 0x%x", inp->in_msg[0]); 649 isp_notify_ack(isp, inp); 650 return; 651 } 652 (void) isp_async(isp, ISPASYNC_TARGET_NOTIFY, &nt); |
584 } else { 585 isp_prt(isp, ISP_LOGERR, 586 "unknown immediate notify status 0x%x", inp->in_status); | 653 } else { 654 isp_prt(isp, ISP_LOGERR, 655 "unknown immediate notify status 0x%x", inp->in_status); |
656 isp_notify_ack(isp, inp); |
|
587 } 588} 589 590/* 591 * Synthesize a message from the task management flags in a FCP_CMND_IU. 592 */ 593static void | 657 } 658} 659 660/* 661 * Synthesize a message from the task management flags in a FCP_CMND_IU. 662 */ 663static void |
594isp_got_msg_fc(struct ispsoftc *isp, int bus, in_fcentry_t *inp) | 664isp_got_msg_fc(struct ispsoftc *isp, in_fcentry_t *inp) |
595{ | 665{ |
596 int lun; 597 static const char f1[] = "%s from iid %d lun %d seq 0x%x"; | 666 tmd_notify_t nt; 667 static const char f1[] = "%s from iid 0x%08x%08x lun %d seq 0x%x"; |
598 static const char f2[] = | 668 static const char f2[] = |
599 "unknown %s 0x%x lun %d iid %d task flags 0x%x seq 0x%x\n"; | 669 "unknown %s 0x%x lun %d iid 0x%08x%08x task flags 0x%x seq 0x%x\n"; |
600 | 670 |
671 MEMZERO(&nt, sizeof (tmd_notify_t)); 672 nt.nt_hba = isp; 673 /* 674 * XXX: LOOK UP TRANSLATION IN CURRENT LPORTDB 675 */ 676 if (IS_2KLOGIN(isp)) { 677 nt.nt_iid = ((in_fcentry_e_t *)inp)->in_iid; 678 } else { 679 nt.nt_iid = inp->in_iid; /* possibly reset in outer layer */ 680 } 681 /* nt_tgt set in outer layers */ |
|
601 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { | 682 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { |
602 lun = inp->in_scclun; | 683 nt.nt_lun = inp->in_scclun; |
603 } else { | 684 } else { |
604 lun = inp->in_lun; | 685 nt.nt_lun = inp->in_lun; |
605 } | 686 } |
687 IN_FC_MAKE_TAGID(nt.nt_tagval, 0, inp); 688 nt.nt_lreserved = inp; |
|
606 607 if (inp->in_status != IN_MSG_RECEIVED) { 608 isp_prt(isp, ISP_LOGINFO, f2, "immediate notify status", | 689 690 if (inp->in_status != IN_MSG_RECEIVED) { 691 isp_prt(isp, ISP_LOGINFO, f2, "immediate notify status", |
609 inp->in_status, lun, inp->in_iid, | 692 inp->in_status, nt.nt_lun, (u_int32_t) (nt.nt_iid >> 32), (u_int32_t) nt.nt_iid, |
610 inp->in_task_flags, inp->in_seqid); | 693 inp->in_task_flags, inp->in_seqid); |
611 } else { 612 tmd_msg_t msg; | 694 isp_notify_ack(isp, inp); 695 return; 696 } |
613 | 697 |
614 MEMZERO(&msg, sizeof (msg)); 615 msg.nt_bus = bus; 616 msg.nt_iid = inp->in_iid; 617 IN_FC_MAKE_TAGID(msg.nt_tagval, 0, inp); 618 msg.nt_lun = lun; 619 620 if (inp->in_task_flags & TASK_FLAGS_ABORT_TASK_SET) { 621 isp_prt(isp, ISP_LOGINFO, f1, "ABORT TASK SET", 622 inp->in_iid, lun, inp->in_seqid); 623 msg.nt_msg[0] = MSG_ABORT; 624 } else if (inp->in_task_flags & TASK_FLAGS_CLEAR_TASK_SET) { 625 isp_prt(isp, ISP_LOGINFO, f1, "CLEAR TASK SET", 626 inp->in_iid, lun, inp->in_seqid); 627 msg.nt_msg[0] = MSG_CLEAR_QUEUE; 628 } else if (inp->in_task_flags & TASK_FLAGS_LUN_RESET) { 629 isp_prt(isp, ISP_LOGINFO, f1, "LUN RESET", 630 inp->in_iid, lun, inp->in_seqid); 631 msg.nt_msg[0] = MSG_LUN_RESET; 632 } else if (inp->in_task_flags & TASK_FLAGS_TARGET_RESET) { 633 isp_prt(isp, ISP_LOGINFO, f1, "TARGET RESET", 634 inp->in_iid, lun, inp->in_seqid); 635 msg.nt_msg[0] = MSG_BUS_DEV_RESET; 636 } else if (inp->in_task_flags & TASK_FLAGS_CLEAR_ACA) { 637 isp_prt(isp, ISP_LOGINFO, f1, "CLEAR ACA", 638 inp->in_iid, lun, inp->in_seqid); 639 msg.nt_msg[0] = MSG_REL_RECOVERY; 640 } else { 641 isp_prt(isp, ISP_LOGWARN, f2, "task flag", 642 inp->in_status, lun, inp->in_iid, 643 inp->in_task_flags, inp->in_seqid); 644 } 645 if (msg.nt_msg[0]) { 646 (void) isp_async(isp, ISPASYNC_TARGET_MESSAGE, &msg); 647 } | 698 if (inp->in_task_flags & TASK_FLAGS_ABORT_TASK_SET) { 699 isp_prt(isp, ISP_LOGINFO, f1, "ABORT TASK SET", 700 (u_int32_t) (nt.nt_iid >> 32), (u_int32_t) nt.nt_iid, nt.nt_lun, inp->in_seqid); 701 nt.nt_ncode = NT_ABORT_TASK_SET; 702 } else if (inp->in_task_flags & TASK_FLAGS_CLEAR_TASK_SET) { 703 isp_prt(isp, ISP_LOGINFO, f1, "CLEAR TASK SET", 704 (u_int32_t) (nt.nt_iid >> 32), (u_int32_t) nt.nt_iid, nt.nt_lun, inp->in_seqid); 705 nt.nt_ncode = NT_CLEAR_TASK_SET; 706 } else if (inp->in_task_flags & TASK_FLAGS_LUN_RESET) { 707 isp_prt(isp, ISP_LOGINFO, f1, "LUN RESET", 708 (u_int32_t) (nt.nt_iid >> 32), (u_int32_t) nt.nt_iid, nt.nt_lun, inp->in_seqid); 709 nt.nt_ncode = NT_LUN_RESET; 710 } else if (inp->in_task_flags & TASK_FLAGS_TARGET_RESET) { 711 isp_prt(isp, ISP_LOGINFO, f1, "TARGET RESET", 712 (u_int32_t) (nt.nt_iid >> 32), (u_int32_t) nt.nt_iid, nt.nt_lun, inp->in_seqid); 713 nt.nt_ncode = NT_TARGET_RESET; 714 } else if (inp->in_task_flags & TASK_FLAGS_CLEAR_ACA) { 715 isp_prt(isp, ISP_LOGINFO, f1, "CLEAR ACA", 716 (u_int32_t) (nt.nt_iid >> 32), (u_int32_t) nt.nt_iid, nt.nt_lun, inp->in_seqid); 717 nt.nt_ncode = NT_CLEAR_ACA; 718 } else { 719 isp_prt(isp, ISP_LOGWARN, f2, "task flag", 720 inp->in_status, nt.nt_lun, (u_int32_t) (nt.nt_iid >> 32), (u_int32_t) nt.nt_iid, 721 inp->in_task_flags, inp->in_seqid); 722 isp_notify_ack(isp, inp); 723 return; |
648 } | 724 } |
725 (void) isp_async(isp, ISPASYNC_TARGET_NOTIFY, &nt); |
|
649} 650 | 726} 727 |
651static void | 728void |
652isp_notify_ack(struct ispsoftc *isp, void *arg) 653{ 654 char storage[QENTRY_LEN]; 655 u_int16_t nxti, optr; 656 void *outp; 657 658 if (isp_getrqentry(isp, &nxti, &optr, &outp)) { 659 isp_prt(isp, ISP_LOGWARN, 660 "Request Queue Overflow For isp_notify_ack"); 661 return; 662 } 663 664 MEMZERO(storage, QENTRY_LEN); 665 666 if (IS_FC(isp)) { 667 na_fcentry_t *na = (na_fcentry_t *) storage; 668 if (arg) { 669 in_fcentry_t *inp = arg; 670 MEMCPY(storage, arg, sizeof (isphdr_t)); | 729isp_notify_ack(struct ispsoftc *isp, void *arg) 730{ 731 char storage[QENTRY_LEN]; 732 u_int16_t nxti, optr; 733 void *outp; 734 735 if (isp_getrqentry(isp, &nxti, &optr, &outp)) { 736 isp_prt(isp, ISP_LOGWARN, 737 "Request Queue Overflow For isp_notify_ack"); 738 return; 739 } 740 741 MEMZERO(storage, QENTRY_LEN); 742 743 if (IS_FC(isp)) { 744 na_fcentry_t *na = (na_fcentry_t *) storage; 745 if (arg) { 746 in_fcentry_t *inp = arg; 747 MEMCPY(storage, arg, sizeof (isphdr_t)); |
671 na->na_iid = inp->in_iid; | 748 if (IS_2KLOGIN(isp)) { 749 ((na_fcentry_e_t *)na)->na_iid = ((in_fcentry_e_t *)inp)->in_iid; 750 } else { 751 na->na_iid = inp->in_iid; 752 } |
672 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { 673 na->na_lun = inp->in_scclun; 674 } else { 675 na->na_lun = inp->in_lun; 676 } 677 na->na_task_flags = inp->in_task_flags; 678 na->na_seqid = inp->in_seqid; 679 na->na_flags = NAFC_RCOUNT; 680 na->na_status = inp->in_status; 681 if (inp->in_status == IN_RESET) { 682 na->na_flags |= NAFC_RST_CLRD; 683 } 684 } else { 685 na->na_flags = NAFC_RST_CLRD; 686 } 687 na->na_header.rqs_entry_type = RQSTYPE_NOTIFY_ACK; 688 na->na_header.rqs_entry_count = 1; | 753 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { 754 na->na_lun = inp->in_scclun; 755 } else { 756 na->na_lun = inp->in_lun; 757 } 758 na->na_task_flags = inp->in_task_flags; 759 na->na_seqid = inp->in_seqid; 760 na->na_flags = NAFC_RCOUNT; 761 na->na_status = inp->in_status; 762 if (inp->in_status == IN_RESET) { 763 na->na_flags |= NAFC_RST_CLRD; 764 } 765 } else { 766 na->na_flags = NAFC_RST_CLRD; 767 } 768 na->na_header.rqs_entry_type = RQSTYPE_NOTIFY_ACK; 769 na->na_header.rqs_entry_count = 1; |
689 isp_put_notify_ack_fc(isp, na, (na_fcentry_t *)outp); | 770 if (IS_2KLOGIN(isp)) { 771 isp_put_notify_ack_fc_e(isp, (na_fcentry_e_t *) na, (na_fcentry_e_t *)outp); 772 } else { 773 isp_put_notify_ack_fc(isp, na, (na_fcentry_t *)outp); 774 } |
690 } else { 691 na_entry_t *na = (na_entry_t *) storage; 692 if (arg) { 693 in_entry_t *inp = arg; 694 MEMCPY(storage, arg, sizeof (isphdr_t)); 695 na->na_iid = inp->in_iid; 696 na->na_lun = inp->in_lun; 697 na->na_tgt = inp->in_tgt; --- 91 unchanged lines hidden (view full) --- 789 (void) isp_target_put_atio(isp, aep); 790 break; 791 } 792} 793 794static void 795isp_handle_atio2(struct ispsoftc *isp, at2_entry_t *aep) 796{ | 775 } else { 776 na_entry_t *na = (na_entry_t *) storage; 777 if (arg) { 778 in_entry_t *inp = arg; 779 MEMCPY(storage, arg, sizeof (isphdr_t)); 780 na->na_iid = inp->in_iid; 781 na->na_lun = inp->in_lun; 782 na->na_tgt = inp->in_tgt; --- 91 unchanged lines hidden (view full) --- 874 (void) isp_target_put_atio(isp, aep); 875 break; 876 } 877} 878 879static void 880isp_handle_atio2(struct ispsoftc *isp, at2_entry_t *aep) 881{ |
797 int lun; | 882 int lun, iid; |
798 799 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { 800 lun = aep->at_scclun; 801 } else { 802 lun = aep->at_lun; 803 } 804 | 883 884 if (FCPARAM(isp)->isp_fwattr & ISP_FW_ATTR_SCCLUN) { 885 lun = aep->at_scclun; 886 } else { 887 lun = aep->at_lun; 888 } 889 |
890 if (IS_2KLOGIN(isp)) { 891 iid = ((at2e_entry_t *)aep)->at_iid; 892 } else { 893 iid = aep->at_iid; 894 } 895 |
|
805 /* 806 * The firmware status (except for the QLTM_SVALID bit) indicates 807 * why this ATIO was sent to us. 808 * 809 * If QLTM_SVALID is set, the firware has recommended Sense Data. 810 * 811 * If the DISCONNECTS DISABLED bit is set in the flags field, 812 * we're still connected on the SCSI bus - i.e. the initiator --- 43 unchanged lines hidden (view full) --- 856 /* 857 * A bus reset came along an blew away this command. Why 858 * they do this in addition the async event code stuff, 859 * I dunno. 860 * 861 * Ignore it because the async event will clear things 862 * up for us. 863 */ | 896 /* 897 * The firmware status (except for the QLTM_SVALID bit) indicates 898 * why this ATIO was sent to us. 899 * 900 * If QLTM_SVALID is set, the firware has recommended Sense Data. 901 * 902 * If the DISCONNECTS DISABLED bit is set in the flags field, 903 * we're still connected on the SCSI bus - i.e. the initiator --- 43 unchanged lines hidden (view full) --- 947 /* 948 * A bus reset came along an blew away this command. Why 949 * they do this in addition the async event code stuff, 950 * I dunno. 951 * 952 * Ignore it because the async event will clear things 953 * up for us. 954 */ |
864 isp_prt(isp, ISP_LOGERR, atior, lun, aep->at_iid, 0); | 955 isp_prt(isp, ISP_LOGERR, atior, lun, iid, 0); |
865 break; 866 867 868 default: 869 isp_prt(isp, ISP_LOGERR, 870 "Unknown ATIO2 status 0x%x from initiator %d for lun %d", | 956 break; 957 958 959 default: 960 isp_prt(isp, ISP_LOGERR, 961 "Unknown ATIO2 status 0x%x from initiator %d for lun %d", |
871 aep->at_status, aep->at_iid, lun); | 962 aep->at_status, iid, lun); |
872 (void) isp_target_put_atio(isp, aep); 873 break; 874 } 875} 876 877static void 878isp_handle_ctio(struct ispsoftc *isp, ct_entry_t *ct) 879{ --- 316 unchanged lines hidden --- | 963 (void) isp_target_put_atio(isp, aep); 964 break; 965 } 966} 967 968static void 969isp_handle_ctio(struct ispsoftc *isp, ct_entry_t *ct) 970{ --- 316 unchanged lines hidden --- |