Lines Matching +full:isp +full:- +full:0
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2009-2020 Alexander Motin <mav@FreeBSD.org>
5 * Copyright (c) 1997-2009 by Matthew Jacob
47 #include <dev/isp/isp_freebsd.h>
77 * (Accept Target IO) type- sometimes with enough info to stop the command at
84 * cards that 'auto-replenish' the f/w's ATIO count, but this is the basic
105 * code- we have no synchroniation primitives in the common code.
109 isp_target_notify(ispsoftc_t *isp, void *vptr, uint32_t *optrp, uint16_t ql)
131 type = isp_get_response_type(isp, (isphdr_t *)vptr);
134 if (isp->isp_dblev & ISP_LOGTDEBUG2)
135 isp_print_qentry(isp, __func__, *optrp, vptr);
139 isp_get_atio7(isp, at7iop, (at7_entry_t *) local);
145 len = at7iop->at_ta_len & 0x0fff;
146 if (len > (QENTRY_LEN - 8)) {
147 len -= (QENTRY_LEN - 8);
148 isp_prt(isp, ISP_LOGINFO, "long IU length (%d) ignored", len);
149 while (len > 0) {
151 len -= QENTRY_LEN;
157 if (at7iop->at_cmnd.fcp_cmnd_task_management) {
158 isp_got_tmf_24xx(isp, at7iop);
164 isp_async(isp, ISPASYNC_TARGET_ACTION, local);
168 isp_get_ctio7(isp, ct7iop, (ct7_entry_t *) local);
169 isp_handle_ctio7(isp, (ct7_entry_t *) local);
173 isp_get_notify_24xx(isp, inot_24xx, (in_fcentry_24xx_t *)local);
174 isp_handle_notify_24xx(isp, (in_fcentry_24xx_t *)local);
179 * The ISP is acknowledging our acknowledgement of an
182 isp_get_notify_ack_24xx(isp, nack_24xx, (na_fcentry_24xx_t *) local);
184 if (nack_24xx->na_status != NA_OK)
188 isp_prt(isp, level, "Notify Ack Status=0x%x; Subcode 0x%x seqid=0x%x", nack_24xx->na_status, nack_24xx->na_status_subcode, nack_24xx->na_rxid);
192 isp_get_abts(isp, abts, (abts_t *)local);
193 isp_handle_abts(isp, (abts_t *)local);
196 isp_get_abts_rsp(isp, abts_rsp, (abts_rsp_t *)local);
198 if (abts_rsp->abts_rsp_status)
202 isp_prt(isp, level, "ABTS RSP response[0x%x]: status=0x%x sub=(0x%x 0x%x)", abts_rsp->abts_rsp_rxid_task, abts_rsp->abts_rsp_status,
203 abts_rsp->abts_rsp_payload.rsp.subcode1, abts_rsp->abts_rsp_payload.rsp.subcode2);
206 isp_prt(isp, ISP_LOGERR, "%s: unknown entry type 0x%x", __func__, type);
207 rval = 0;
221 * Command completion- both for handling cases of no resources or
239 isp_endcmd(ispsoftc_t *isp, ...)
248 va_start(ap, isp);
252 * Note that vpidx may equal 0xff (unknown) here
258 isp_prt(isp, ISP_LOGTDEBUG0, "%s: [RX_ID 0x%x] chan %d code %x", __func__, aep->at_rxid, vpidx, code);
260 sts = code & 0xff;
262 cto->ct_header.rqs_entry_type = RQSTYPE_CTIO7;
263 cto->ct_header.rqs_entry_count = 1;
264 cto->ct_nphdl = nphdl;
265 cto->ct_rxid = aep->at_rxid;
266 cto->ct_iid_lo = (aep->at_hdr.s_id[1] << 8) | aep->at_hdr.s_id[2];
267 cto->ct_iid_hi = aep->at_hdr.s_id[0];
268 cto->ct_oxid = aep->at_hdr.ox_id;
269 cto->ct_scsi_status = sts;
270 cto->ct_vpidx = vpidx;
271 cto->ct_flags = CT7_NOACK;
273 cto->ct_flags |= CT7_TERMINATE;
275 cto->ct_flags |= CT7_FLAG_MODE1 | CT7_SENDSTATUS;
276 cto->ct_scsi_status |= (FCP_SNSLEN_VALID << 8);
277 cto->ct_senselen = min(16, MAXRESPLEN_24XX);
278 ISP_MEMZERO(cto->rsp.m1.ct_resp, sizeof (cto->rsp.m1.ct_resp));
279 cto->rsp.m1.ct_resp[0] = 0xf0;
280 cto->rsp.m1.ct_resp[2] = (code >> 12) & 0xf;
281 cto->rsp.m1.ct_resp[7] = 8;
282 cto->rsp.m1.ct_resp[12] = (code >> 16) & 0xff;
283 cto->rsp.m1.ct_resp[13] = (code >> 24) & 0xff;
285 cto->ct_flags |= CT7_FLAG_MODE1 | CT7_SENDSTATUS;
286 cto->ct_scsi_status |= (FCP_RSPLEN_VALID << 8);
287 cto->rsp.m1.ct_resplen = 4;
288 ISP_MEMZERO(cto->rsp.m1.ct_resp, sizeof (cto->rsp.m1.ct_resp));
289 cto->rsp.m1.ct_resp[0] = (code >> 12) & 0xf;
290 cto->rsp.m1.ct_resp[1] = (code >> 16) & 0xff;
291 cto->rsp.m1.ct_resp[2] = (code >> 24) & 0xff;
292 cto->rsp.m1.ct_resp[3] = 0;
294 cto->ct_flags |= CT7_FLAG_MODE1 | CT7_SENDSTATUS;
296 if (aep->at_cmnd.cdb_dl.sf.fcp_cmnd_dl != 0) {
297 cto->ct_resid = aep->at_cmnd.cdb_dl.sf.fcp_cmnd_dl;
298 cto->ct_scsi_status |= (FCP_RESID_UNDERFLOW << 8);
300 cto->ct_syshandle = hdl;
301 return (isp_send_entry(isp, cto));
309 isp_target_async(ispsoftc_t *isp, int bus, int event)
314 notify.nt_hba = isp;
323 notify.nt_tagval |= (((uint64_t)(isp->isp_serno++)) << 32);
328 isp_prt(isp, ISP_LOGTDEBUG0, "%s: LOOP UP", __func__);
330 isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify);
333 isp_prt(isp, ISP_LOGTDEBUG0, "%s: LOOP DOWN", __func__);
335 isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify);
341 isp_prt(isp, ISP_LOGTDEBUG0, "%s: LIP RESET", __func__);
343 isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify);
346 isp_prt(isp, ISP_LOGERR, "%s: unknown event 0x%x", __func__, event);
352 isp_got_tmf_24xx(ispsoftc_t *isp, at7_entry_t *aep)
355 static const char f1[] = "%s from PortID 0x%06x lun %jx seq 0x%08x";
356 static const char f2[] = "unknown Task Flag 0x%x lun %jx PortID 0x%x tag 0x%08x";
362 notify.nt_hba = isp;
364 notify.nt_lun = CAM_EXTLUN_BYTE_SWIZZLE(be64dec(aep->at_cmnd.fcp_cmnd_lun));
365 notify.nt_tagval = aep->at_rxid;
366 notify.nt_tagval |= (((uint64_t)(isp->isp_serno++)) << 32);
368 sid = (aep->at_hdr.s_id[0] << 16) | (aep->at_hdr.s_id[1] << 8) | aep->at_hdr.s_id[2];
369 did = (aep->at_hdr.d_id[0] << 16) | (aep->at_hdr.d_id[1] << 8) | aep->at_hdr.d_id[2];
370 if (ISP_CAP_MULTI_ID(isp) && isp->isp_nchan > 1) {
372 isp_find_chan_by_did(isp, did, &chan);
374 isp_prt(isp, ISP_LOGWARN,
375 "%s: D_ID 0x%x not found on any channel",
377 isp_endcmd(isp, aep, NIL_HANDLE, ISP_NOCHAN,
378 ECMD_TERMINATE, 0);
382 chan = 0;
384 if (isp_find_pdb_by_portid(isp, chan, sid, &lp))
385 notify.nt_nphdl = lp->handle;
391 if (aep->at_cmnd.fcp_cmnd_task_management & FCP_CMND_TMF_QUERY_TASK_SET) {
392 isp_prt(isp, ISP_LOGINFO, f1, "QUERY TASK SET", sid, notify.nt_lun, aep->at_rxid);
394 } else if (aep->at_cmnd.fcp_cmnd_task_management & FCP_CMND_TMF_ABORT_TASK_SET) {
395 isp_prt(isp, ISP_LOGINFO, f1, "ABORT TASK SET", sid, notify.nt_lun, aep->at_rxid);
397 } else if (aep->at_cmnd.fcp_cmnd_task_management & FCP_CMND_TMF_CLEAR_TASK_SET) {
398 isp_prt(isp, ISP_LOGINFO, f1, "CLEAR TASK SET", sid, notify.nt_lun, aep->at_rxid);
400 } else if (aep->at_cmnd.fcp_cmnd_task_management & FCP_CMND_TMF_QUERY_ASYNC_EVENT) {
401 isp_prt(isp, ISP_LOGINFO, f1, "QUERY ASYNC EVENT", sid, notify.nt_lun, aep->at_rxid);
403 } else if (aep->at_cmnd.fcp_cmnd_task_management & FCP_CMND_TMF_LUN_RESET) {
404 isp_prt(isp, ISP_LOGINFO, f1, "LUN RESET", sid, notify.nt_lun, aep->at_rxid);
406 } else if (aep->at_cmnd.fcp_cmnd_task_management & FCP_CMND_TMF_TGT_RESET) {
407 isp_prt(isp, ISP_LOGINFO, f1, "TARGET RESET", sid, notify.nt_lun, aep->at_rxid);
409 } else if (aep->at_cmnd.fcp_cmnd_task_management & FCP_CMND_TMF_CLEAR_ACA) {
410 isp_prt(isp, ISP_LOGINFO, f1, "CLEAR ACA", sid, notify.nt_lun, aep->at_rxid);
413 isp_prt(isp, ISP_LOGWARN, f2, aep->at_cmnd.fcp_cmnd_task_management, notify.nt_lun, sid, aep->at_rxid);
415 isp_endcmd(isp, aep, notify.nt_nphdl, chan, ECMD_RVALID | (0x4 << 12), 0);
418 isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify);
422 isp_notify_ack(ispsoftc_t *isp, void *arg)
429 if (((isphdr_t *)arg)->rqs_entry_type == RQSTYPE_ATIO)
430 return (isp_endcmd(isp, arg, NIL_HANDLE, 0, 0, 0));
435 na->na_header.rqs_entry_type = RQSTYPE_NOTIFY_ACK;
436 na->na_header.rqs_entry_count = 1;
437 na->na_nphdl = in->in_nphdl;
438 na->na_flags = in->in_flags;
439 na->na_status = in->in_status;
440 na->na_status_subcode = in->in_status_subcode;
441 na->na_fwhandle = in->in_fwhandle;
442 na->na_rxid = in->in_rxid;
443 na->na_oxid = in->in_oxid;
444 na->na_vpidx = in->in_vpidx;
445 if (in->in_status == IN24XX_SRR_RCVD) {
446 na->na_srr_rxid = in->in_srr_rxid;
447 na->na_srr_reloff_hi = in->in_srr_reloff_hi;
448 na->na_srr_reloff_lo = in->in_srr_reloff_lo;
449 na->na_srr_iu = in->in_srr_iu;
455 if (in->in_reserved) {
456 na->na_srr_flags = 1;
457 na->na_srr_reject_vunique = 0;
459 na->na_srr_reject_code = 9;
461 na->na_srr_reject_explanation = 0x2a;
464 return (isp_send_entry(isp, na));
468 isp_acknak_abts(ispsoftc_t *isp, void *arg, int errno)
476 if (abts->abts_header.rqs_entry_type != RQSTYPE_ABTS_RCVD) {
477 isp_prt(isp, ISP_LOGERR, "%s: called for non-ABTS entry (0x%x)", __func__, abts->abts_header.rqs_entry_type);
478 return (0);
482 rsp->abts_rsp_header.rqs_entry_type = RQSTYPE_ABTS_RSP;
484 isp_prt(isp, ISP_LOGTINFO, "[0x%x] ABTS of 0x%x being %s'd",
485 rsp->abts_rsp_rxid_abts, rsp->abts_rsp_rxid_task,
486 (errno == 0) ? "BA_ACC" : "BA_RJT");
487 rsp->abts_rsp_r_ctl = (errno == 0) ? BA_ACC : BA_RJT;
492 tmpw = rsp->abts_rsp_did_lo;
493 tmpb = rsp->abts_rsp_did_hi;
494 rsp->abts_rsp_did_lo = rsp->abts_rsp_sid_lo;
495 rsp->abts_rsp_did_hi = rsp->abts_rsp_sid_hi;
496 rsp->abts_rsp_sid_lo = tmpw;
497 rsp->abts_rsp_sid_hi = tmpb;
499 rsp->abts_rsp_f_ctl_hi ^= 0x80; /* invert Exchange Context */
500 rsp->abts_rsp_f_ctl_hi &= ~0x7f; /* clear Sequence Initiator and other bits */
501 rsp->abts_rsp_f_ctl_hi |= 0x10; /* abort the whole exchange */
502 rsp->abts_rsp_f_ctl_hi |= 0x8; /* last data frame of sequence */
503 rsp->abts_rsp_f_ctl_hi |= 0x1; /* transfer Sequence Initiative */
504 rsp->abts_rsp_f_ctl_lo = 0;
506 if (errno == 0) {
509 rx_id = rsp->abts_rsp_rx_id;
510 ox_id = rsp->abts_rsp_ox_id;
511 ISP_MEMZERO(&rsp->abts_rsp_payload.ba_acc, sizeof (rsp->abts_rsp_payload.ba_acc));
512 rsp->abts_rsp_payload.ba_acc.aborted_rx_id = rx_id;
513 rsp->abts_rsp_payload.ba_acc.aborted_ox_id = ox_id;
514 rsp->abts_rsp_payload.ba_acc.high_seq_cnt = 0xffff;
516 ISP_MEMZERO(&rsp->abts_rsp_payload.ba_rjt, sizeof (rsp->abts_rsp_payload.ba_rjt));
519 rsp->abts_rsp_payload.ba_rjt.reason = 5; /* Logical busy */
522 rsp->abts_rsp_payload.ba_rjt.reason = 9; /* Unable to perform command request */
526 return (isp_send_entry(isp, rsp));
530 isp_handle_abts(ispsoftc_t *isp, abts_t *abts)
537 did = (abts->abts_did_hi << 16) | abts->abts_did_lo;
538 sid = (abts->abts_sid_hi << 16) | abts->abts_sid_lo;
541 nt->nt_hba = isp;
542 nt->nt_did = did;
543 nt->nt_nphdl = abts->abts_nphdl;
544 nt->nt_sid = sid;
545 if (ISP_CAP_MULTI_ID(isp) && isp->isp_nchan > 1) {
547 isp_find_chan_by_did(isp, did, &chan);
549 isp_prt(isp, ISP_LOGWARN,
550 "%s: D_ID 0x%x not found on any channel",
552 isp_acknak_abts(isp, abts, ENXIO);
556 chan = 0;
557 nt->nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
558 if (isp_find_pdb_by_handle(isp, chan, abts->abts_nphdl, &lp))
559 nt->nt_wwn = lp->port_wwn;
561 nt->nt_wwn = INI_ANY;
562 nt->nt_lun = LUN_ANY;
563 nt->nt_need_ack = 1;
564 nt->nt_tagval = abts->abts_rxid_task;
565 nt->nt_tagval |= (((uint64_t) abts->abts_rxid_abts) << 32);
566 isp_prt(isp, ISP_LOGTINFO, "[0x%x] ABTS from N-Port handle 0x%x"
567 " Port 0x%06x for task 0x%x (rx_id 0x%04x ox_id 0x%04x)",
568 abts->abts_rxid_abts, abts->abts_nphdl, sid, abts->abts_rxid_task,
569 abts->abts_rx_id, abts->abts_ox_id);
570 nt->nt_channel = chan;
571 nt->nt_ncode = NT_ABORT_TASK;
572 nt->nt_lreserved = abts;
573 isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify);
577 isp_handle_ctio7(ispsoftc_t *isp, ct7_entry_t *ct)
583 if (ct->ct_syshandle) {
584 xs = isp_find_xs(isp, ct->ct_syshandle);
592 switch (ct->ct_nphdl) {
594 isp_prt(isp, ISP_LOGERR, "PCI DMA Bus Error");
622 isp_prt(isp, ISP_LOGTDEBUG0, "CTIO7 destroyed by %s: RX_ID=0x%x", fmsg, ct->ct_rxid);
629 isp_prt(isp, ISP_LOGWARN, "Firmware timed out on %s", fmsg);
649 isp_prt(isp, ISP_LOGWARN, "CTIO returned by f/w- %s", fmsg);
657 isp_prt(isp, ISP_LOGWARN, "CTIO7 completed with Invalid RX_ID 0x%x", ct->ct_rxid);
661 isp_prt(isp, ISP_LOGWARN, "reassembly error");
665 isp_prt(isp, ISP_LOGTDEBUG0, "SRR received");
669 isp_prt(isp, ISP_LOGERR, "Unknown CTIO7 status 0x%x", ct->ct_nphdl);
681 if (ct->ct_syshandle == 0) {
682 if (ct->ct_flags & CT7_TERMINATE) {
683 isp_prt(isp, ISP_LOGINFO, "termination of [RX_ID 0x%x] complete", ct->ct_rxid);
684 } else if ((ct->ct_flags & CT7_SENDSTATUS) == 0) {
685 isp_prt(isp, pl, "intermediate CTIO completed ok");
687 isp_prt(isp, pl, "unmonitored CTIO completed ok");
690 isp_prt(isp, pl, "NO xs for CTIO (handle 0x%x) status 0x%x", ct->ct_syshandle, ct->ct_nphdl);
693 ISP_DMAFREE(isp, xs);
694 if (ct->ct_flags & CT7_SENDSTATUS) {
703 isp_prt(isp, pl, "status CTIO complete");
709 isp_prt(isp, pl, "data CTIO complete");
711 isp_async(isp, ISPASYNC_TARGET_ACTION, ct);
719 isp_handle_notify_24xx(ispsoftc_t *isp, in_fcentry_24xx_t *inot)
722 uint16_t nphdl, prli_options = 0;
731 nphdl = inot->in_nphdl;
733 portid = inot->in_portid_hi << 16 | inot->in_portid_lo;
738 chan = ISP_GET_VPIDX(isp, inot->in_vpidx);
739 if (chan >= isp->isp_nchan &&
740 inot->in_status != IN24XX_LIP_RESET &&
741 inot->in_status != IN24XX_LINK_RESET &&
742 inot->in_status != IN24XX_LINK_FAILED) {
743 isp_prt(isp, ISP_LOGWARN, "%s: Received INOT with status %x on VP %x",
744 __func__, inot->in_status, chan);
745 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
749 switch (inot->in_status) {
758 switch (inot->in_status_subcode) {
762 isp_del_wwn_entry(isp, chan, wwpn, nphdl, portid);
771 isp_add_wwn_entry(isp, chan, wwpn, wwnn,
776 prli_options = inot->in_prli_options;
777 if (inot->in_flags & IN24XX_FLAG_PN_NN_VALID)
780 isp_add_wwn_entry(isp, chan, wwpn, wwnn,
793 ISP_SNPRINTF(buf, sizeof (buf), "ELS 0x%x",
794 inot->in_status_subcode);
798 if (inot->in_flags & IN24XX_FLAG_PUREX_IOCB) {
799 isp_prt(isp, ISP_LOGERR, "%s Chan %d ELS N-port handle %x"
800 " PortID 0x%06x marked as needing a PUREX response",
804 isp_prt(isp, ISP_LOGTDEBUG0, "%s Chan %d ELS N-port handle %x"
805 " PortID 0x%06x RX_ID 0x%x OX_ID 0x%x", msg, chan, nphdl,
806 portid, inot->in_rxid, inot->in_oxid);
807 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
813 if (isp_find_pdb_by_handle(isp, chan, nphdl, &lp))
814 isp_del_wwn_entry(isp, chan, lp->port_wwn, nphdl, lp->portid);
823 isp_prt(isp, ISP_LOGINFO, "Chan %d %s (sub-status 0x%x) for "
824 "N-port handle 0x%x",
825 chan, msg, inot->in_status_subcode, nphdl);
830 * this initiator (known by N-port handle).
833 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);
839 notify.nt_hba = isp;
841 notify.nt_tgt = FCPARAM(isp, chan)->isp_wwpn;
846 notify.nt_tagval = inot->in_rxid;
847 notify.nt_tagval |= ((uint64_t)inot->in_srr_rxid << 32);
852 isp_async(isp, ISPASYNC_TARGET_NOTIFY, ¬ify);
866 isp_prt(isp, ISP_LOGWARN, "Chan %d %s", chan, msg);
867 isp_async(isp, ISPASYNC_TARGET_NOTIFY_ACK, inot);