Lines Matching +full:spi +full:- +full:crc

1 /*-
5 * SPDX-License-Identifier: BSD-2-Clause AND BSD-3-Clause
30 /*-
63 * Support from LSI-Logic has also gone a great deal toward making this a
66 /*-
185 int mpt_enable_sata_wc = -1;
195 * (or want to) or have RAID physical devices that need CAM pass-thru in mpt_cam_probe()
198 if (mpt->do_cfg_role) { in mpt_cam_probe()
199 role = mpt->cfg_role; in mpt_cam_probe()
201 role = mpt->role; in mpt_cam_probe()
204 (mpt->ioc_page2 != NULL && mpt->ioc_page2->MaxPhysDisks != 0)) { in mpt_cam_probe()
219 TAILQ_INIT(&mpt->request_timeout_list); in mpt_cam_attach()
220 maxq = (mpt->ioc_facts.GlobalCredits < MPT_MAX_REQUESTS(mpt))? in mpt_cam_attach()
221 mpt->ioc_facts.GlobalCredits : MPT_MAX_REQUESTS(mpt); in mpt_cam_attach()
243 if (mpt->is_fc && (mpt->role & MPT_ROLE_TARGET) != 0) { in mpt_cam_attach()
256 maxq -= mpt->els_cmds_allocated; in mpt_cam_attach()
264 if (mpt->is_fc && (mpt->role & MPT_ROLE_TARGET) != 0) { in mpt_cam_attach()
267 &mpt->scsi_tgt_handler_id); in mpt_cam_attach()
274 if (mpt->is_sas) { in mpt_cam_attach()
287 mpt->tmf_req = mpt_get_request(mpt, FALSE); in mpt_cam_attach()
288 if (mpt->tmf_req == NULL) { in mpt_cam_attach()
301 mpt->tmf_req->state = REQ_STATE_FREE; in mpt_cam_attach()
302 maxq--; in mpt_cam_attach()
328 mpt->sim = in mpt_cam_attach()
330 if (mpt->sim == NULL) { in mpt_cam_attach()
341 if (xpt_bus_register(mpt->sim, mpt->dev, 0) != CAM_SUCCESS) { in mpt_cam_attach()
348 if (xpt_create_path(&mpt->path, NULL, cam_sim_path(mpt->sim), in mpt_cam_attach()
361 if (mpt->ioc_page2 == NULL || mpt->ioc_page2->MaxPhysDisks == 0) { in mpt_cam_attach()
368 mpt->phydisk_sim = in mpt_cam_attach()
370 if (mpt->phydisk_sim == NULL) { in mpt_cam_attach()
380 if (xpt_bus_register(mpt->phydisk_sim, mpt->dev, 1) != in mpt_cam_attach()
388 if (xpt_create_path(&mpt->phydisk_path, NULL, in mpt_cam_attach()
389 cam_sim_path(mpt->phydisk_sim), in mpt_cam_attach()
417 0, &mpt->mpt_fcport_page0.Header, FALSE, 5000); in mpt_read_config_info_fc()
419 return (-1); in mpt_read_config_info_fc()
422 mpt->mpt_fcport_page0.Header.PageVersion, in mpt_read_config_info_fc()
423 mpt->mpt_fcport_page0.Header.PageLength, in mpt_read_config_info_fc()
424 mpt->mpt_fcport_page0.Header.PageNumber, in mpt_read_config_info_fc()
425 mpt->mpt_fcport_page0.Header.PageType); in mpt_read_config_info_fc()
427 rv = mpt_read_cur_cfg_page(mpt, 0, &mpt->mpt_fcport_page0.Header, in mpt_read_config_info_fc()
428 sizeof(mpt->mpt_fcport_page0), FALSE, 5000); in mpt_read_config_info_fc()
431 return (-1); in mpt_read_config_info_fc()
433 mpt2host_config_page_fc_port_0(&mpt->mpt_fcport_page0); in mpt_read_config_info_fc()
435 switch (mpt->mpt_fcport_page0.CurrentSpeed) { in mpt_read_config_info_fc()
437 mpt->mpt_fcport_speed = 1; in mpt_read_config_info_fc()
440 mpt->mpt_fcport_speed = 2; in mpt_read_config_info_fc()
443 mpt->mpt_fcport_speed = 10; in mpt_read_config_info_fc()
446 mpt->mpt_fcport_speed = 4; in mpt_read_config_info_fc()
449 mpt->mpt_fcport_speed = 0; in mpt_read_config_info_fc()
453 switch (mpt->mpt_fcport_page0.Flags & in mpt_read_config_info_fc()
456 mpt->mpt_fcport_speed = 0; in mpt_read_config_info_fc()
460 topology = "N-Port"; in mpt_read_config_info_fc()
463 topology = "NL-Port"; in mpt_read_config_info_fc()
466 topology = "F-Port"; in mpt_read_config_info_fc()
469 topology = "FL-Port"; in mpt_read_config_info_fc()
472 mpt->mpt_fcport_speed = 0; in mpt_read_config_info_fc()
477 mpt->scinfo.fc.wwnn = ((uint64_t)mpt->mpt_fcport_page0.WWNN.High << 32) in mpt_read_config_info_fc()
478 | mpt->mpt_fcport_page0.WWNN.Low; in mpt_read_config_info_fc()
479 mpt->scinfo.fc.wwpn = ((uint64_t)mpt->mpt_fcport_page0.WWPN.High << 32) in mpt_read_config_info_fc()
480 | mpt->mpt_fcport_page0.WWPN.Low; in mpt_read_config_info_fc()
481 mpt->scinfo.fc.portid = mpt->mpt_fcport_page0.PortIdentifier; in mpt_read_config_info_fc()
485 "Speed %u-Gbit\n", topology, in mpt_read_config_info_fc()
486 (uintmax_t)mpt->scinfo.fc.wwnn, (uintmax_t)mpt->scinfo.fc.wwpn, in mpt_read_config_info_fc()
487 mpt->mpt_fcport_speed); in mpt_read_config_info_fc()
489 ctx = device_get_sysctl_ctx(mpt->dev); in mpt_read_config_info_fc()
490 tree = device_get_sysctl_tree(mpt->dev); in mpt_read_config_info_fc()
493 "wwnn", CTLFLAG_RD, &mpt->scinfo.fc.wwnn, in mpt_read_config_info_fc()
497 "wwpn", CTLFLAG_RD, &mpt->scinfo.fc.wwpn, in mpt_read_config_info_fc()
546 if (mpt->do_cfg_role == 0) { in mpt_set_initial_config_fc()
547 role = mpt->cfg_role; in mpt_set_initial_config_fc()
549 mpt->do_cfg_role = 0; in mpt_set_initial_config_fc()
552 if (role != mpt->cfg_role) { in mpt_set_initial_config_fc()
553 if (mpt->cfg_role & MPT_ROLE_INITIATOR) { in mpt_set_initial_config_fc()
565 if (mpt->cfg_role & MPT_ROLE_TARGET) { in mpt_set_initial_config_fc()
577 mpt->role = mpt->cfg_role; in mpt_set_initial_config_fc()
636 portinfo->num_phys = buffer->NumPhys; in mptsas_sas_io_unit_pg0()
637 portinfo->phy_info = malloc(sizeof(*portinfo->phy_info) * in mptsas_sas_io_unit_pg0()
638 portinfo->num_phys, M_DEVBUF, M_NOWAIT|M_ZERO); in mptsas_sas_io_unit_pg0()
639 if (portinfo->phy_info == NULL) { in mptsas_sas_io_unit_pg0()
645 for (i = 0; i < portinfo->num_phys; i++) { in mptsas_sas_io_unit_pg0()
646 phyinfo = &portinfo->phy_info[i]; in mptsas_sas_io_unit_pg0()
647 phyinfo->phy_num = i; in mptsas_sas_io_unit_pg0()
648 phyinfo->port_id = buffer->PhyData[i].Port; in mptsas_sas_io_unit_pg0()
649 phyinfo->negotiated_link_rate = in mptsas_sas_io_unit_pg0()
650 buffer->PhyData[i].NegotiatedLinkRate; in mptsas_sas_io_unit_pg0()
651 phyinfo->handle = in mptsas_sas_io_unit_pg0()
652 le16toh(buffer->PhyData[i].ControllerDevHandle); in mptsas_sas_io_unit_pg0()
692 phy_info->hw_link_rate = buffer->HwLinkRate; in mptsas_sas_phy_pg0()
693 phy_info->programmed_link_rate = buffer->ProgrammedLinkRate; in mptsas_sas_phy_pg0()
694 phy_info->identify.dev_handle = le16toh(buffer->OwnerDevHandle); in mptsas_sas_phy_pg0()
695 phy_info->attached.dev_handle = le16toh(buffer->AttachedDevHandle); in mptsas_sas_phy_pg0()
736 device_info->dev_handle = le16toh(buffer->DevHandle); in mptsas_sas_device_pg0()
737 device_info->parent_dev_handle = le16toh(buffer->ParentDevHandle); in mptsas_sas_device_pg0()
738 device_info->enclosure_handle = le16toh(buffer->EnclosureHandle); in mptsas_sas_device_pg0()
739 device_info->slot = le16toh(buffer->Slot); in mptsas_sas_device_pg0()
740 device_info->phy_num = buffer->PhyNum; in mptsas_sas_device_pg0()
741 device_info->physical_port = buffer->PhysicalPort; in mptsas_sas_device_pg0()
742 device_info->target_id = buffer->TargetID; in mptsas_sas_device_pg0()
743 device_info->bus = buffer->Bus; in mptsas_sas_device_pg0()
744 bcopy(&buffer->SASAddress, &sas_address, sizeof(uint64_t)); in mptsas_sas_device_pg0()
745 device_info->sas_address = le64toh(sas_address); in mptsas_sas_device_pg0()
746 device_info->device_info = le32toh(buffer->DeviceInfo); in mptsas_sas_device_pg0()
773 for (i = 0; i < portinfo->num_phys; i++) { in mpt_read_config_info_sas()
774 phyinfo = &portinfo->phy_info[i]; in mpt_read_config_info_sas()
780 error = mptsas_sas_device_pg0(mpt, &phyinfo->identify, in mpt_read_config_info_sas()
783 phyinfo->handle); in mpt_read_config_info_sas()
786 phyinfo->identify.phy_num = phyinfo->phy_num = i; in mpt_read_config_info_sas()
787 if (phyinfo->attached.dev_handle) in mpt_read_config_info_sas()
789 &phyinfo->attached, in mpt_read_config_info_sas()
792 phyinfo->attached.dev_handle); in mpt_read_config_info_sas()
796 mpt->sas_portinfo = portinfo; in mpt_read_config_info_sas()
812 pass = req->req_vbuf; in mptsas_set_sata_wc()
814 pass->Function = MPI_FUNCTION_SATA_PASSTHROUGH; in mptsas_set_sata_wc()
815 pass->TargetID = devinfo->target_id; in mptsas_set_sata_wc()
816 pass->Bus = devinfo->bus; in mptsas_set_sata_wc()
817 pass->PassthroughFlags = 0; in mptsas_set_sata_wc()
818 pass->ConnectionRate = MPI_SATA_PT_REQ_CONNECT_RATE_NEGOTIATED; in mptsas_set_sata_wc()
819 pass->DataLength = 0; in mptsas_set_sata_wc()
820 pass->MsgContext = htole32(req->index | sata_pass_handler_id); in mptsas_set_sata_wc()
821 pass->CommandFIS[0] = 0x27; in mptsas_set_sata_wc()
822 pass->CommandFIS[1] = 0x80; in mptsas_set_sata_wc()
823 pass->CommandFIS[2] = 0xef; in mptsas_set_sata_wc()
824 pass->CommandFIS[3] = (enabled) ? 0x02 : 0x82; in mptsas_set_sata_wc()
825 pass->CommandFIS[7] = 0x40; in mptsas_set_sata_wc()
826 pass->CommandFIS[15] = 0x08; in mptsas_set_sata_wc()
838 status = le16toh(req->IOCStatus); in mptsas_set_sata_wc()
857 if ((mpt_enable_sata_wc != -1) && (mpt->sas_portinfo != NULL)) { in mpt_set_initial_config_sas()
858 for (i = 0; i < mpt->sas_portinfo->num_phys; i++) { in mpt_set_initial_config_sas()
859 phyinfo = &mpt->sas_portinfo->phy_info[i]; in mpt_set_initial_config_sas()
860 if (phyinfo->attached.dev_handle == 0) in mpt_set_initial_config_sas()
862 if ((phyinfo->attached.device_info & in mpt_set_initial_config_sas()
866 device_printf(mpt->dev, in mpt_set_initial_config_sas()
869 mptsas_set_sata_wc(mpt, &phyinfo->attached, in mpt_set_initial_config_sas()
884 req->IOCStatus = le16toh(reply_frame->IOCStatus); in mpt_sata_pass_reply_handler()
886 req->state &= ~REQ_STATE_QUEUED; in mpt_sata_pass_reply_handler()
887 req->state |= REQ_STATE_DONE; in mpt_sata_pass_reply_handler()
888 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_sata_pass_reply_handler()
889 if ((req->state & REQ_STATE_NEED_WAKEUP) != 0) { in mpt_sata_pass_reply_handler()
891 } else if ((req->state & REQ_STATE_TIMEDOUT) != 0) { in mpt_sata_pass_reply_handler()
893 * Whew- we can free this request (late completion) in mpt_sata_pass_reply_handler()
911 &mpt->mpt_port_page0.Header, FALSE, 5000); in mpt_read_config_info_spi()
913 return (-1); in mpt_read_config_info_spi()
915 mpt_lprt(mpt, MPT_PRT_DEBUG, "SPI Port Page 0 Header: %x %x %x %x\n", in mpt_read_config_info_spi()
916 mpt->mpt_port_page0.Header.PageVersion, in mpt_read_config_info_spi()
917 mpt->mpt_port_page0.Header.PageLength, in mpt_read_config_info_spi()
918 mpt->mpt_port_page0.Header.PageNumber, in mpt_read_config_info_spi()
919 mpt->mpt_port_page0.Header.PageType); in mpt_read_config_info_spi()
922 &mpt->mpt_port_page1.Header, FALSE, 5000); in mpt_read_config_info_spi()
924 return (-1); in mpt_read_config_info_spi()
926 mpt_lprt(mpt, MPT_PRT_DEBUG, "SPI Port Page 1 Header: %x %x %x %x\n", in mpt_read_config_info_spi()
927 mpt->mpt_port_page1.Header.PageVersion, in mpt_read_config_info_spi()
928 mpt->mpt_port_page1.Header.PageLength, in mpt_read_config_info_spi()
929 mpt->mpt_port_page1.Header.PageNumber, in mpt_read_config_info_spi()
930 mpt->mpt_port_page1.Header.PageType); in mpt_read_config_info_spi()
933 &mpt->mpt_port_page2.Header, FALSE, 5000); in mpt_read_config_info_spi()
935 return (-1); in mpt_read_config_info_spi()
937 mpt_lprt(mpt, MPT_PRT_DEBUG, "SPI Port Page 2 Header: %x %x %x %x\n", in mpt_read_config_info_spi()
938 mpt->mpt_port_page2.Header.PageVersion, in mpt_read_config_info_spi()
939 mpt->mpt_port_page2.Header.PageLength, in mpt_read_config_info_spi()
940 mpt->mpt_port_page2.Header.PageNumber, in mpt_read_config_info_spi()
941 mpt->mpt_port_page2.Header.PageType); in mpt_read_config_info_spi()
945 0, i, &mpt->mpt_dev_page0[i].Header, FALSE, 5000); in mpt_read_config_info_spi()
947 return (-1); in mpt_read_config_info_spi()
950 "SPI Target %d Device Page 0 Header: %x %x %x %x\n", i, in mpt_read_config_info_spi()
951 mpt->mpt_dev_page0[i].Header.PageVersion, in mpt_read_config_info_spi()
952 mpt->mpt_dev_page0[i].Header.PageLength, in mpt_read_config_info_spi()
953 mpt->mpt_dev_page0[i].Header.PageNumber, in mpt_read_config_info_spi()
954 mpt->mpt_dev_page0[i].Header.PageType); in mpt_read_config_info_spi()
957 1, i, &mpt->mpt_dev_page1[i].Header, FALSE, 5000); in mpt_read_config_info_spi()
959 return (-1); in mpt_read_config_info_spi()
962 "SPI Target %d Device Page 1 Header: %x %x %x %x\n", i, in mpt_read_config_info_spi()
963 mpt->mpt_dev_page1[i].Header.PageVersion, in mpt_read_config_info_spi()
964 mpt->mpt_dev_page1[i].Header.PageLength, in mpt_read_config_info_spi()
965 mpt->mpt_dev_page1[i].Header.PageNumber, in mpt_read_config_info_spi()
966 mpt->mpt_dev_page1[i].Header.PageType); in mpt_read_config_info_spi()
975 rv = mpt_read_cur_cfg_page(mpt, 0, &mpt->mpt_port_page0.Header, in mpt_read_config_info_spi()
976 sizeof(mpt->mpt_port_page0), FALSE, 5000); in mpt_read_config_info_spi()
978 mpt_prt(mpt, "failed to read SPI Port Page 0\n"); in mpt_read_config_info_spi()
980 mpt2host_config_page_scsi_port_0(&mpt->mpt_port_page0); in mpt_read_config_info_spi()
982 "SPI Port Page 0: Capabilities %x PhysicalInterface %x\n", in mpt_read_config_info_spi()
983 mpt->mpt_port_page0.Capabilities, in mpt_read_config_info_spi()
984 mpt->mpt_port_page0.PhysicalInterface); in mpt_read_config_info_spi()
987 rv = mpt_read_cur_cfg_page(mpt, 0, &mpt->mpt_port_page1.Header, in mpt_read_config_info_spi()
988 sizeof(mpt->mpt_port_page1), FALSE, 5000); in mpt_read_config_info_spi()
990 mpt_prt(mpt, "failed to read SPI Port Page 1\n"); in mpt_read_config_info_spi()
992 mpt2host_config_page_scsi_port_1(&mpt->mpt_port_page1); in mpt_read_config_info_spi()
994 "SPI Port Page 1: Configuration %x OnBusTimerValue %x\n", in mpt_read_config_info_spi()
995 mpt->mpt_port_page1.Configuration, in mpt_read_config_info_spi()
996 mpt->mpt_port_page1.OnBusTimerValue); in mpt_read_config_info_spi()
999 rv = mpt_read_cur_cfg_page(mpt, 0, &mpt->mpt_port_page2.Header, in mpt_read_config_info_spi()
1000 sizeof(mpt->mpt_port_page2), FALSE, 5000); in mpt_read_config_info_spi()
1002 mpt_prt(mpt, "failed to read SPI Port Page 2\n"); in mpt_read_config_info_spi()
1006 mpt->mpt_port_page2.PortFlags, in mpt_read_config_info_spi()
1007 mpt->mpt_port_page2.PortSettings); in mpt_read_config_info_spi()
1008 mpt2host_config_page_scsi_port_2(&mpt->mpt_port_page2); in mpt_read_config_info_spi()
1012 i, mpt->mpt_port_page2.DeviceSettings[i].Timeout, in mpt_read_config_info_spi()
1013 mpt->mpt_port_page2.DeviceSettings[i].SyncFactor, in mpt_read_config_info_spi()
1014 mpt->mpt_port_page2.DeviceSettings[i].DeviceFlags); in mpt_read_config_info_spi()
1020 &mpt->mpt_dev_page0[i].Header, sizeof(*mpt->mpt_dev_page0), in mpt_read_config_info_spi()
1024 "cannot read SPI Target %d Device Page 0\n", i); in mpt_read_config_info_spi()
1027 mpt2host_config_page_scsi_device_0(&mpt->mpt_dev_page0[i]); in mpt_read_config_info_spi()
1030 i, mpt->mpt_dev_page0[i].NegotiatedParameters, in mpt_read_config_info_spi()
1031 mpt->mpt_dev_page0[i].Information); in mpt_read_config_info_spi()
1034 &mpt->mpt_dev_page1[i].Header, sizeof(*mpt->mpt_dev_page1), in mpt_read_config_info_spi()
1038 "cannot read SPI Target %d Device Page 1\n", i); in mpt_read_config_info_spi()
1041 mpt2host_config_page_scsi_device_1(&mpt->mpt_dev_page1[i]); in mpt_read_config_info_spi()
1044 i, mpt->mpt_dev_page1[i].RequestedParameters, in mpt_read_config_info_spi()
1045 mpt->mpt_dev_page1[i].Configuration); in mpt_read_config_info_spi()
1051 * Validate SPI configuration information.
1053 * In particular, validate SPI Port Page 1.
1060 mpt->mpt_disc_enable = 0xff; in mpt_set_initial_config_spi()
1061 mpt->mpt_tag_enable = 0; in mpt_set_initial_config_spi()
1063 pp1val = ((1 << mpt->mpt_ini_id) << in mpt_set_initial_config_spi()
1064 MPI_SCSIPORTPAGE1_CFG_SHIFT_PORT_RESPONSE_ID) | mpt->mpt_ini_id; in mpt_set_initial_config_spi()
1065 if (mpt->mpt_port_page1.Configuration != pp1val) { in mpt_set_initial_config_spi()
1068 mpt_prt(mpt, "SPI Port Page 1 Config value bad (%x)- should " in mpt_set_initial_config_spi()
1069 "be %x\n", mpt->mpt_port_page1.Configuration, pp1val); in mpt_set_initial_config_spi()
1070 tmp = mpt->mpt_port_page1; in mpt_set_initial_config_spi()
1076 return (-1); in mpt_set_initial_config_spi()
1081 return (-1); in mpt_set_initial_config_spi()
1086 "failed to reset SPI Port Page 1 Config value\n"); in mpt_set_initial_config_spi()
1087 return (-1); in mpt_set_initial_config_spi()
1089 mpt->mpt_port_page1 = tmp; in mpt_set_initial_config_spi()
1099 i = mpt->mpt_port_page2.PortSettings & in mpt_set_initial_config_spi()
1106 mpt->mpt_dev_page1[i].RequestedParameters = 0; in mpt_set_initial_config_spi()
1107 mpt->mpt_dev_page1[i].Configuration = 0; in mpt_set_initial_config_spi()
1122 if (mpt->is_fc) { in mpt_cam_enable()
1129 } else if (mpt->is_sas) { in mpt_cam_enable()
1136 } else if (mpt->is_spi) { in mpt_cam_enable()
1159 if (mpt->is_fc && (mpt->role & MPT_ROLE_TARGET)) { in mpt_cam_ready()
1169 mpt->ready = 1; in mpt_cam_ready()
1178 mpt->ready = 0; in mpt_cam_detach()
1192 mpt->scsi_tgt_handler_id); in mpt_cam_detach()
1197 if (mpt->tmf_req != NULL) { in mpt_cam_detach()
1198 mpt->tmf_req->state = REQ_STATE_ALLOCATED; in mpt_cam_detach()
1199 mpt_free_request(mpt, mpt->tmf_req); in mpt_cam_detach()
1200 mpt->tmf_req = NULL; in mpt_cam_detach()
1202 if (mpt->sas_portinfo != NULL) { in mpt_cam_detach()
1203 free(mpt->sas_portinfo, M_DEVBUF); in mpt_cam_detach()
1204 mpt->sas_portinfo = NULL; in mpt_cam_detach()
1207 if (mpt->sim != NULL) { in mpt_cam_detach()
1208 xpt_free_path(mpt->path); in mpt_cam_detach()
1209 xpt_bus_deregister(cam_sim_path(mpt->sim)); in mpt_cam_detach()
1210 cam_sim_free(mpt->sim, TRUE); in mpt_cam_detach()
1211 mpt->sim = NULL; in mpt_cam_detach()
1214 if (mpt->phydisk_sim != NULL) { in mpt_cam_detach()
1215 xpt_free_path(mpt->phydisk_path); in mpt_cam_detach()
1216 xpt_bus_deregister(cam_sim_path(mpt->phydisk_sim)); in mpt_cam_detach()
1217 cam_sim_free(mpt->phydisk_sim, TRUE); in mpt_cam_detach()
1218 mpt->phydisk_sim = NULL; in mpt_cam_detach()
1245 mpt = ccb->ccb_h.ccb_mpt_ptr; in mpt_timeout()
1248 req = ccb->ccb_h.ccb_req_ptr; in mpt_timeout()
1249 mpt_prt(mpt, "request %p:%u timed out for ccb %p (req->ccb %p)\n", req, in mpt_timeout()
1250 req->serno, ccb, req->ccb); in mpt_timeout()
1252 if ((req->state & REQ_STATE_QUEUED) == REQ_STATE_QUEUED) { in mpt_timeout()
1253 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_timeout()
1254 TAILQ_INSERT_TAIL(&mpt->request_timeout_list, req, links); in mpt_timeout()
1255 req->state |= REQ_STATE_TIMEDOUT; in mpt_timeout()
1285 ccb = req->ccb; in mpt_execute_req_a64()
1287 mpt = ccb->ccb_h.ccb_mpt_ptr; in mpt_execute_req_a64()
1288 req = ccb->ccb_h.ccb_req_ptr; in mpt_execute_req_a64()
1290 hdrp = req->req_vbuf; in mpt_execute_req_a64()
1291 mpt_off = req->req_vbuf; in mpt_execute_req_a64()
1294 switch (hdrp->Function) { in mpt_execute_req_a64()
1298 sglp = &((PTR_MSG_SCSI_IO_REQUEST)hdrp)->SGL; in mpt_execute_req_a64()
1302 sglp = &((PTR_MSG_TARGET_ASSIST_REQUEST)hdrp)->SGL; in mpt_execute_req_a64()
1306 hdrp->Function); in mpt_execute_req_a64()
1317 if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG) { in mpt_execute_req_a64()
1323 if (mpt->outofbeer == 0) { in mpt_execute_req_a64()
1324 mpt->outofbeer = 1; in mpt_execute_req_a64()
1325 xpt_freeze_simq(mpt->sim, 1); in mpt_execute_req_a64()
1335 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) { in mpt_execute_req_a64()
1337 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id); in mpt_execute_req_a64()
1338 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM; in mpt_execute_req_a64()
1339 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL; in mpt_execute_req_a64()
1340 MPT_TGT_STATE(mpt, cmd_req)->req = NULL; in mpt_execute_req_a64()
1342 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_execute_req_a64()
1343 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); in mpt_execute_req_a64()
1354 if (mpt->verbose >= MPT_PRT_DEBUG) { in mpt_execute_req_a64()
1355 int tidx = ((char *)sglp) - mpt_off; in mpt_execute_req_a64()
1356 memset(&mpt_off[tidx], 0xff, MPT_REQUEST_AREA - tidx); in mpt_execute_req_a64()
1364 se1->FlagsLength = htole32(se1->FlagsLength); in mpt_execute_req_a64()
1370 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) { in mpt_execute_req_a64()
1374 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_execute_req_a64()
1379 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) { in mpt_execute_req_a64()
1382 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_execute_req_a64()
1388 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_execute_req_a64()
1394 bus_dmamap_sync(mpt->buffer_dmat, req->dmap, op); in mpt_execute_req_a64()
1413 first_lim = MPT_NSGL_FIRST(mpt) - 1; in mpt_execute_req_a64()
1420 MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len); in mpt_execute_req_a64()
1421 se->Address.Low = htole32(dm_segs->ds_addr & 0xffffffff); in mpt_execute_req_a64()
1423 addr = ((uint64_t)dm_segs->ds_addr) >> 32; in mpt_execute_req_a64()
1425 if (mpt->is_1078 && (((uint64_t)dm_segs->ds_addr + in mpt_execute_req_a64()
1426 MPI_SGE_LENGTH(se->FlagsLength)) >> 32) == 9) { in mpt_execute_req_a64()
1430 se->Address.High = htole32(addr); in mpt_execute_req_a64()
1432 if (seg == first_lim - 1) { in mpt_execute_req_a64()
1435 if (seg == nseg - 1) { in mpt_execute_req_a64()
1440 se->FlagsLength = htole32(se->FlagsLength); in mpt_execute_req_a64()
1450 hdrp->ChainOffset = ((char *)se - (char *)hdrp) >> 2; in mpt_execute_req_a64()
1495 chain_list_addr = trq->req_pbuf; in mpt_execute_req_a64()
1498 ce->Address.High = in mpt_execute_req_a64()
1501 ce->Address.Low = htole32(chain_list_addr & 0xffffffff); in mpt_execute_req_a64()
1502 ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT | in mpt_execute_req_a64()
1510 if ((nseg - seg) > MPT_NSGL(mpt)) { in mpt_execute_req_a64()
1511 this_seg_lim = seg + MPT_NSGL(mpt) - 1; in mpt_execute_req_a64()
1519 ce->Length = (this_seg_lim - seg) * in mpt_execute_req_a64()
1521 ce->NextChainOffset = ce->Length >> 2; in mpt_execute_req_a64()
1522 ce->Length += sizeof (SGE_CHAIN64); in mpt_execute_req_a64()
1525 ce->Length = (this_seg_lim - seg) * in mpt_execute_req_a64()
1528 ce->Length = htole16(ce->Length); in mpt_execute_req_a64()
1540 MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len); in mpt_execute_req_a64()
1541 se->Address.Low = htole32(dm_segs->ds_addr & in mpt_execute_req_a64()
1544 addr = ((uint64_t)dm_segs->ds_addr) >> 32; in mpt_execute_req_a64()
1546 if (mpt->is_1078 && in mpt_execute_req_a64()
1547 (((uint64_t)dm_segs->ds_addr + in mpt_execute_req_a64()
1548 MPI_SGE_LENGTH(se->FlagsLength)) >> in mpt_execute_req_a64()
1553 se->Address.High = htole32(addr); in mpt_execute_req_a64()
1555 if (seg == this_seg_lim - 1) { in mpt_execute_req_a64()
1558 if (seg == nseg - 1) { in mpt_execute_req_a64()
1563 se->FlagsLength = htole32(se->FlagsLength); in mpt_execute_req_a64()
1588 if ((trq = req->chain) == NULL) { in mpt_execute_req_a64()
1589 req->chain = nrq; in mpt_execute_req_a64()
1591 while (trq->chain != NULL) { in mpt_execute_req_a64()
1592 trq = trq->chain; in mpt_execute_req_a64()
1594 trq->chain = nrq; in mpt_execute_req_a64()
1597 mpt_off = trq->req_vbuf; in mpt_execute_req_a64()
1598 if (mpt->verbose >= MPT_PRT_DEBUG) { in mpt_execute_req_a64()
1609 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { in mpt_execute_req_a64()
1610 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) { in mpt_execute_req_a64()
1612 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id); in mpt_execute_req_a64()
1613 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM; in mpt_execute_req_a64()
1614 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL; in mpt_execute_req_a64()
1615 MPT_TGT_STATE(mpt, cmd_req)->req = NULL; in mpt_execute_req_a64()
1619 ccb->ccb_h.status & CAM_STATUS_MASK); in mpt_execute_req_a64()
1621 bus_dmamap_unload(mpt->buffer_dmat, req->dmap); in mpt_execute_req_a64()
1623 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_execute_req_a64()
1624 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); in mpt_execute_req_a64()
1630 ccb->ccb_h.status |= CAM_SIM_QUEUED; in mpt_execute_req_a64()
1631 if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) { in mpt_execute_req_a64()
1632 mpt_req_timeout(req, SBT_1MS * ccb->ccb_h.timeout, in mpt_execute_req_a64()
1635 if (mpt->verbose > MPT_PRT_DEBUG) { in mpt_execute_req_a64()
1637 mpt_print_request(req->req_vbuf); in mpt_execute_req_a64()
1638 for (trq = req->chain; trq; trq = trq->chain) { in mpt_execute_req_a64()
1640 mpt_dump_sgl(trq->req_vbuf, 0); in mpt_execute_req_a64()
1644 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) { in mpt_execute_req_a64()
1645 request_t *cmd_req = MPT_TAG_2_REQ(mpt, ccb->csio.tag_id); in mpt_execute_req_a64()
1648 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) && in mpt_execute_req_a64()
1649 csio->scsi_status == SCSI_STATUS_OK && tgt->resid == 0) { in mpt_execute_req_a64()
1650 tgt->state = TGT_STATE_MOVING_DATA_AND_STATUS; in mpt_execute_req_a64()
1652 tgt->state = TGT_STATE_MOVING_DATA; in mpt_execute_req_a64()
1655 tgt->state = TGT_STATE_MOVING_DATA; in mpt_execute_req_a64()
1677 ccb = req->ccb; in mpt_execute_req()
1679 mpt = ccb->ccb_h.ccb_mpt_ptr; in mpt_execute_req()
1680 req = ccb->ccb_h.ccb_req_ptr; in mpt_execute_req()
1682 hdrp = req->req_vbuf; in mpt_execute_req()
1683 mpt_off = req->req_vbuf; in mpt_execute_req()
1686 switch (hdrp->Function) { in mpt_execute_req()
1689 sglp = &((PTR_MSG_SCSI_IO_REQUEST)hdrp)->SGL; in mpt_execute_req()
1693 sglp = &((PTR_MSG_TARGET_ASSIST_REQUEST)hdrp)->SGL; in mpt_execute_req()
1697 hdrp->Function); in mpt_execute_req()
1708 if ((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_INPROG) { in mpt_execute_req()
1714 if (mpt->outofbeer == 0) { in mpt_execute_req()
1715 mpt->outofbeer = 1; in mpt_execute_req()
1716 xpt_freeze_simq(mpt->sim, 1); in mpt_execute_req()
1726 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) { in mpt_execute_req()
1728 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id); in mpt_execute_req()
1729 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM; in mpt_execute_req()
1730 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL; in mpt_execute_req()
1731 MPT_TGT_STATE(mpt, cmd_req)->req = NULL; in mpt_execute_req()
1733 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_execute_req()
1734 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); in mpt_execute_req()
1745 if (mpt->verbose >= MPT_PRT_DEBUG) { in mpt_execute_req()
1746 int tidx = ((char *)sglp) - mpt_off; in mpt_execute_req()
1747 memset(&mpt_off[tidx], 0xff, MPT_REQUEST_AREA - tidx); in mpt_execute_req()
1755 se1->FlagsLength = htole32(se1->FlagsLength); in mpt_execute_req()
1761 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) { in mpt_execute_req()
1765 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_execute_req()
1770 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) { in mpt_execute_req()
1773 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_execute_req()
1779 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_execute_req()
1785 bus_dmamap_sync(mpt->buffer_dmat, req->dmap, op); in mpt_execute_req()
1804 first_lim = MPT_NSGL_FIRST(mpt) - 1; in mpt_execute_req()
1812 se->Address = htole32(dm_segs->ds_addr); in mpt_execute_req()
1814 MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len); in mpt_execute_req()
1816 if (seg == first_lim - 1) { in mpt_execute_req()
1819 if (seg == nseg - 1) { in mpt_execute_req()
1824 se->FlagsLength = htole32(se->FlagsLength); in mpt_execute_req()
1834 hdrp->ChainOffset = ((char *)se - (char *)hdrp) >> 2; in mpt_execute_req()
1883 chain_list_addr = trq->req_pbuf; in mpt_execute_req()
1886 ce->Address = htole32(chain_list_addr); in mpt_execute_req()
1887 ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT; in mpt_execute_req()
1894 if ((nseg - seg) > MPT_NSGL(mpt)) { in mpt_execute_req()
1895 this_seg_lim = seg + MPT_NSGL(mpt) - 1; in mpt_execute_req()
1903 ce->Length = (this_seg_lim - seg) * in mpt_execute_req()
1905 ce->NextChainOffset = ce->Length >> 2; in mpt_execute_req()
1906 ce->Length += sizeof (SGE_CHAIN32); in mpt_execute_req()
1909 ce->Length = (this_seg_lim - seg) * in mpt_execute_req()
1912 ce->Length = htole16(ce->Length); in mpt_execute_req()
1923 se->Address = htole32(dm_segs->ds_addr); in mpt_execute_req()
1925 MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len); in mpt_execute_req()
1927 if (seg == this_seg_lim - 1) { in mpt_execute_req()
1930 if (seg == nseg - 1) { in mpt_execute_req()
1935 se->FlagsLength = htole32(se->FlagsLength); in mpt_execute_req()
1960 if ((trq = req->chain) == NULL) { in mpt_execute_req()
1961 req->chain = nrq; in mpt_execute_req()
1963 while (trq->chain != NULL) { in mpt_execute_req()
1964 trq = trq->chain; in mpt_execute_req()
1966 trq->chain = nrq; in mpt_execute_req()
1969 mpt_off = trq->req_vbuf; in mpt_execute_req()
1970 if (mpt->verbose >= MPT_PRT_DEBUG) { in mpt_execute_req()
1981 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) { in mpt_execute_req()
1982 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) { in mpt_execute_req()
1984 MPT_TAG_2_REQ(mpt, ccb->csio.tag_id); in mpt_execute_req()
1985 MPT_TGT_STATE(mpt, cmd_req)->state = TGT_STATE_IN_CAM; in mpt_execute_req()
1986 MPT_TGT_STATE(mpt, cmd_req)->ccb = NULL; in mpt_execute_req()
1987 MPT_TGT_STATE(mpt, cmd_req)->req = NULL; in mpt_execute_req()
1991 ccb->ccb_h.status & CAM_STATUS_MASK); in mpt_execute_req()
1993 bus_dmamap_unload(mpt->buffer_dmat, req->dmap); in mpt_execute_req()
1995 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_execute_req()
1996 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); in mpt_execute_req()
2002 ccb->ccb_h.status |= CAM_SIM_QUEUED; in mpt_execute_req()
2003 if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) { in mpt_execute_req()
2004 mpt_req_timeout(req, SBT_1MS * ccb->ccb_h.timeout, in mpt_execute_req()
2007 if (mpt->verbose > MPT_PRT_DEBUG) { in mpt_execute_req()
2009 mpt_print_request(req->req_vbuf); in mpt_execute_req()
2010 for (trq = req->chain; trq; trq = trq->chain) { in mpt_execute_req()
2012 mpt_dump_sgl(trq->req_vbuf, 0); in mpt_execute_req()
2016 if (hdrp->Function == MPI_FUNCTION_TARGET_ASSIST) { in mpt_execute_req()
2017 request_t *cmd_req = MPT_TAG_2_REQ(mpt, ccb->csio.tag_id); in mpt_execute_req()
2020 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) && in mpt_execute_req()
2021 csio->scsi_status == SCSI_STATUS_OK && tgt->resid == 0) { in mpt_execute_req()
2022 tgt->state = TGT_STATE_MOVING_DATA_AND_STATUS; in mpt_execute_req()
2024 tgt->state = TGT_STATE_MOVING_DATA; in mpt_execute_req()
2027 tgt->state = TGT_STATE_MOVING_DATA; in mpt_execute_req()
2039 struct ccb_scsiio *csio = &ccb->csio; in mpt_start()
2040 struct ccb_hdr *ccbh = &ccb->ccb_h; in mpt_start()
2047 mpt = ccb->ccb_h.ccb_mpt_ptr; in mpt_start()
2048 raid_passthru = (sim == mpt->phydisk_sim); in mpt_start()
2051 if (mpt->outofbeer == 0) { in mpt_start()
2052 mpt->outofbeer = 1; in mpt_start()
2053 xpt_freeze_simq(mpt->sim, 1); in mpt_start()
2056 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_start()
2075 req->ccb = ccb; in mpt_start()
2076 ccb->ccb_h.ccb_req_ptr = req; in mpt_start()
2079 mpt_req = req->req_vbuf; in mpt_start()
2082 mpt_req->Function = MPI_FUNCTION_SCSI_IO_REQUEST; in mpt_start()
2084 mpt_req->Function = MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH; in mpt_start()
2086 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_start()
2091 mpt_req->Bus = 0; /* we never set bus here */ in mpt_start()
2093 tgt = ccb->ccb_h.target_id; in mpt_start()
2094 mpt_req->Bus = 0; /* XXX */ in mpt_start()
2097 mpt_req->SenseBufferLength = in mpt_start()
2098 (csio->sense_len < MPT_SENSE_SIZE) ? in mpt_start()
2099 csio->sense_len : MPT_SENSE_SIZE; in mpt_start()
2105 mpt_req->MsgContext = htole32(req->index | scsi_io_handler_id); in mpt_start()
2108 mpt_req->TargetID = tgt; in mpt_start()
2110 be64enc(mpt_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(ccb->ccb_h.target_lun)); in mpt_start()
2113 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_start()
2114 mpt_req->Control = MPI_SCSIIO_CONTROL_READ; in mpt_start()
2115 } else if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT) { in mpt_start()
2116 mpt_req->Control = MPI_SCSIIO_CONTROL_WRITE; in mpt_start()
2118 mpt_req->Control = MPI_SCSIIO_CONTROL_NODATATRANSFER; in mpt_start()
2121 if ((ccb->ccb_h.flags & CAM_TAG_ACTION_VALID) != 0) { in mpt_start()
2122 switch(ccb->csio.tag_action) { in mpt_start()
2124 mpt_req->Control |= MPI_SCSIIO_CONTROL_HEADOFQ; in mpt_start()
2127 mpt_req->Control |= MPI_SCSIIO_CONTROL_ACAQ; in mpt_start()
2130 mpt_req->Control |= MPI_SCSIIO_CONTROL_ORDEREDQ; in mpt_start()
2134 mpt_req->Control |= MPI_SCSIIO_CONTROL_SIMPLEQ; in mpt_start()
2138 if (mpt->is_fc || mpt->is_sas) { in mpt_start()
2139 mpt_req->Control |= MPI_SCSIIO_CONTROL_SIMPLEQ; in mpt_start()
2142 mpt_req->Control |= MPI_SCSIIO_CONTROL_UNTAGGED; in mpt_start()
2146 if (mpt->is_spi) { in mpt_start()
2147 if (ccb->ccb_h.flags & CAM_DIS_DISCONNECT) { in mpt_start()
2148 mpt_req->Control |= MPI_SCSIIO_CONTROL_NO_DISCONNECT; in mpt_start()
2151 mpt_req->Control = htole32(mpt_req->Control); in mpt_start()
2154 if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0) { in mpt_start()
2155 bcopy(csio->cdb_io.cdb_ptr, mpt_req->CDB, csio->cdb_len); in mpt_start()
2157 bcopy(csio->cdb_io.cdb_bytes, mpt_req->CDB, csio->cdb_len); in mpt_start()
2160 mpt_req->CDBLength = csio->cdb_len; in mpt_start()
2161 mpt_req->DataLength = htole32(csio->dxfer_len); in mpt_start()
2162 mpt_req->SenseBufferLowAddr = htole32(req->sense_pbuf); in mpt_start()
2167 if (mpt->verbose == MPT_PRT_DEBUG) { in mpt_start()
2170 (mpt_req->Function == MPI_FUNCTION_SCSI_IO_REQUEST)? in mpt_start()
2171 "SCSI_IO_REQUEST" : "SCSI_IO_PASSTHRU", mpt_req->CDB[0]); in mpt_start()
2172 df = mpt_req->Control & MPI_SCSIIO_CONTROL_DATADIRECTION_MASK; in mpt_start()
2176 "read" : "write", csio->dxfer_len, in mpt_start()
2177 (csio->dxfer_len == 1)? ")" : "s)"); in mpt_start()
2180 (uintmax_t)ccb->ccb_h.target_lun, req, req->serno); in mpt_start()
2183 error = bus_dmamap_load_ccb(mpt->buffer_dmat, req->dmap, ccb, cb, in mpt_start()
2190 xpt_freeze_simq(mpt->sim, 1); in mpt_start()
2191 ccbh->status |= CAM_RELEASE_SIMQ; in mpt_start()
2207 mpt->is_fc ? MPI_SCSITASKMGMT_MSGFLAGS_LIP_RESET_OPTION : 0, in mpt_bus_reset()
2224 error = mpt_wait_req(mpt, mpt->tmf_req, REQ_STATE_DONE, in mpt_bus_reset()
2227 status = le16toh(mpt->tmf_req->IOCStatus); in mpt_bus_reset()
2228 response = mpt->tmf_req->ResponseCode; in mpt_bus_reset()
2229 mpt->tmf_req->state = REQ_STATE_FREE; in mpt_bus_reset()
2232 mpt_prt(mpt, "mpt_bus_reset: Reset timed-out. " in mpt_bus_reset()
2266 fc = req->req_vbuf; in mpt_fc_reset_link()
2268 fc->SendFlags = MPI_FC_PRIM_SEND_FLAGS_RESET_LINK; in mpt_fc_reset_link()
2269 fc->Function = MPI_FUNCTION_FC_PRIMITIVE_SEND; in mpt_fc_reset_link()
2270 fc->MsgContext = htole32(req->index | fc_els_handler_id); in mpt_fc_reset_link()
2288 data0 = le32toh(msg->Data[0]); in mpt_cam_event()
2289 data1 = le32toh(msg->Data[1]); in mpt_cam_event()
2290 switch(msg->Event & 0xFF) { in mpt_cam_event()
2300 xpt_async(AC_BUS_RESET, mpt->path, NULL); in mpt_cam_event()
2310 xpt_async(AC_BUS_RESET, mpt->path, NULL); in mpt_cam_event()
2321 if (mpt->ready == 0) { in mpt_cam_event()
2324 if (mpt->phydisk_sim) { in mpt_cam_event()
2325 pathid = cam_sim_path(mpt->phydisk_sim); in mpt_cam_event()
2327 pathid = cam_sim_path(mpt->sim); in mpt_cam_event()
2339 if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid, in mpt_cam_event()
2429 pqf = (PTR_EVENT_DATA_QUEUE_FULL)msg->Data; in mpt_cam_event()
2430 pqf->CurrentDepth = le16toh(pqf->CurrentDepth); in mpt_cam_event()
2434 pqf->Bus, pqf->TargetID, pqf->CurrentDepth); in mpt_cam_event()
2436 if (mpt->phydisk_sim && mpt_is_raid_member(mpt, in mpt_cam_event()
2437 pqf->TargetID) != 0) { in mpt_cam_event()
2438 sim = mpt->phydisk_sim; in mpt_cam_event()
2440 sim = mpt->sim; in mpt_cam_event()
2444 pqf->TargetID, lun_id) != CAM_REQ_CMP) { in mpt_cam_event()
2454 crs.openings = pqf->CurrentDepth - 1; in mpt_cam_event()
2474 psdsc = (PTR_EVENT_DATA_SAS_DEVICE_STATUS_CHANGE)msg->Data; in mpt_cam_event()
2475 if (mpt->phydisk_sim && mpt_is_raid_member(mpt, in mpt_cam_event()
2476 psdsc->TargetID) != 0) in mpt_cam_event()
2477 sim = mpt->phydisk_sim; in mpt_cam_event()
2479 sim = mpt->sim; in mpt_cam_event()
2480 switch(psdsc->ReasonCode) { in mpt_cam_event()
2488 if (xpt_create_path(&ccb->ccb_h.path, NULL, in mpt_cam_event()
2489 cam_sim_path(sim), psdsc->TargetID, in mpt_cam_event()
2500 psdsc->TargetID, CAM_LUN_WILDCARD) != in mpt_cam_event()
2516 "0x%02x ReasonCode: 0x%02x\n", psdsc->Bus, in mpt_cam_event()
2517 psdsc->TargetID, psdsc->ReasonCode); in mpt_cam_event()
2526 pde = (PTR_EVENT_DATA_DISCOVERY_ERROR)msg->Data; in mpt_cam_event()
2527 pde->DiscoveryStatus = le32toh(pde->DiscoveryStatus); in mpt_cam_event()
2530 pde->Port, pde->DiscoveryStatus); in mpt_cam_event()
2543 msg->Event & 0xFF); in mpt_cam_event()
2556 * offloaded to non-inlined helper routines to minimize
2566 if (req->state == REQ_STATE_FREE) { in mpt_scsi_reply_handler()
2571 scsi_req = (MSG_SCSI_IO_REQUEST *)req->req_vbuf; in mpt_scsi_reply_handler()
2572 ccb = req->ccb; in mpt_scsi_reply_handler()
2575 req, req->serno); in mpt_scsi_reply_handler()
2580 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_scsi_reply_handler()
2582 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) { in mpt_scsi_reply_handler()
2585 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) in mpt_scsi_reply_handler()
2589 bus_dmamap_sync(mpt->buffer_dmat, req->dmap, op); in mpt_scsi_reply_handler()
2590 bus_dmamap_unload(mpt->buffer_dmat, req->dmap); in mpt_scsi_reply_handler()
2597 ccb->csio.resid = 0; in mpt_scsi_reply_handler()
2599 ccb->csio.scsi_status = SCSI_STATUS_OK; in mpt_scsi_reply_handler()
2604 if (mpt->outofbeer) { in mpt_scsi_reply_handler()
2605 ccb->ccb_h.status |= CAM_RELEASE_SIMQ; in mpt_scsi_reply_handler()
2606 mpt->outofbeer = 0; in mpt_scsi_reply_handler()
2609 if (scsi_req->CDB[0] == INQUIRY && (scsi_req->CDB[1] & SI_EVPD) == 0) { in mpt_scsi_reply_handler()
2611 (struct scsi_inquiry_data *)ccb->csio.data_ptr; in mpt_scsi_reply_handler()
2612 if (scsi_req->Function == in mpt_scsi_reply_handler()
2616 * pass-thru device will attach. in mpt_scsi_reply_handler()
2618 iq->device &= ~0x1F; in mpt_scsi_reply_handler()
2619 iq->device |= T_NODEVICE; in mpt_scsi_reply_handler()
2622 if (mpt->verbose == MPT_PRT_DEBUG) { in mpt_scsi_reply_handler()
2624 req, req->serno); in mpt_scsi_reply_handler()
2626 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); in mpt_scsi_reply_handler()
2628 if ((req->state & REQ_STATE_TIMEDOUT) == 0) { in mpt_scsi_reply_handler()
2629 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_scsi_reply_handler()
2632 req, req->serno); in mpt_scsi_reply_handler()
2633 TAILQ_REMOVE(&mpt->request_timeout_list, req, links); in mpt_scsi_reply_handler()
2635 KASSERT((req->state & REQ_STATE_NEED_WAKEUP) == 0, in mpt_scsi_reply_handler()
2650 KASSERT(req == mpt->tmf_req, ("TMF Reply not using mpt->tmf_req")); in mpt_scsi_tmf_reply_handler()
2656 req->IOCStatus = le16toh(tmf_reply->IOCStatus); in mpt_scsi_tmf_reply_handler()
2657 req->ResponseCode = tmf_reply->ResponseCode; in mpt_scsi_tmf_reply_handler()
2660 req, req->serno, le16toh(tmf_reply->IOCStatus)); in mpt_scsi_tmf_reply_handler()
2661 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_scsi_tmf_reply_handler()
2662 if ((req->state & REQ_STATE_NEED_WAKEUP) != 0) { in mpt_scsi_tmf_reply_handler()
2663 req->state |= REQ_STATE_DONE; in mpt_scsi_tmf_reply_handler()
2666 mpt->tmf_req->state = REQ_STATE_FREE; in mpt_scsi_tmf_reply_handler()
2707 rsp->RspFlags = LINK_SERVICE_RSP_FLAGS_IMMEDIATE; in mpt_fc_els_send_response()
2709 rsp->RspLength = length; in mpt_fc_els_send_response()
2710 rsp->Function = MPI_FUNCTION_FC_LINK_SRVC_RSP; in mpt_fc_els_send_response()
2711 rsp->MsgContext = htole32(req->index | fc_els_handler_id); in mpt_fc_els_send_response()
2722 memcpy(req->req_vbuf, rsp, sizeof (MSG_LINK_SERVICE_RSP_REQUEST)); in mpt_fc_els_send_response()
2723 rsp = req->req_vbuf; in mpt_fc_els_send_response()
2726 memcpy((U8 *)&rsp->SGL, &((U8 *)req->req_vbuf)[MPT_RQSL(mpt)], length); in mpt_fc_els_send_response()
2729 PTR_SGE_SIMPLE32 se = (PTR_SGE_SIMPLE32) &rsp->SGL; in mpt_fc_els_send_response()
2730 bus_addr_t paddr = req->req_pbuf; in mpt_fc_els_send_response()
2741 se->FlagsLength = htole32(fl); in mpt_fc_els_send_response()
2742 se->Address = htole32((uint32_t) paddr); in mpt_fc_els_send_response()
2761 U16 status = le16toh(reply_frame->IOCStatus); in mpt_fc_els_reply_handler()
2769 req, req->serno, rp->Function)); in mpt_fc_els_reply_handler()
2770 if (rp->Function != MPI_FUNCTION_FC_PRIMITIVE_SEND) { in mpt_fc_els_reply_handler()
2778 req, req->serno, reply_frame, reply_frame->Function); in mpt_fc_els_reply_handler()
2782 status, reply_frame->Function); in mpt_fc_els_reply_handler()
2787 mpt->disabled = 1; in mpt_fc_els_reply_handler()
2800 if (rp->Function == MPI_FUNCTION_FC_LINK_SRVC_RSP) { in mpt_fc_els_reply_handler()
2803 for (ioindex = 0; ioindex < mpt->els_cmds_allocated; ioindex++) in mpt_fc_els_reply_handler()
2804 if (mpt->els_cmd_ptrs[ioindex] == req) { in mpt_fc_els_reply_handler()
2808 KASSERT(ioindex < mpt->els_cmds_allocated, in mpt_fc_els_reply_handler()
2811 /* remove from active list as we're going to re-post it */ in mpt_fc_els_reply_handler()
2812 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_fc_els_reply_handler()
2813 req->state &= ~REQ_STATE_QUEUED; in mpt_fc_els_reply_handler()
2814 req->state |= REQ_STATE_DONE; in mpt_fc_els_reply_handler()
2819 if (rp->Function == MPI_FUNCTION_FC_PRIMITIVE_SEND) { in mpt_fc_els_reply_handler()
2821 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_fc_els_reply_handler()
2822 req->state &= ~REQ_STATE_QUEUED; in mpt_fc_els_reply_handler()
2823 req->state |= REQ_STATE_DONE; in mpt_fc_els_reply_handler()
2824 if (req->state & REQ_STATE_TIMEDOUT) { in mpt_fc_els_reply_handler()
2828 } else if ((req->state & REQ_STATE_NEED_WAKEUP) == 0) { in mpt_fc_els_reply_handler()
2834 "Sync Primitive Send Complete- Waking Waiter\n"); in mpt_fc_els_reply_handler()
2840 if (rp->Function != MPI_FUNCTION_FC_LINK_SRVC_BUF_POST) { in mpt_fc_els_reply_handler()
2842 "Length %d Message Flags %x\n", rp->Function, rp->Flags, in mpt_fc_els_reply_handler()
2843 rp->MsgLength, rp->MsgFlags); in mpt_fc_els_reply_handler()
2847 if (rp->MsgLength <= 5) { in mpt_fc_els_reply_handler()
2852 "RECV'd ACK of FC_ELS buf post %p:%u\n", req, req->serno); in mpt_fc_els_reply_handler()
2856 rctl = (le32toh(rp->Rctl_Did) & MPI_FC_RCTL_MASK) >> MPI_FC_RCTL_SHIFT; in mpt_fc_els_reply_handler()
2857 type = (le32toh(rp->Type_Fctl) & MPI_FC_TYPE_MASK) >> MPI_FC_TYPE_SHIFT; in mpt_fc_els_reply_handler()
2859 elsbuf = &((U32 *)req->req_vbuf)[MPT_RQSL(mpt)/sizeof (U32)]; in mpt_fc_els_reply_handler()
2862 if (rp->Flags & MPI_LS_BUF_POST_REPLY_FLAG_NO_RSP_NEEDED) { in mpt_fc_els_reply_handler()
2867 ioindex = le32toh(rp->TransactionContext); in mpt_fc_els_reply_handler()
2868 req = mpt->els_cmd_ptrs[ioindex]; in mpt_fc_els_reply_handler()
2877 le32toh(rp->Wwn.PortNameHigh), in mpt_fc_els_reply_handler()
2878 le32toh(rp->Wwn.PortNameLow)); in mpt_fc_els_reply_handler()
2882 if (mpt->role & MPT_ROLE_TARGET) in mpt_fc_els_reply_handler()
2884 if (mpt->role & MPT_ROLE_INITIATOR) in mpt_fc_els_reply_handler()
2887 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_fc_els_reply_handler()
2888 req->state &= ~REQ_STATE_QUEUED; in mpt_fc_els_reply_handler()
2889 req->state |= REQ_STATE_DONE; in mpt_fc_els_reply_handler()
2898 le32toh(rp->Wwn.PortNameHigh), in mpt_fc_els_reply_handler()
2899 le32toh(rp->Wwn.PortNameLow)); in mpt_fc_els_reply_handler()
2901 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_fc_els_reply_handler()
2902 req->state &= ~REQ_STATE_QUEUED; in mpt_fc_els_reply_handler()
2903 req->state |= REQ_STATE_DONE; in mpt_fc_els_reply_handler()
2912 uint16_t rx_id = le16toh(rp->Rxid); in mpt_fc_els_reply_handler()
2913 uint16_t ox_id = le16toh(rp->Oxid); in mpt_fc_els_reply_handler()
2921 ox_id, rx_id, le32toh(rp->Wwn.PortNameHigh), in mpt_fc_els_reply_handler()
2922 le32toh(rp->Wwn.PortNameLow)); in mpt_fc_els_reply_handler()
2923 if (rx_id >= mpt->mpt_max_tgtcmds) { in mpt_fc_els_reply_handler()
2925 } else if (mpt->tgt_cmd_ptrs == NULL) { in mpt_fc_els_reply_handler()
2928 tgt_req = mpt->tgt_cmd_ptrs[rx_id]; in mpt_fc_els_reply_handler()
2937 ct_id = GET_IO_INDEX(tgt->reply_desc); in mpt_fc_els_reply_handler()
2943 if (tgt->itag != ox_id) { in mpt_fc_els_reply_handler()
2945 "OX_ID received=0x%x, in cmd=0x%x\n", ox_id, tgt->itag); in mpt_fc_els_reply_handler()
2949 if ((ccb = tgt->ccb) != NULL) { in mpt_fc_els_reply_handler()
2951 ccb, (uintmax_t)ccb->ccb_h.target_lun, in mpt_fc_els_reply_handler()
2952 ccb->ccb_h.flags, ccb->ccb_h.status); in mpt_fc_els_reply_handler()
2955 "%x nxfers %x\n", tgt->state, tgt->resid, in mpt_fc_els_reply_handler()
2956 tgt->bytes_xfered, tgt->reply_desc, tgt->nxfers); in mpt_fc_els_reply_handler()
2969 rp->Rctl_Did += ((BA_ACC - ABTS) << MPI_FC_RCTL_SHIFT); in mpt_fc_els_reply_handler()
2971 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_fc_els_reply_handler()
2972 req->state &= ~REQ_STATE_QUEUED; in mpt_fc_els_reply_handler()
2973 req->state |= REQ_STATE_DONE; in mpt_fc_els_reply_handler()
2981 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_fc_els_reply_handler()
2982 req->state &= ~REQ_STATE_QUEUED; in mpt_fc_els_reply_handler()
2983 req->state |= REQ_STATE_DONE; in mpt_fc_els_reply_handler()
3002 mpt_complete_request_chain(mpt, &mpt->request_timeout_list, in mpt_cam_ioc_reset()
3012 xpt_async(AC_BUS_RESET, mpt->path, NULL); in mpt_cam_ioc_reset()
3029 KASSERT(reply_frame->Function == MPI_FUNCTION_SCSI_IO_REQUEST in mpt_scsi_reply_frame_handler()
3030 || reply_frame->Function == MPI_FUNCTION_RAID_SCSI_IO_PASSTHROUGH, in mpt_scsi_reply_frame_handler()
3032 KASSERT((reply_frame->MsgFlags & MPI_MSGFLAGS_CONTINUATION_REPLY) == 0, in mpt_scsi_reply_frame_handler()
3036 ioc_status = le16toh(scsi_io_reply->IOCStatus); in mpt_scsi_reply_frame_handler()
3038 sstate = scsi_io_reply->SCSIState; in mpt_scsi_reply_frame_handler()
3040 ccb = req->ccb; in mpt_scsi_reply_frame_handler()
3041 ccb->csio.resid = in mpt_scsi_reply_frame_handler()
3042 ccb->csio.dxfer_len - le32toh(scsi_io_reply->TransferCount); in mpt_scsi_reply_frame_handler()
3045 && (ccb->ccb_h.flags & (CAM_SENSE_PHYS | CAM_SENSE_PTR)) == 0) { in mpt_scsi_reply_frame_handler()
3048 ccb->ccb_h.status |= CAM_AUTOSNS_VALID; in mpt_scsi_reply_frame_handler()
3050 sense_returned = le32toh(scsi_io_reply->SenseCount); in mpt_scsi_reply_frame_handler()
3051 if (sense_returned < ccb->csio.sense_len) in mpt_scsi_reply_frame_handler()
3052 ccb->csio.sense_resid = ccb->csio.sense_len - in mpt_scsi_reply_frame_handler()
3055 ccb->csio.sense_resid = 0; in mpt_scsi_reply_frame_handler()
3057 bzero(&ccb->csio.sense_data, sizeof(ccb->csio.sense_data)); in mpt_scsi_reply_frame_handler()
3058 bcopy(req->sense_vbuf, &ccb->csio.sense_data, in mpt_scsi_reply_frame_handler()
3059 min(ccb->csio.sense_len, sense_returned)); in mpt_scsi_reply_frame_handler()
3064 * Tag messages rejected, but non-tagged retry in mpt_scsi_reply_frame_handler()
3077 * indicates a CRC error. in mpt_scsi_reply_frame_handler()
3082 if (scsi_io_reply->TransferCount == 0) { in mpt_scsi_reply_frame_handler()
3095 } else if (scsi_io_reply->SCSIStatus != SCSI_STATUS_OK) { in mpt_scsi_reply_frame_handler()
3096 ccb->csio.scsi_status = scsi_io_reply->SCSIStatus; in mpt_scsi_reply_frame_handler()
3101 /* XXX Handle SPI-Packet and FCP-2 response info. */ in mpt_scsi_reply_frame_handler()
3133 ccb->ccb_h.status = CAM_UA_TERMIO; in mpt_scsi_reply_frame_handler()
3141 ccb->ccb_h.status = CAM_SCSI_BUS_RESET; in mpt_scsi_reply_frame_handler()
3152 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_INPROG) in mpt_scsi_reply_frame_handler()
3172 ccb->ccb_h.status = CAM_UNREC_HBA_ERROR; in mpt_scsi_reply_frame_handler()
3176 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in mpt_scsi_reply_frame_handler()
3192 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("mpt_action\n")); in mpt_action()
3195 raid_passthru = (sim == mpt->phydisk_sim); in mpt_action()
3198 tgt = ccb->ccb_h.target_id; in mpt_action()
3199 lun = ccb->ccb_h.target_lun; in mpt_action()
3201 ccb->ccb_h.func_code != XPT_PATH_INQ && in mpt_action()
3202 ccb->ccb_h.func_code != XPT_RESET_BUS && in mpt_action()
3203 ccb->ccb_h.func_code != XPT_RESET_DEV) { in mpt_action()
3205 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_action()
3211 ccb->ccb_h.ccb_mpt_ptr = mpt; in mpt_action()
3213 switch (ccb->ccb_h.func_code) { in mpt_action()
3218 if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0) { in mpt_action()
3219 if ((ccb->ccb_h.flags & CAM_CDB_PHYS) != 0) { in mpt_action()
3220 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_action()
3227 if (ccb->csio.cdb_len > in mpt_action()
3228 sizeof (((PTR_MSG_SCSI_IO_REQUEST)0)->CDB)) { in mpt_action()
3229 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_action()
3234 if (mpt->failure_id == ccb->ccb_h.target_id) { in mpt_action()
3235 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_action()
3240 ccb->csio.scsi_status = SCSI_STATUS_OK; in mpt_action()
3246 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_action()
3251 if (ccb->ccb_h.func_code == XPT_RESET_BUS) { in mpt_action()
3253 xpt_print(ccb->ccb_h.path, "reset bus\n"); in mpt_action()
3256 xpt_print(ccb->ccb_h.path, "reset device\n"); in mpt_action()
3265 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_action()
3271 union ccb *accb = ccb->cab.abort_ccb; in mpt_action()
3272 switch (accb->ccb_h.func_code) { in mpt_action()
3275 ccb->ccb_h.status = mpt_abort_target_ccb(mpt, ccb); in mpt_action()
3279 ccb->ccb_h.status = CAM_UA_ABORT; in mpt_action()
3282 ccb->ccb_h.status = CAM_UA_ABORT; in mpt_action()
3285 ccb->ccb_h.status = CAM_REQ_INVALID; in mpt_action()
3291 #define IS_CURRENT_SETTINGS(c) ((c)->type == CTS_TYPE_CURRENT_SETTINGS) in mpt_action()
3310 struct ccb_trans_settings_spi *spi; in mpt_action() local
3316 cts = &ccb->cts; in mpt_action()
3318 if (mpt->is_fc || mpt->is_sas) { in mpt_action()
3323 scsi = &cts->proto_specific.scsi; in mpt_action()
3324 spi = &cts->xport_specific.spi; in mpt_action()
3329 if (scsi->valid == 0 && spi->valid == 0) { in mpt_action()
3338 if (mpt->phydisk_sim && raid_passthru == 0 && in mpt_action()
3346 i = mpt->mpt_port_page2.PortSettings & in mpt_action()
3348 j = mpt->mpt_port_page2.PortFlags & in mpt_action()
3362 if ((spi->valid & CTS_SPI_VALID_DISC) != 0) { in mpt_action()
3363 dval |= ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0) ? in mpt_action()
3367 if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) { in mpt_action()
3368 dval |= ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0) ? in mpt_action()
3372 if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) { in mpt_action()
3373 dval |= (spi->bus_width == MSG_EXT_WDTR_BUS_16_BIT) ? in mpt_action()
3377 if (spi->valid & CTS_SPI_VALID_SYNC_OFFSET) { in mpt_action()
3379 offset = spi->sync_offset; in mpt_action()
3382 &mpt->mpt_dev_page1[tgt]; in mpt_action()
3383 offset = ptr->RequestedParameters; in mpt_action()
3387 if (spi->valid & CTS_SPI_VALID_SYNC_RATE) { in mpt_action()
3389 period = spi->sync_period; in mpt_action()
3392 &mpt->mpt_dev_page1[tgt]; in mpt_action()
3393 period = ptr->RequestedParameters; in mpt_action()
3399 mpt->mpt_disc_enable |= (1 << tgt); in mpt_action()
3401 mpt->mpt_disc_enable &= ~(1 << tgt); in mpt_action()
3404 mpt->mpt_tag_enable |= (1 << tgt); in mpt_action()
3406 mpt->mpt_tag_enable &= ~(1 << tgt); in mpt_action()
3431 cts = &ccb->cts; in mpt_action()
3432 cts->protocol = PROTO_SCSI; in mpt_action()
3433 if (mpt->is_fc) { in mpt_action()
3435 &cts->xport_specific.fc; in mpt_action()
3436 cts->protocol_version = SCSI_REV_SPC; in mpt_action()
3437 cts->transport = XPORT_FC; in mpt_action()
3438 cts->transport_version = 0; in mpt_action()
3439 if (mpt->mpt_fcport_speed != 0) { in mpt_action()
3440 fc->valid = CTS_FC_VALID_SPEED; in mpt_action()
3441 fc->bitrate = 100000 * mpt->mpt_fcport_speed; in mpt_action()
3443 } else if (mpt->is_sas) { in mpt_action()
3445 &cts->xport_specific.sas; in mpt_action()
3446 cts->protocol_version = SCSI_REV_SPC2; in mpt_action()
3447 cts->transport = XPORT_SAS; in mpt_action()
3448 cts->transport_version = 0; in mpt_action()
3449 sas->valid = CTS_SAS_VALID_SPEED; in mpt_action()
3450 sas->bitrate = 300000; in mpt_action()
3452 cts->protocol_version = SCSI_REV_2; in mpt_action()
3453 cts->transport = XPORT_SPI; in mpt_action()
3454 cts->transport_version = 2; in mpt_action()
3460 scsi = &cts->proto_specific.scsi; in mpt_action()
3461 scsi->valid = CTS_SCSI_VALID_TQ; in mpt_action()
3462 scsi->flags = CTS_SCSI_FLAGS_TAG_ENB; in mpt_action()
3470 ccg = &ccb->ccg; in mpt_action()
3471 if (ccg->block_size == 0) { in mpt_action()
3472 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_action()
3477 KASSERT(ccb->ccb_h.status, ("zero ccb sts at %d", __LINE__)); in mpt_action()
3482 struct ccb_sim_knob *kp = &ccb->knob; in mpt_action()
3484 if (mpt->is_fc) { in mpt_action()
3485 kp->xport_specific.fc.wwnn = mpt->scinfo.fc.wwnn; in mpt_action()
3486 kp->xport_specific.fc.wwpn = mpt->scinfo.fc.wwpn; in mpt_action()
3487 switch (mpt->role) { in mpt_action()
3489 kp->xport_specific.fc.role = KNOB_ROLE_NONE; in mpt_action()
3492 kp->xport_specific.fc.role = KNOB_ROLE_INITIATOR; in mpt_action()
3495 kp->xport_specific.fc.role = KNOB_ROLE_TARGET; in mpt_action()
3498 kp->xport_specific.fc.role = KNOB_ROLE_BOTH; in mpt_action()
3501 kp->xport_specific.fc.valid = in mpt_action()
3503 ccb->ccb_h.status = CAM_REQ_CMP; in mpt_action()
3505 ccb->ccb_h.status = CAM_REQ_INVALID; in mpt_action()
3512 struct ccb_pathinq *cpi = &ccb->cpi; in mpt_action()
3514 cpi->version_num = 1; in mpt_action()
3515 cpi->target_sprt = 0; in mpt_action()
3516 cpi->hba_eng_cnt = 0; in mpt_action()
3517 cpi->max_target = mpt->port_facts[0].MaxDevices - 1; in mpt_action()
3518 cpi->maxio = (mpt->max_cam_seg_cnt - 1) * PAGE_SIZE; in mpt_action()
3526 if (cpi->max_target > 255) { in mpt_action()
3527 cpi->max_target = 255; in mpt_action()
3533 if (mpt->is_spi && cpi->max_target > 15) { in mpt_action()
3534 cpi->max_target = 15; in mpt_action()
3536 if (mpt->is_spi) in mpt_action()
3537 cpi->max_lun = 7; in mpt_action()
3539 cpi->max_lun = MPT_MAX_LUNS; in mpt_action()
3540 cpi->initiator_id = mpt->mpt_ini_id; in mpt_action()
3541 cpi->bus_id = cam_sim_bus(sim); in mpt_action()
3546 cpi->protocol = PROTO_SCSI; in mpt_action()
3547 if (mpt->is_fc) { in mpt_action()
3548 cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | in mpt_action()
3550 cpi->base_transfer_speed = 100000; in mpt_action()
3551 cpi->hba_inquiry = PI_TAG_ABLE; in mpt_action()
3552 cpi->transport = XPORT_FC; in mpt_action()
3553 cpi->transport_version = 0; in mpt_action()
3554 cpi->protocol_version = SCSI_REV_SPC; in mpt_action()
3555 cpi->xport_specific.fc.wwnn = mpt->scinfo.fc.wwnn; in mpt_action()
3556 cpi->xport_specific.fc.wwpn = mpt->scinfo.fc.wwpn; in mpt_action()
3557 cpi->xport_specific.fc.port = mpt->scinfo.fc.portid; in mpt_action()
3558 cpi->xport_specific.fc.bitrate = in mpt_action()
3559 100000 * mpt->mpt_fcport_speed; in mpt_action()
3560 } else if (mpt->is_sas) { in mpt_action()
3561 cpi->hba_misc = PIM_NOBUSRESET | PIM_UNMAPPED | in mpt_action()
3563 cpi->base_transfer_speed = 300000; in mpt_action()
3564 cpi->hba_inquiry = PI_TAG_ABLE; in mpt_action()
3565 cpi->transport = XPORT_SAS; in mpt_action()
3566 cpi->transport_version = 0; in mpt_action()
3567 cpi->protocol_version = SCSI_REV_SPC2; in mpt_action()
3569 cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | in mpt_action()
3571 cpi->base_transfer_speed = 3300; in mpt_action()
3572 cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE|PI_WIDE_16; in mpt_action()
3573 cpi->transport = XPORT_SPI; in mpt_action()
3574 cpi->transport_version = 2; in mpt_action()
3575 cpi->protocol_version = SCSI_REV_2; in mpt_action()
3583 cpi->max_target = mpt->ioc_page2->MaxPhysDisks - 1; in mpt_action()
3584 cpi->initiator_id = cpi->max_target + 1; in mpt_action()
3585 cpi->max_lun = 0; in mpt_action()
3588 if ((mpt->role & MPT_ROLE_INITIATOR) == 0) { in mpt_action()
3589 cpi->hba_misc |= PIM_NOINITIATOR; in mpt_action()
3591 if (mpt->is_fc && (mpt->role & MPT_ROLE_TARGET)) { in mpt_action()
3592 cpi->target_sprt = in mpt_action()
3595 cpi->target_sprt = 0; in mpt_action()
3597 strlcpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN); in mpt_action()
3598 strlcpy(cpi->hba_vid, "LSI", HBA_IDLEN); in mpt_action()
3599 strlcpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN); in mpt_action()
3600 cpi->unit_number = cam_sim_unit(sim); in mpt_action()
3601 cpi->ccb_h.status = CAM_REQ_CMP; in mpt_action()
3608 if (ccb->cel.enable) in mpt_action()
3610 ccb->ccb_h.target_id, ccb->ccb_h.target_lun); in mpt_action()
3613 ccb->ccb_h.target_id, ccb->ccb_h.target_lun); in mpt_action()
3625 lun_id_t lun = ccb->ccb_h.target_lun; in mpt_action()
3626 ccb->ccb_h.sim_priv.entries[0].field = 0; in mpt_action()
3627 ccb->ccb_h.sim_priv.entries[1].ptr = mpt; in mpt_action()
3630 if (ccb->ccb_h.target_id != CAM_TARGET_WILDCARD) { in mpt_action()
3634 trtp = &mpt->trt_wildcard; in mpt_action()
3639 trtp = &mpt->trt[lun]; in mpt_action()
3641 if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { in mpt_action()
3644 STAILQ_INSERT_TAIL(&trtp->atios, &ccb->ccb_h, in mpt_action()
3649 STAILQ_INSERT_TAIL(&trtp->inots, &ccb->ccb_h, in mpt_action()
3657 request_t *req = MPT_TAG_2_REQ(mpt, ccb->cna2.tag_id); in mpt_action()
3669 ccb->ccb_h.status = CAM_REQ_INVALID; in mpt_action()
3678 struct ccb_trans_settings_scsi *scsi = &cts->proto_specific.scsi; in mpt_get_spi_settings()
3679 struct ccb_trans_settings_spi *spi = &cts->xport_specific.spi; in mpt_get_spi_settings() local
3685 tgt = cts->ccb_h.target_id; in mpt_get_spi_settings()
3686 } else if (xpt_path_sim(cts->ccb_h.path) == mpt->phydisk_sim) { in mpt_get_spi_settings()
3688 return (-1); in mpt_get_spi_settings()
3691 tgt = cts->ccb_h.target_id; in mpt_get_spi_settings()
3695 * We aren't looking at Port Page 2 BIOS settings here- in mpt_get_spi_settings()
3707 tmp = mpt->mpt_dev_page0[tgt]; in mpt_get_spi_settings()
3721 dval |= (mpt->mpt_disc_enable & (1 << tgt)) ? in mpt_get_spi_settings()
3723 dval |= (mpt->mpt_tag_enable & (1 << tgt)) ? in mpt_get_spi_settings()
3731 mpt->mpt_dev_page0[tgt] = tmp; in mpt_get_spi_settings()
3734 oval = mpt->mpt_port_page0.Capabilities; in mpt_get_spi_settings()
3736 pval = mpt->mpt_port_page0.Capabilities; in mpt_get_spi_settings()
3740 spi->valid = 0; in mpt_get_spi_settings()
3741 scsi->valid = 0; in mpt_get_spi_settings()
3742 spi->flags = 0; in mpt_get_spi_settings()
3743 scsi->flags = 0; in mpt_get_spi_settings()
3744 spi->sync_offset = oval; in mpt_get_spi_settings()
3745 spi->sync_period = pval; in mpt_get_spi_settings()
3746 spi->valid |= CTS_SPI_VALID_SYNC_OFFSET; in mpt_get_spi_settings()
3747 spi->valid |= CTS_SPI_VALID_SYNC_RATE; in mpt_get_spi_settings()
3748 spi->valid |= CTS_SPI_VALID_BUS_WIDTH; in mpt_get_spi_settings()
3750 spi->bus_width = MSG_EXT_WDTR_BUS_16_BIT; in mpt_get_spi_settings()
3752 spi->bus_width = MSG_EXT_WDTR_BUS_8_BIT; in mpt_get_spi_settings()
3754 if (cts->ccb_h.target_lun != CAM_LUN_WILDCARD) { in mpt_get_spi_settings()
3755 scsi->valid = CTS_SCSI_VALID_TQ; in mpt_get_spi_settings()
3757 scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB; in mpt_get_spi_settings()
3759 spi->valid |= CTS_SPI_VALID_DISC; in mpt_get_spi_settings()
3761 spi->flags |= CTS_SPI_FLAGS_DISC_ENB; in mpt_get_spi_settings()
3776 ptr = &mpt->mpt_dev_page1[tgt]; in mpt_setwidth()
3778 ptr->RequestedParameters |= MPI_SCSIDEVPAGE1_RP_WIDE; in mpt_setwidth()
3780 ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_WIDE; in mpt_setwidth()
3789 ptr = &mpt->mpt_dev_page1[tgt]; in mpt_setsync()
3790 ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_MIN_SYNC_PERIOD_MASK; in mpt_setsync()
3791 ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_MAX_SYNC_OFFSET_MASK; in mpt_setsync()
3792 ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_DT; in mpt_setsync()
3793 ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_QAS; in mpt_setsync()
3794 ptr->RequestedParameters &= ~MPI_SCSIDEVPAGE1_RP_IU; in mpt_setsync()
3798 ptr->RequestedParameters |= in mpt_setsync()
3800 ptr->RequestedParameters |= in mpt_setsync()
3803 ptr->RequestedParameters |= MPI_SCSIDEVPAGE1_RP_DT; in mpt_setsync()
3806 ptr->RequestedParameters |= MPI_SCSIDEVPAGE1_RP_QAS; in mpt_setsync()
3807 ptr->RequestedParameters |= MPI_SCSIDEVPAGE1_RP_IU; in mpt_setsync()
3819 tgt, mpt->mpt_dev_page1[tgt].RequestedParameters); in mpt_update_spi_config()
3820 tmp = mpt->mpt_dev_page1[tgt]; in mpt_update_spi_config()
3826 return (-1); in mpt_update_spi_config()
3838 &mpt->recovery_thread, /*flags*/0, in mpt_spawn_recovery_thread()
3839 /*altstack*/0, "mpt_recovery%d", mpt->unit); in mpt_spawn_recovery_thread()
3847 if (mpt->recovery_thread == NULL) { in mpt_terminate_recovery_thread()
3850 mpt->shutdwn_recovery = 1; in mpt_terminate_recovery_thread()
3856 mpt_sleep(mpt, &mpt->recovery_thread, PUSER, "thtrm", 0); in mpt_terminate_recovery_thread()
3867 if (TAILQ_EMPTY(&mpt->request_timeout_list) != 0) { in mpt_recovery_thread()
3868 if (mpt->shutdwn_recovery == 0) { in mpt_recovery_thread()
3872 if (mpt->shutdwn_recovery != 0) { in mpt_recovery_thread()
3877 mpt->recovery_thread = NULL; in mpt_recovery_thread()
3878 wakeup(&mpt->recovery_thread); in mpt_recovery_thread()
3895 error = mpt_wait_req(mpt, mpt->tmf_req, REQ_STATE_FREE, REQ_STATE_FREE, in mpt_scsi_send_tmf()
3902 mpt_assign_serno(mpt, mpt->tmf_req); in mpt_scsi_send_tmf()
3903 mpt->tmf_req->state = REQ_STATE_ALLOCATED|REQ_STATE_QUEUED; in mpt_scsi_send_tmf()
3905 tmf_req = (MSG_SCSI_TASK_MGMT *)mpt->tmf_req->req_vbuf; in mpt_scsi_send_tmf()
3907 tmf_req->TargetID = target; in mpt_scsi_send_tmf()
3908 tmf_req->Bus = channel; in mpt_scsi_send_tmf()
3909 tmf_req->Function = MPI_FUNCTION_SCSI_TASK_MGMT; in mpt_scsi_send_tmf()
3910 tmf_req->TaskType = type; in mpt_scsi_send_tmf()
3911 tmf_req->MsgFlags = flags; in mpt_scsi_send_tmf()
3912 tmf_req->MsgContext = in mpt_scsi_send_tmf()
3913 htole32(mpt->tmf_req->index | scsi_tmf_handler_id); in mpt_scsi_send_tmf()
3914 be64enc(tmf_req->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); in mpt_scsi_send_tmf()
3915 tmf_req->TaskMsgContext = abort_ctx; in mpt_scsi_send_tmf()
3918 "Issuing TMF %p:%u with MsgContext of 0x%x\n", mpt->tmf_req, in mpt_scsi_send_tmf()
3919 mpt->tmf_req->serno, tmf_req->MsgContext); in mpt_scsi_send_tmf()
3920 if (mpt->verbose > MPT_PRT_DEBUG) { in mpt_scsi_send_tmf()
3924 KASSERT(mpt_req_on_pending_list(mpt, mpt->tmf_req) == 0, in mpt_scsi_send_tmf()
3926 TAILQ_INSERT_HEAD(&mpt->request_pending_list, mpt->tmf_req, links); in mpt_scsi_send_tmf()
3929 TAILQ_REMOVE(&mpt->request_pending_list, mpt->tmf_req, links); in mpt_scsi_send_tmf()
3930 mpt->tmf_req->state = REQ_STATE_FREE; in mpt_scsi_send_tmf()
3938 * and we wake our recovery thread. The MPT-Fusion architecture supports
3951 if (TAILQ_EMPTY(&mpt->request_timeout_list) != 0) { in mpt_recover_commands()
3953 * No work to do- leave. in mpt_recover_commands()
3964 if (TAILQ_EMPTY(&mpt->request_timeout_list) != 0) { in mpt_recover_commands()
3970 * requires or - more likely - interrupts in mpt_recover_commands()
3982 * order they timed-out. For initiator commands, we in mpt_recover_commands()
3986 while ((req = TAILQ_FIRST(&mpt->request_timeout_list)) != NULL) { in mpt_recover_commands()
3989 MSG_REQUEST_HEADER *hdrp = req->req_vbuf; in mpt_recover_commands()
3992 req, req->serno, hdrp->Function); in mpt_recover_commands()
3993 ccb = req->ccb; in mpt_recover_commands()
4006 switch (hdrp->Function) { in mpt_recover_commands()
4015 TAILQ_REMOVE(&mpt->request_timeout_list, req, links); in mpt_recover_commands()
4016 TAILQ_INSERT_HEAD(&mpt->request_pending_list, req, in mpt_recover_commands()
4023 0, 0, ccb->ccb_h.target_id, ccb->ccb_h.target_lun, in mpt_recover_commands()
4024 htole32(req->index | scsi_io_handler_id), TRUE); in mpt_recover_commands()
4035 error = mpt_wait_req(mpt, mpt->tmf_req, REQ_STATE_DONE, in mpt_recover_commands()
4038 status = le16toh(mpt->tmf_req->IOCStatus); in mpt_recover_commands()
4039 response = mpt->tmf_req->ResponseCode; in mpt_recover_commands()
4040 mpt->tmf_req->state = REQ_STATE_FREE; in mpt_recover_commands()
4046 mpt_prt(mpt, "mpt_recover_commands: abort timed-out. " in mpt_recover_commands()
4066 mpt_prt(mpt, "abort of req %p:%u completed\n", req, req->serno); in mpt_recover_commands()
4080 paddr = req->req_pbuf; in mpt_fc_post_els()
4083 fc = req->req_vbuf; in mpt_fc_post_els()
4085 fc->BufferCount = 1; in mpt_fc_post_els()
4086 fc->Function = MPI_FUNCTION_FC_LINK_SRVC_BUF_POST; in mpt_fc_post_els()
4087 fc->MsgContext = htole32(req->index | fc_els_handler_id); in mpt_fc_post_els()
4096 tep = (PTR_SGE_TRANSACTION32) &fc->SGL; in mpt_fc_post_els()
4098 tep->ContextSize = 4; in mpt_fc_post_els()
4099 tep->Flags = 0; in mpt_fc_post_els()
4100 tep->TransactionContext[0] = htole32(ioindex); in mpt_fc_post_els()
4102 se = (PTR_SGE_SIMPLE32) &tep->TransactionDetails[0]; in mpt_fc_post_els()
4110 fl |= (MPT_NRFM(mpt) - MPT_RQSL(mpt)); in mpt_fc_post_els()
4111 se->FlagsLength = htole32(fl); in mpt_fc_post_els()
4112 se->Address = htole32((uint32_t) paddr); in mpt_fc_post_els()
4115 req->index, ioindex, req, req->serno); in mpt_fc_post_els()
4116 KASSERT(((req->state & REQ_STATE_LOCKED) != 0), in mpt_fc_post_els()
4128 paddr = req->req_pbuf; in mpt_post_target_command()
4130 memset(req->req_vbuf, 0, MPT_REQUEST_AREA); in mpt_post_target_command()
4131 MPT_TGT_STATE(mpt, req)->state = TGT_STATE_LOADING; in mpt_post_target_command()
4133 fc = req->req_vbuf; in mpt_post_target_command()
4134 fc->BufferCount = 1; in mpt_post_target_command()
4135 fc->Function = MPI_FUNCTION_TARGET_CMD_BUFFER_POST; in mpt_post_target_command()
4136 fc->BufferLength = MIN(MPT_REQUEST_AREA - MPT_RQSL(mpt), UINT8_MAX); in mpt_post_target_command()
4137 fc->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); in mpt_post_target_command()
4139 cb = &fc->Buffer[0]; in mpt_post_target_command()
4140 cb->IoIndex = htole16(ioindex); in mpt_post_target_command()
4141 cb->u.PhysicalAddress32 = htole32((U32) paddr); in mpt_post_target_command()
4152 if (mpt->is_fc == 0) { in mpt_add_els_buffers()
4156 if (mpt->els_cmds_allocated) { in mpt_add_els_buffers()
4160 mpt->els_cmd_ptrs = malloc(MPT_MAX_ELS * sizeof (request_t *), in mpt_add_els_buffers()
4163 if (mpt->els_cmd_ptrs == NULL) { in mpt_add_els_buffers()
4175 req->state |= REQ_STATE_LOCKED; in mpt_add_els_buffers()
4176 mpt->els_cmd_ptrs[i] = req; in mpt_add_els_buffers()
4182 free(mpt->els_cmd_ptrs, M_DEVBUF); in mpt_add_els_buffers()
4183 mpt->els_cmd_ptrs = NULL; in mpt_add_els_buffers()
4190 mpt->els_cmds_allocated = i; in mpt_add_els_buffers()
4199 if (mpt->tgt_cmd_ptrs) { in mpt_add_target_commands()
4204 if (max > mpt->mpt_max_tgtcmds) { in mpt_add_target_commands()
4205 max = mpt->mpt_max_tgtcmds; in mpt_add_target_commands()
4207 mpt->tgt_cmd_ptrs = in mpt_add_target_commands()
4209 if (mpt->tgt_cmd_ptrs == NULL) { in mpt_add_target_commands()
4222 req->state |= REQ_STATE_LOCKED; in mpt_add_target_commands()
4223 mpt->tgt_cmd_ptrs[i] = req; in mpt_add_target_commands()
4229 free(mpt->tgt_cmd_ptrs, M_DEVBUF); in mpt_add_target_commands()
4230 mpt->tgt_cmd_ptrs = NULL; in mpt_add_target_commands()
4234 mpt->tgt_cmds_allocated = i; in mpt_add_target_commands()
4248 mpt->twildcard = 1; in mpt_enable_lun()
4254 if (mpt->tenabled == 0) { in mpt_enable_lun()
4255 if (mpt->is_fc) { in mpt_enable_lun()
4258 mpt->tenabled = 1; in mpt_enable_lun()
4261 mpt->trt_wildcard.enabled = 1; in mpt_enable_lun()
4263 mpt->trt[lun].enabled = 1; in mpt_enable_lun()
4274 mpt->twildcard = 0; in mpt_disable_lun()
4281 mpt->trt_wildcard.enabled = 0; in mpt_disable_lun()
4283 mpt->trt[lun].enabled = 0; in mpt_disable_lun()
4286 if (mpt->trt[i].enabled) { in mpt_disable_lun()
4290 if (i == MPT_MAX_LUNS && mpt->twildcard == 0) { in mpt_disable_lun()
4291 if (mpt->is_fc) { in mpt_disable_lun()
4294 mpt->tenabled = 0; in mpt_disable_lun()
4305 struct ccb_scsiio *csio = &ccb->csio; in mpt_target_start_io()
4306 request_t *cmd_req = MPT_TAG_2_REQ(mpt, csio->tag_id); in mpt_target_start_io()
4309 switch (tgt->state) { in mpt_target_start_io()
4314 xpt_freeze_simq(mpt->sim, 1); in mpt_target_start_io()
4315 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_target_start_io()
4316 tgt->ccb->ccb_h.status |= CAM_RELEASE_SIMQ; in mpt_target_start_io()
4321 "starting I/O\n", ccb, csio->ccb_h.flags, csio->tag_id); in mpt_target_start_io()
4328 if (csio->dxfer_len) { in mpt_target_start_io()
4334 KASSERT((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE, in mpt_target_start_io()
4335 ("dxfer_len %u but direction is NONE", csio->dxfer_len)); in mpt_target_start_io()
4338 if (mpt->outofbeer == 0) { in mpt_target_start_io()
4339 mpt->outofbeer = 1; in mpt_target_start_io()
4340 xpt_freeze_simq(mpt->sim, 1); in mpt_target_start_io()
4343 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_target_start_io()
4348 ccb->ccb_h.status = CAM_SIM_QUEUED | CAM_REQ_INPROG; in mpt_target_start_io()
4355 req->ccb = ccb; in mpt_target_start_io()
4356 ccb->ccb_h.ccb_req_ptr = req; in mpt_target_start_io()
4362 tgt->ccb = ccb; in mpt_target_start_io()
4363 tgt->req = req; in mpt_target_start_io()
4365 memset(req->req_vbuf, 0, MPT_RQSL(mpt)); in mpt_target_start_io()
4366 ta = req->req_vbuf; in mpt_target_start_io()
4368 if (mpt->is_sas) { in mpt_target_start_io()
4370 cmd_req->req_vbuf; in mpt_target_start_io()
4371 ta->QueueTag = ssp->InitiatorTag; in mpt_target_start_io()
4372 } else if (mpt->is_spi) { in mpt_target_start_io()
4374 cmd_req->req_vbuf; in mpt_target_start_io()
4375 ta->QueueTag = sp->Tag; in mpt_target_start_io()
4377 ta->Function = MPI_FUNCTION_TARGET_ASSIST; in mpt_target_start_io()
4378 ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); in mpt_target_start_io()
4379 ta->ReplyWord = htole32(tgt->reply_desc); in mpt_target_start_io()
4380 be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(csio->ccb_h.target_lun)); in mpt_target_start_io()
4382 ta->RelativeOffset = tgt->bytes_xfered; in mpt_target_start_io()
4383 ta->DataLength = ccb->csio.dxfer_len; in mpt_target_start_io()
4384 if (ta->DataLength > tgt->resid) { in mpt_target_start_io()
4385 ta->DataLength = tgt->resid; in mpt_target_start_io()
4391 csio->resid = csio->dxfer_len - ta->DataLength; in mpt_target_start_io()
4392 tgt->resid -= csio->dxfer_len; in mpt_target_start_io()
4393 tgt->bytes_xfered += csio->dxfer_len; in mpt_target_start_io()
4395 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) { in mpt_target_start_io()
4396 ta->TargetAssistFlags |= in mpt_target_start_io()
4401 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) && in mpt_target_start_io()
4402 csio->scsi_status == SCSI_STATUS_OK && tgt->resid == 0) { in mpt_target_start_io()
4403 ta->TargetAssistFlags |= in mpt_target_start_io()
4407 tgt->state = TGT_STATE_SETTING_UP_FOR_DATA; in mpt_target_start_io()
4411 "nxtstate=%d\n", csio, csio->tag_id, csio->dxfer_len, in mpt_target_start_io()
4412 tgt->resid, ccb->ccb_h.flags, req, req->serno, tgt->state); in mpt_target_start_io()
4414 error = bus_dmamap_load_ccb(mpt->buffer_dmat, req->dmap, ccb, in mpt_target_start_io()
4417 xpt_freeze_simq(mpt->sim, 1); in mpt_target_start_io()
4418 ccb->ccb_h.status |= CAM_RELEASE_SIMQ; in mpt_target_start_io()
4427 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) == 0) { in mpt_target_start_io()
4430 "resid %d bytes_xfered %u\n", ccb, ccb->ccb_h.flags, in mpt_target_start_io()
4431 ccb->ccb_h.status, tgt->resid, tgt->bytes_xfered); in mpt_target_start_io()
4433 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_target_start_io()
4437 mpt_scsi_tgt_status(mpt, ccb, cmd_req, csio->scsi_status, in mpt_target_start_io()
4438 (void *)&csio->sense_data, in mpt_target_start_io()
4439 (ccb->ccb_h.flags & CAM_SEND_SENSE) ? in mpt_target_start_io()
4440 csio->sense_len : 0); in mpt_target_start_io()
4460 if (length == 0 || tgt->resid == 0) { in mpt_scsi_tgt_local()
4461 tgt->resid = 0; in mpt_scsi_tgt_local()
4467 mpt_prt(mpt, "out of resources- dropping local response\n"); in mpt_scsi_tgt_local()
4470 tgt->is_local = 1; in mpt_scsi_tgt_local()
4472 memset(req->req_vbuf, 0, MPT_RQSL(mpt)); in mpt_scsi_tgt_local()
4473 ta = req->req_vbuf; in mpt_scsi_tgt_local()
4475 if (mpt->is_sas) { in mpt_scsi_tgt_local()
4476 PTR_MPI_TARGET_SSP_CMD_BUFFER ssp = cmd_req->req_vbuf; in mpt_scsi_tgt_local()
4477 ta->QueueTag = ssp->InitiatorTag; in mpt_scsi_tgt_local()
4478 } else if (mpt->is_spi) { in mpt_scsi_tgt_local()
4479 PTR_MPI_TARGET_SCSI_SPI_CMD_BUFFER sp = cmd_req->req_vbuf; in mpt_scsi_tgt_local()
4480 ta->QueueTag = sp->Tag; in mpt_scsi_tgt_local()
4482 ta->Function = MPI_FUNCTION_TARGET_ASSIST; in mpt_scsi_tgt_local()
4483 ta->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); in mpt_scsi_tgt_local()
4484 ta->ReplyWord = htole32(tgt->reply_desc); in mpt_scsi_tgt_local()
4485 be64enc(ta->LUN, CAM_EXTLUN_BYTE_SWIZZLE(lun)); in mpt_scsi_tgt_local()
4486 ta->RelativeOffset = 0; in mpt_scsi_tgt_local()
4487 ta->DataLength = length; in mpt_scsi_tgt_local()
4489 dptr = req->req_vbuf; in mpt_scsi_tgt_local()
4491 pptr = req->req_pbuf; in mpt_scsi_tgt_local()
4495 se = (SGE_SIMPLE32 *) &ta->SGL[0]; in mpt_scsi_tgt_local()
4500 ta->TargetAssistFlags |= TARGET_ASSIST_FLAGS_DATA_DIRECTION; in mpt_scsi_tgt_local()
4503 se->Address = pptr; in mpt_scsi_tgt_local()
4509 tgt->ccb = NULL; in mpt_scsi_tgt_local()
4510 tgt->req = req; in mpt_scsi_tgt_local()
4511 tgt->resid -= length; in mpt_scsi_tgt_local()
4512 tgt->bytes_xfered = length; in mpt_scsi_tgt_local()
4514 tgt->state = TGT_STATE_MOVING_DATA_AND_STATUS; in mpt_scsi_tgt_local()
4516 tgt->state = TGT_STATE_MOVING_DATA; in mpt_scsi_tgt_local()
4529 union ccb *accb = ccb->cab.abort_ccb; in mpt_abort_target_ccb()
4536 if (ccb->ccb_h.target_lun == CAM_LUN_WILDCARD) in mpt_abort_target_ccb()
4537 trtp = &mpt->trt_wildcard; in mpt_abort_target_ccb()
4539 trtp = &mpt->trt[ccb->ccb_h.target_lun]; in mpt_abort_target_ccb()
4540 if (accb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) { in mpt_abort_target_ccb()
4541 lp = &trtp->atios; in mpt_abort_target_ccb()
4542 tag = accb->atio.tag_id; in mpt_abort_target_ccb()
4544 lp = &trtp->inots; in mpt_abort_target_ccb()
4545 tag = accb->cin1.tag_id; in mpt_abort_target_ccb()
4550 if (srch != &accb->ccb_h) in mpt_abort_target_ccb()
4553 accb->ccb_h.status = CAM_REQ_ABORTED; in mpt_abort_target_ccb()
4561 if (tgt->tag_id == tag) { in mpt_abort_target_ccb()
4581 return (-1); in mpt_abort_target_cmd()
4583 abtp = req->req_vbuf; in mpt_abort_target_cmd()
4586 abtp->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); in mpt_abort_target_cmd()
4587 abtp->AbortType = TARGET_MODE_ABORT_TYPE_EXACT_IO; in mpt_abort_target_cmd()
4588 abtp->Function = MPI_FUNCTION_TARGET_MODE_ABORT; in mpt_abort_target_cmd()
4589 abtp->ReplyWord = htole32(MPT_TGT_STATE(mpt, cmd_req)->reply_desc); in mpt_abort_target_cmd()
4591 if (mpt->is_fc || mpt->is_sas) { in mpt_abort_target_cmd()
4600 * WE_TRUST_AUTO_GOOD_STATUS- I've found that setting
4606 * WE_CAN_USE_AUTO_REPOST- we can't use AUTO_REPOST because
4623 cmd_vbuf = cmd_req->req_vbuf; in mpt_scsi_tgt_status()
4628 if (mpt->outofbeer == 0) { in mpt_scsi_tgt_status()
4629 mpt->outofbeer = 1; in mpt_scsi_tgt_status()
4630 xpt_freeze_simq(mpt->sim, 1); in mpt_scsi_tgt_status()
4634 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_scsi_tgt_status()
4639 "could not allocate status request- dropping\n"); in mpt_scsi_tgt_status()
4643 req->ccb = ccb; in mpt_scsi_tgt_status()
4645 ccb->ccb_h.ccb_mpt_ptr = mpt; in mpt_scsi_tgt_status()
4646 ccb->ccb_h.ccb_req_ptr = req; in mpt_scsi_tgt_status()
4653 tgt->ccb = ccb; in mpt_scsi_tgt_status()
4654 tgt->req = req; in mpt_scsi_tgt_status()
4655 tgt->state = TGT_STATE_SENDING_STATUS; in mpt_scsi_tgt_status()
4657 tp = req->req_vbuf; in mpt_scsi_tgt_status()
4658 paddr = req->req_pbuf; in mpt_scsi_tgt_status()
4662 tp->StatusCode = status; in mpt_scsi_tgt_status()
4663 tp->Function = MPI_FUNCTION_TARGET_STATUS_SEND; in mpt_scsi_tgt_status()
4664 if (mpt->is_fc) { in mpt_scsi_tgt_status()
4670 sts_vbuf = req->req_vbuf; in mpt_scsi_tgt_status()
4673 memcpy(tp->LUN, fc->FcpLun, sizeof (tp->LUN)); in mpt_scsi_tgt_status()
4677 * It has to be big-endian in memory and is organized in mpt_scsi_tgt_status()
4693 if (tgt->resid < 0) { in mpt_scsi_tgt_status()
4695 rsp[3] = htobe32(-tgt->resid); in mpt_scsi_tgt_status()
4697 } else if (tgt->resid > 0) { in mpt_scsi_tgt_status()
4699 rsp[3] = htobe32(tgt->resid); in mpt_scsi_tgt_status()
4708 } else if (mpt->is_sas) { in mpt_scsi_tgt_status()
4711 memcpy(tp->LUN, ssp->LogicalUnitNumber, sizeof (tp->LUN)); in mpt_scsi_tgt_status()
4715 tp->QueueTag = htole16(sp->Tag); in mpt_scsi_tgt_status()
4716 memcpy(tp->LUN, sp->LogicalUnitNumber, sizeof (tp->LUN)); in mpt_scsi_tgt_status()
4719 tp->ReplyWord = htole32(tgt->reply_desc); in mpt_scsi_tgt_status()
4720 tp->MsgContext = htole32(req->index | mpt->scsi_tgt_handler_id); in mpt_scsi_tgt_status()
4723 tp->MsgFlags = TARGET_STATUS_SEND_FLAGS_REPOST_CMD_BUFFER; in mpt_scsi_tgt_status()
4726 tp->MsgFlags |= TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS; in mpt_scsi_tgt_status()
4728 tp->StatusDataSGE.u.Address32 = htole32((uint32_t) paddr); in mpt_scsi_tgt_status()
4736 tp->StatusDataSGE.FlagsLength = htole32(fl); in mpt_scsi_tgt_status()
4741 ccb, sense_len > 0 ? "" : "out", tgt->tag_id, in mpt_scsi_tgt_status()
4742 req, req->serno, tgt->resid); in mpt_scsi_tgt_status()
4743 if (mpt->verbose > MPT_PRT_DEBUG) in mpt_scsi_tgt_status()
4744 mpt_print_request(req->req_vbuf); in mpt_scsi_tgt_status()
4746 ccb->ccb_h.status = CAM_SIM_QUEUED | CAM_REQ_INPROG; in mpt_scsi_tgt_status()
4760 inot = (struct ccb_immediate_notify *) STAILQ_FIRST(&trtp->inots); in mpt_scsi_tgt_tsk_mgmt()
4762 mpt_lprt(mpt, MPT_PRT_WARN, "no INOTSs- sending back BSY\n"); in mpt_scsi_tgt_tsk_mgmt()
4766 STAILQ_REMOVE_HEAD(&trtp->inots, sim_links.stqe); in mpt_scsi_tgt_tsk_mgmt()
4769 (uintmax_t)inot->ccb_h.target_lun); in mpt_scsi_tgt_tsk_mgmt()
4771 inot->initiator_id = init_id; /* XXX */ in mpt_scsi_tgt_tsk_mgmt()
4772 inot->tag_id = tgt->tag_id; in mpt_scsi_tgt_tsk_mgmt()
4773 inot->seq_id = 0; in mpt_scsi_tgt_tsk_mgmt()
4780 inot->arg = MSG_QUERY_TASK_SET; in mpt_scsi_tgt_tsk_mgmt()
4783 inot->arg = MSG_ABORT_TASK_SET; in mpt_scsi_tgt_tsk_mgmt()
4786 inot->arg = MSG_CLEAR_TASK_SET; in mpt_scsi_tgt_tsk_mgmt()
4789 inot->arg = MSG_QUERY_ASYNC_EVENT; in mpt_scsi_tgt_tsk_mgmt()
4792 inot->arg = MSG_LOGICAL_UNIT_RESET; in mpt_scsi_tgt_tsk_mgmt()
4795 inot->arg = MSG_TARGET_RESET; in mpt_scsi_tgt_tsk_mgmt()
4798 inot->arg = MSG_CLEAR_ACA; in mpt_scsi_tgt_tsk_mgmt()
4801 inot->arg = MSG_NOOP; in mpt_scsi_tgt_tsk_mgmt()
4804 tgt->ccb = (union ccb *) inot; in mpt_scsi_tgt_tsk_mgmt()
4805 inot->ccb_h.status = CAM_MESSAGE_RECV; in mpt_scsi_tgt_tsk_mgmt()
4815 'L', 'S', 'I', '-', 'L', 'O', 'G', 'I', in mpt_scsi_tgt_atio()
4833 vbuf = req->req_vbuf; in mpt_scsi_tgt_atio()
4835 if (mpt->verbose >= MPT_PRT_DEBUG) { in mpt_scsi_tgt_atio()
4846 if (tgt->state != TGT_STATE_LOADED) { in mpt_scsi_tgt_atio()
4851 tgt->state = TGT_STATE_IN_CAM; in mpt_scsi_tgt_atio()
4852 tgt->reply_desc = reply_desc; in mpt_scsi_tgt_atio()
4862 tgt->tag_id = MPT_MAKE_TAGID(mpt, req, ioindex); in mpt_scsi_tgt_atio()
4864 if (mpt->is_fc) { in mpt_scsi_tgt_atio()
4867 if (fc->FcpCntl[2]) { in mpt_scsi_tgt_atio()
4871 switch (fc->FcpCntl[2]) { in mpt_scsi_tgt_atio()
4895 fc->FcpCntl[2]); in mpt_scsi_tgt_atio()
4901 switch (fc->FcpCntl[1]) { in mpt_scsi_tgt_atio()
4919 tgt->resid = be32toh(fc->FcpDl); in mpt_scsi_tgt_atio()
4920 cdbp = fc->FcpCdb; in mpt_scsi_tgt_atio()
4921 lunptr = fc->FcpLun; in mpt_scsi_tgt_atio()
4922 tgt->itag = fc->OptionalOxid; in mpt_scsi_tgt_atio()
4923 } else if (mpt->is_sas) { in mpt_scsi_tgt_atio()
4926 cdbp = ssp->CDB; in mpt_scsi_tgt_atio()
4927 lunptr = ssp->LogicalUnitNumber; in mpt_scsi_tgt_atio()
4928 tgt->itag = ssp->InitiatorTag; in mpt_scsi_tgt_atio()
4932 cdbp = sp->CDB; in mpt_scsi_tgt_atio()
4933 lunptr = sp->LogicalUnitNumber; in mpt_scsi_tgt_atio()
4934 tgt->itag = sp->Tag; in mpt_scsi_tgt_atio()
4940 * Deal with non-enabled or bad luns here. in mpt_scsi_tgt_atio()
4942 if (lun >= MPT_MAX_LUNS || mpt->tenabled == 0 || in mpt_scsi_tgt_atio()
4943 mpt->trt[lun].enabled == 0) { in mpt_scsi_tgt_atio()
4944 if (mpt->twildcard) { in mpt_scsi_tgt_atio()
4945 trtp = &mpt->trt_wildcard; in mpt_scsi_tgt_atio()
4973 len = min(tgt->resid, cdbp[4]); in mpt_scsi_tgt_atio()
4984 len = min(tgt->resid, cdbp[4]); in mpt_scsi_tgt_atio()
5009 trtp = &mpt->trt[lun]; in mpt_scsi_tgt_atio()
5028 atiop = (struct ccb_accept_tio *) STAILQ_FIRST(&trtp->atios); in mpt_scsi_tgt_atio()
5031 "no ATIOs for lun %jx- sending back %s\n", (uintmax_t)lun, in mpt_scsi_tgt_atio()
5032 mpt->tenabled? "QUEUE FULL" : "BUSY"); in mpt_scsi_tgt_atio()
5034 mpt->tenabled? SCSI_STATUS_QUEUE_FULL : SCSI_STATUS_BUSY, in mpt_scsi_tgt_atio()
5038 STAILQ_REMOVE_HEAD(&trtp->atios, sim_links.stqe); in mpt_scsi_tgt_atio()
5041 (uintmax_t)atiop->ccb_h.target_lun); in mpt_scsi_tgt_atio()
5042 atiop->ccb_h.ccb_mpt_ptr = mpt; in mpt_scsi_tgt_atio()
5043 atiop->ccb_h.status = CAM_CDB_RECVD; in mpt_scsi_tgt_atio()
5044 atiop->ccb_h.target_lun = lun; in mpt_scsi_tgt_atio()
5045 atiop->sense_len = 0; in mpt_scsi_tgt_atio()
5046 atiop->tag_id = tgt->tag_id; in mpt_scsi_tgt_atio()
5047 atiop->init_id = GET_INITIATOR_INDEX(reply_desc); in mpt_scsi_tgt_atio()
5048 atiop->cdb_len = 16; in mpt_scsi_tgt_atio()
5049 memcpy(atiop->cdb_io.cdb_bytes, cdbp, atiop->cdb_len); in mpt_scsi_tgt_atio()
5051 atiop->tag_action = tag_action; in mpt_scsi_tgt_atio()
5052 atiop->ccb_h.flags |= CAM_TAG_ACTION_VALID; in mpt_scsi_tgt_atio()
5054 if (mpt->verbose >= MPT_PRT_DEBUG) { in mpt_scsi_tgt_atio()
5057 (uintmax_t)atiop->ccb_h.target_lun); in mpt_scsi_tgt_atio()
5058 for (i = 0; i < atiop->cdb_len; i++) { in mpt_scsi_tgt_atio()
5060 (i == (atiop->cdb_len - 1))? '>' : ' '); in mpt_scsi_tgt_atio()
5063 tgt->itag, tgt->tag_id, tgt->reply_desc, tgt->resid); in mpt_scsi_tgt_atio()
5075 "nx %d tag 0x%08x itag 0x%04x state=%d\n", req, req->serno, in mpt_tgt_dump_tgt_state()
5076 tgt->reply_desc, tgt->resid, tgt->bytes_xfered, tgt->ccb, in mpt_tgt_dump_tgt_state()
5077 tgt->req, tgt->nxfers, tgt->tag_id, tgt->itag, tgt->state); in mpt_tgt_dump_tgt_state()
5084 mpt_prt(mpt, "req %p:%u index %u (%x) state %x\n", req, req->serno, in mpt_tgt_dump_req_state()
5085 req->index, req->index, req->state); in mpt_tgt_dump_req_state()
5105 if (tgt->req) { in mpt_scsi_tgt_reply_handler()
5106 mpt_req_not_spcl(mpt, tgt->req, in mpt_scsi_tgt_reply_handler()
5110 switch(tgt->state) { in mpt_scsi_tgt_reply_handler()
5119 ccb = tgt->ccb; in mpt_scsi_tgt_reply_handler()
5120 if (tgt->req == NULL) { in mpt_scsi_tgt_reply_handler()
5126 if (tgt->is_local == 0) { in mpt_scsi_tgt_reply_handler()
5133 TAILQ_REMOVE(&mpt->request_pending_list, in mpt_scsi_tgt_reply_handler()
5134 tgt->req, links); in mpt_scsi_tgt_reply_handler()
5135 mpt_free_request(mpt, tgt->req); in mpt_scsi_tgt_reply_handler()
5136 tgt->req = NULL; in mpt_scsi_tgt_reply_handler()
5141 tgt->ccb = NULL; in mpt_scsi_tgt_reply_handler()
5142 tgt->nxfers++; in mpt_scsi_tgt_reply_handler()
5143 mpt_req_untimeout(tgt->req, mpt_timeout, ccb); in mpt_scsi_tgt_reply_handler()
5146 ccb, tgt->req, tgt->req->serno, ccb->csio.tag_id); in mpt_scsi_tgt_reply_handler()
5150 KASSERT(tgt->req->ccb == ccb, in mpt_scsi_tgt_reply_handler()
5151 ("tgt->req %p:%u tgt->req->ccb %p", tgt->req, in mpt_scsi_tgt_reply_handler()
5152 tgt->req->serno, tgt->req->ccb)); in mpt_scsi_tgt_reply_handler()
5153 TAILQ_REMOVE(&mpt->request_pending_list, in mpt_scsi_tgt_reply_handler()
5154 tgt->req, links); in mpt_scsi_tgt_reply_handler()
5155 mpt_free_request(mpt, tgt->req); in mpt_scsi_tgt_reply_handler()
5156 tgt->req = NULL; in mpt_scsi_tgt_reply_handler()
5162 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) == 0) { in mpt_scsi_tgt_reply_handler()
5164 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_scsi_tgt_reply_handler()
5165 KASSERT(ccb->ccb_h.status, in mpt_scsi_tgt_reply_handler()
5167 tgt->state = TGT_STATE_IN_CAM; in mpt_scsi_tgt_reply_handler()
5168 if (mpt->outofbeer) { in mpt_scsi_tgt_reply_handler()
5169 ccb->ccb_h.status |= CAM_RELEASE_SIMQ; in mpt_scsi_tgt_reply_handler()
5170 mpt->outofbeer = 0; in mpt_scsi_tgt_reply_handler()
5180 ccb->csio.scsi_status, in mpt_scsi_tgt_reply_handler()
5181 (void *)&ccb->csio.sense_data, in mpt_scsi_tgt_reply_handler()
5182 (ccb->ccb_h.flags & CAM_SEND_SENSE) ? in mpt_scsi_tgt_reply_handler()
5183 ccb->csio.sense_len : 0); in mpt_scsi_tgt_reply_handler()
5190 ccb = tgt->ccb; in mpt_scsi_tgt_reply_handler()
5192 if (tgt->req == NULL) { in mpt_scsi_tgt_reply_handler()
5199 tgt->ccb = NULL; in mpt_scsi_tgt_reply_handler()
5200 if (tgt->state == in mpt_scsi_tgt_reply_handler()
5202 tgt->nxfers++; in mpt_scsi_tgt_reply_handler()
5204 mpt_req_untimeout(tgt->req, mpt_timeout, ccb); in mpt_scsi_tgt_reply_handler()
5205 if (ccb->ccb_h.flags & CAM_SEND_SENSE) { in mpt_scsi_tgt_reply_handler()
5206 ccb->ccb_h.status |= CAM_SENT_SENSE; in mpt_scsi_tgt_reply_handler()
5210 "%p\n", ccb->csio.tag_id, ccb->ccb_h.status, in mpt_scsi_tgt_reply_handler()
5211 ccb->ccb_h.flags, tgt->req); in mpt_scsi_tgt_reply_handler()
5215 KASSERT(tgt->req->ccb == ccb, in mpt_scsi_tgt_reply_handler()
5216 ("tgt->req %p:%u tgt->req->ccb %p", in mpt_scsi_tgt_reply_handler()
5217 tgt->req, tgt->req->serno, tgt->req->ccb)); in mpt_scsi_tgt_reply_handler()
5222 ccb->ccb_h.status &= ~CAM_SIM_QUEUED; in mpt_scsi_tgt_reply_handler()
5223 KASSERT(ccb->ccb_h.status, in mpt_scsi_tgt_reply_handler()
5225 tgt->ccb = NULL; in mpt_scsi_tgt_reply_handler()
5228 "TARGET_STATUS non-CAM for req %p:%u\n", in mpt_scsi_tgt_reply_handler()
5229 tgt->req, tgt->req->serno); in mpt_scsi_tgt_reply_handler()
5231 TAILQ_REMOVE(&mpt->request_pending_list, in mpt_scsi_tgt_reply_handler()
5232 tgt->req, links); in mpt_scsi_tgt_reply_handler()
5233 mpt_free_request(mpt, tgt->req); in mpt_scsi_tgt_reply_handler()
5234 tgt->req = NULL; in mpt_scsi_tgt_reply_handler()
5237 * And re-post the Command Buffer. in mpt_scsi_tgt_reply_handler()
5241 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_scsi_tgt_reply_handler()
5242 tgt->is_local = 0; in mpt_scsi_tgt_reply_handler()
5249 if (mpt->outofbeer) { in mpt_scsi_tgt_reply_handler()
5250 ccb->ccb_h.status |= CAM_RELEASE_SIMQ; in mpt_scsi_tgt_reply_handler()
5251 mpt->outofbeer = 0; in mpt_scsi_tgt_reply_handler()
5259 tgt->state = TGT_STATE_LOADED; in mpt_scsi_tgt_reply_handler()
5263 "Reply Function\n", tgt->state); in mpt_scsi_tgt_reply_handler()
5268 status = le16toh(reply_frame->IOCStatus); in mpt_scsi_tgt_reply_handler()
5277 req, req->serno, reply_frame, reply_frame->Function, status); in mpt_scsi_tgt_reply_handler()
5279 switch (reply_frame->Function) { in mpt_scsi_tgt_reply_handler()
5293 KASSERT(tgt->state == TGT_STATE_LOADING, in mpt_scsi_tgt_reply_handler()
5294 ("bad state 0x%x on reply to buffer post", tgt->state)); in mpt_scsi_tgt_reply_handler()
5296 tgt->state = TGT_STATE_LOADED; in mpt_scsi_tgt_reply_handler()
5304 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_scsi_tgt_reply_handler()
5312 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_scsi_tgt_reply_handler()
5320 (PTR_MSG_TARGET_MODE_ABORT) req->req_vbuf; in mpt_scsi_tgt_reply_handler()
5321 uint32_t cc = GET_IO_INDEX(le32toh(abtp->ReplyWord)); in mpt_scsi_tgt_reply_handler()
5326 cc, le16toh(abtrp->IOCStatus), le32toh(abtrp->AbortCount)); in mpt_scsi_tgt_reply_handler()
5327 TAILQ_REMOVE(&mpt->request_pending_list, req, links); in mpt_scsi_tgt_reply_handler()
5333 "0x%x\n", reply_frame->Function); in mpt_scsi_tgt_reply_handler()