Lines Matching +full:device +full:- +full:handle

1 /*-
2 * Copyright (c) 2011-2015 LSI Corp.
3 * Copyright (c) 2013-2016 Avago Technologies
4 * Copyright 2000-2020 Broadcom Inc.
28 * Broadcom Inc. (LSI) MPT-Fusion Host Adapter FreeBSD
103 * define the IDENTIFY DEVICE structure
106 u16 reserved1[10]; /* 0-9 */
107 u16 serial_number[10]; /* 10-19 */
108 u16 reserved2[7]; /* 20-26 */
109 u16 model_number[20]; /* 27-46*/
110 u16 reserved3[170]; /* 47-216 */
112 u16 reserved4[38]; /* 218-255 */
119 static int mprsas_add_device(struct mpr_softc *sc, u16 handle, u8 linkrate);
120 static int mprsas_add_pcie_device(struct mpr_softc *sc, u16 handle,
122 static int mprsas_get_sata_identify(struct mpr_softc *sc, u16 handle,
128 u64 *sas_address, u16 handle, u32 device_info, u8 *is_SATA_SSD);
130 u16 handle);
152 sz = le16toh(event->EventDataLength) * 4; in mprsas_evt_handler()
153 fw_event->event_data = malloc(sz, M_MPR, M_ZERO|M_NOWAIT); in mprsas_evt_handler()
154 if (!fw_event->event_data) { in mprsas_evt_handler()
160 bcopy(event->EventData, fw_event->event_data, sz); in mprsas_evt_handler()
161 fw_event->event = le16toh(event->Event); in mprsas_evt_handler()
162 if ((fw_event->event == MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in mprsas_evt_handler()
163 fw_event->event == MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in mprsas_evt_handler()
164 fw_event->event == MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE || in mprsas_evt_handler()
165 fw_event->event == MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST) && in mprsas_evt_handler()
166 sc->track_mapping_events) in mprsas_evt_handler()
167 sc->pending_map_events++; in mprsas_evt_handler()
174 if ((fw_event->event == MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST || in mprsas_evt_handler()
175 fw_event->event == MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST || in mprsas_evt_handler()
176 fw_event->event == MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST) && in mprsas_evt_handler()
177 sc->wait_for_port_enable) in mprsas_evt_handler()
178 mprsas_startup_increment(sc->sassc); in mprsas_evt_handler()
180 TAILQ_INSERT_TAIL(&sc->sassc->ev_queue, fw_event, ev_link); in mprsas_evt_handler()
181 taskqueue_enqueue(sc->sassc->ev_tq, &sc->sassc->ev_task); in mprsas_evt_handler()
188 free(fw_event->event_data, M_MPR); in mprsas_fw_event_free()
193 * _mpr_fw_work - delayed task for processing firmware events
204 sassc = sc->sassc; in mprsas_fw_work()
206 mpr_dprint(sc, MPR_EVENT, "(%d)->(%s) Working on Event: [%x]\n", in mprsas_fw_work()
207 event_count++, __func__, fw_event->event); in mprsas_fw_work()
208 switch (fw_event->event) { in mprsas_fw_work()
216 fw_event->event_data; in mprsas_fw_work()
218 mpr_mapping_topology_change_event(sc, fw_event->event_data); in mprsas_fw_work()
220 for (i = 0; i < data->NumEntries; i++) { in mprsas_fw_work()
221 phy = &data->PHY[i]; in mprsas_fw_work()
222 switch (phy->PhyStatus & MPI2_EVENT_SAS_TOPO_RC_MASK) { in mprsas_fw_work()
225 le16toh(phy->AttachedDevHandle), in mprsas_fw_work()
226 phy->LinkRate)) { in mprsas_fw_work()
228 "failed to add device with handle " in mprsas_fw_work()
230 le16toh(phy->AttachedDevHandle)); in mprsas_fw_work()
232 phy->AttachedDevHandle)); in mprsas_fw_work()
237 phy->AttachedDevHandle)); in mprsas_fw_work()
258 data = (MPI2_EVENT_DATA_SAS_DISCOVERY *)fw_event->event_data; in mprsas_fw_work()
260 if (data->ReasonCode & MPI2_EVENT_SAS_DISC_RC_STARTED) in mprsas_fw_work()
262 if (data->ReasonCode & MPI2_EVENT_SAS_DISC_RC_COMPLETED) { in mprsas_fw_work()
264 sassc->flags &= ~MPRSAS_IN_DISCOVERY; in mprsas_fw_work()
272 fw_event->event_data); in mprsas_fw_work()
285 event_data = fw_event->event_data; in mprsas_fw_work()
286 foreign_config = (le32toh(event_data->Flags) & in mprsas_fw_work()
290 (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; in mprsas_fw_work()
292 element->VolDevHandle); in mprsas_fw_work()
295 for (i = 0; i < event_data->NumElements; i++, element++) { in mprsas_fw_work()
296 reason = element->ReasonCode; in mprsas_fw_work()
297 elementType = le16toh(element->ElementFlags) & in mprsas_fw_work()
338 action = (MPI2_RAID_ACTION_REQUEST *)cm->cm_req; in mprsas_fw_work()
339 action->Function = MPI2_FUNCTION_RAID_ACTION; in mprsas_fw_work()
340 action->Action = in mprsas_fw_work()
342 action->PhysDiskNum = element->PhysDiskNum; in mprsas_fw_work()
343 cm->cm_desc.Default.RequestFlags = in mprsas_fw_work()
348 cm->cm_reply; in mprsas_fw_work()
358 if (reply && (le16toh(reply->IOCStatus) & in mprsas_fw_work()
364 le16toh(reply->IOCStatus)); in mprsas_fw_work()
373 "code %x:\n", element->ReasonCode); in mprsas_fw_work()
374 switch (element->ReasonCode) { in mprsas_fw_work()
379 le16toh(element->VolDevHandle))) { in mprsas_fw_work()
381 "volume with handle 0x%x\n", in mprsas_fw_work()
382 __func__, le16toh(element-> in mprsas_fw_work()
395 "for volume with handle " in mprsas_fw_work()
397 le16toh(element-> in mprsas_fw_work()
402 targ = &sassc->targets[id]; in mprsas_fw_work()
403 targ->handle = 0x0; in mprsas_fw_work()
404 targ->encl_slot = 0x0; in mprsas_fw_work()
405 targ->encl_handle = 0x0; in mprsas_fw_work()
406 targ->encl_level_valid = 0x0; in mprsas_fw_work()
407 targ->encl_level = 0x0; in mprsas_fw_work()
408 targ->connector_name[0] = ' '; in mprsas_fw_work()
409 targ->connector_name[1] = ' '; in mprsas_fw_work()
410 targ->connector_name[2] = ' '; in mprsas_fw_work()
411 targ->connector_name[3] = ' '; in mprsas_fw_work()
412 targ->exp_dev_handle = 0x0; in mprsas_fw_work()
413 targ->phy_num = 0x0; in mprsas_fw_work()
414 targ->linkrate = 0x0; in mprsas_fw_work()
417 targ->tid); in mprsas_fw_work()
427 element->PhysDiskDevHandle); in mprsas_fw_work()
430 targ->flags |= MPR_TARGET_FLAGS_RAID_COMPONENT; in mprsas_fw_work()
439 le16toh(element->PhysDiskDevHandle), 0)) { in mprsas_fw_work()
440 printf("%s: failed to add device with " in mprsas_fw_work()
441 "handle 0x%x\n", __func__, in mprsas_fw_work()
442 le16toh(element-> in mprsas_fw_work()
445 le16toh(element-> in mprsas_fw_work()
461 Mpi2EventDataIrVolume_t *event_data = fw_event->event_data; in mprsas_fw_work()
467 switch (event_data->ReasonCode) { in mprsas_fw_work()
471 "handle 0x%x", le32toh(event_data->PreviousValue), in mprsas_fw_work()
472 le32toh(event_data->NewValue), in mprsas_fw_work()
473 le16toh(event_data->VolDevHandle)); in mprsas_fw_work()
478 "handle 0x%x", le32toh(event_data->PreviousValue), in mprsas_fw_work()
479 le32toh(event_data->NewValue), in mprsas_fw_work()
480 le16toh(event_data->VolDevHandle)); in mprsas_fw_work()
485 "handle 0x%x", le32toh(event_data->PreviousValue), in mprsas_fw_work()
486 le32toh(event_data->NewValue), in mprsas_fw_work()
487 le16toh(event_data->VolDevHandle)); in mprsas_fw_work()
490 state = le32toh(event_data->NewValue); in mprsas_fw_work()
495 event_data->VolDevHandle); in mprsas_fw_work()
503 0, event_data->VolDevHandle); in mprsas_fw_work()
505 printf("%s %d: Volume handle " in mprsas_fw_work()
508 event_data->VolDevHandle); in mprsas_fw_work()
512 le16toh(event_data-> in mprsas_fw_work()
515 "volume with handle 0x%x\n", in mprsas_fw_work()
517 event_data->VolDevHandle)); in mprsas_fw_work()
532 fw_event->event_data; in mprsas_fw_work()
539 switch (event_data->ReasonCode) { in mprsas_fw_work()
543 "%d and handle 0x%x at Enclosure handle 0x%x, Slot " in mprsas_fw_work()
544 "%d", le32toh(event_data->PreviousValue), in mprsas_fw_work()
545 le32toh(event_data->NewValue), in mprsas_fw_work()
546 event_data->PhysDiskNum, in mprsas_fw_work()
547 le16toh(event_data->PhysDiskDevHandle), in mprsas_fw_work()
548 le16toh(event_data->EnclosureHandle), in mprsas_fw_work()
549 le16toh(event_data->Slot)); in mprsas_fw_work()
554 "handle 0x%x at Enclosure handle 0x%x, Slot %d", in mprsas_fw_work()
555 le32toh(event_data->PreviousValue), in mprsas_fw_work()
556 le32toh(event_data->NewValue), in mprsas_fw_work()
557 event_data->PhysDiskNum, in mprsas_fw_work()
558 le16toh(event_data->PhysDiskDevHandle), in mprsas_fw_work()
559 le16toh(event_data->EnclosureHandle), in mprsas_fw_work()
560 le16toh(event_data->Slot)); in mprsas_fw_work()
565 "handle 0x%x at Enclosure handle 0x%x, Slot %d", in mprsas_fw_work()
566 le32toh(event_data->PreviousValue), in mprsas_fw_work()
567 le32toh(event_data->NewValue), in mprsas_fw_work()
568 event_data->PhysDiskNum, in mprsas_fw_work()
569 le16toh(event_data->PhysDiskDevHandle), in mprsas_fw_work()
570 le16toh(event_data->EnclosureHandle), in mprsas_fw_work()
571 le16toh(event_data->Slot)); in mprsas_fw_work()
572 switch (event_data->NewValue) { in mprsas_fw_work()
580 event_data->PhysDiskDevHandle); in mprsas_fw_work()
582 targ->flags |= in mprsas_fw_work()
585 "for handle 0x%x.\n", in mprsas_fw_work()
587 event_data-> in mprsas_fw_work()
597 event_data->PhysDiskDevHandle); in mprsas_fw_work()
599 targ->flags |= in mprsas_fw_work()
602 "for handle 0x%x. \n", in mprsas_fw_work()
604 event_data-> in mprsas_fw_work()
617 fw_event->event_data; in mprsas_fw_work()
624 "percent complete for Volume with handle 0x%x", in mprsas_fw_work()
625 event_data->RAIDOperation, event_data->PercentComplete, in mprsas_fw_work()
626 le16toh(event_data->VolDevHandle)); in mprsas_fw_work()
633 temp_event = (pMpi2EventDataTemperature_t)fw_event->event_data; in mprsas_fw_work()
640 if (sc->iounit_pg8.NumSensors > temp_event->SensorNum) { in mprsas_fw_work()
643 ((temp_event->Status & 0x01) == 1) ? "0 " : " ", in mprsas_fw_work()
644 ((temp_event->Status & 0x02) == 2) ? "1 " : " ", in mprsas_fw_work()
645 ((temp_event->Status & 0x04) == 4) ? "2 " : " ", in mprsas_fw_work()
646 ((temp_event->Status & 0x08) == 8) ? "3 " : " ", in mprsas_fw_work()
647 temp_event->SensorNum); in mprsas_fw_work()
649 "%d\n", temp_event->CurrentTemperature); in mprsas_fw_work()
657 (pMpi26EventDataActiveCableExcept_t)fw_event->event_data; in mprsas_fw_work()
659 switch(ace_event_data->ReasonCode) { in mprsas_fw_work()
663 "ReceptacleID %d cannot be powered and device " in mprsas_fw_work()
666 ace_event_data->ReceptacleID, in mprsas_fw_work()
667 ace_event_data->ActiveCablePowerRequirement); in mprsas_fw_work()
674 "(12 Gb/s rate)\n", ace_event_data->ReceptacleID); in mprsas_fw_work()
686 (pMpi26EventDataPCIeDeviceStatusChange_t)fw_event->event_data; in mprsas_fw_work()
688 switch (pcie_status_event_data->ReasonCode) { in mprsas_fw_work()
692 "0x%x\n", pcie_status_event_data->DevHandle); in mprsas_fw_work()
707 fw_event->event_data; in mprsas_fw_work()
709 sas_address = discovery_error_data->SASAddress.High; in mprsas_fw_work()
711 discovery_error_data->SASAddress.Low; in mprsas_fw_work()
713 switch(discovery_error_data->ReasonCode) { in mprsas_fw_work()
718 "handle 0x%x.\n", sas_address, in mprsas_fw_work()
719 discovery_error_data->DevHandle); in mprsas_fw_work()
726 "handle 0x%x.\n", sas_address, in mprsas_fw_work()
727 discovery_error_data->DevHandle); in mprsas_fw_work()
740 uint16_t handle; in mprsas_fw_work() local
743 fw_event->event_data; in mprsas_fw_work()
746 fw_event->event_data); in mprsas_fw_work()
748 for (i = 0; i < data->NumEntries; i++) { in mprsas_fw_work()
749 port_entry = &data->PortEntry[i]; in mprsas_fw_work()
750 handle = le16toh(port_entry->AttachedDevHandle); in mprsas_fw_work()
751 link_rate = port_entry->CurrentPortInfo & in mprsas_fw_work()
753 switch (port_entry->PortStatus) { in mprsas_fw_work()
758 "add PCIe device with handle 0x%x " in mprsas_fw_work()
760 __func__, handle); in mprsas_fw_work()
763 if (mprsas_add_pcie_device(sc, handle, in mprsas_fw_work()
766 "to add PCIe device with handle " in mprsas_fw_work()
767 "0x%x\n", __func__, handle); in mprsas_fw_work()
768 mprsas_prepare_remove(sassc, handle); in mprsas_fw_work()
772 mprsas_prepare_remove(sassc, handle); in mprsas_fw_work()
793 fw_event->event); in mprsas_fw_work()
796 mpr_dprint(sc, MPR_EVENT, "(%d)->(%s) Event Free: [%x]\n", event_count, in mprsas_fw_work()
797 __func__, fw_event->event); in mprsas_fw_work()
809 while ((fw_event = TAILQ_FIRST(&sc->sassc->ev_queue)) != NULL) { in mprsas_firmware_event_work()
810 TAILQ_REMOVE(&sc->sassc->ev_queue, fw_event, ev_link); in mprsas_firmware_event_work()
817 mprsas_add_device(struct mpr_softc *sc, u16 handle, u8 linkrate) in mprsas_add_device() argument
832 sassc = sc->sassc; in mprsas_add_device()
835 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle) != 0) { in mprsas_add_device()
837 "Error reading SAS device %#x page0, iocstatus= 0x%x\n", in mprsas_add_device()
838 handle, mpi_reply.IOCStatus); in mprsas_add_device()
854 "Error reading parent SAS device %#x page0, " in mprsas_add_device()
867 mpr_dprint(sc, MPR_MAPPING, "Handle 0x%04x SAS Address from SAS device " in mprsas_add_device()
868 "page0 = %jx\n", handle, sas_address); in mprsas_add_device()
877 handle, device_info, &is_SATA_SSD); in mprsas_add_device()
881 "device with handle 0x%04x\n", in mprsas_add_device()
882 __func__, handle); in mprsas_add_device()
884 mpr_dprint(sc, MPR_MAPPING, "Handle 0x%04x SAS Address " in mprsas_add_device()
885 "from SATA device = %jx\n", handle, sas_address); in mprsas_add_device()
891 * 1 - use the PhyNum field as a fallback to the mapping logic in mprsas_add_device()
892 * 0 - never use the PhyNum field in mprsas_add_device()
893 * -1 - only use the PhyNum field in mprsas_add_device()
895 * Note that using the Phy number to map a device can cause device adds in mprsas_add_device()
903 if (sc->use_phynum != -1) in mprsas_add_device()
904 id = mpr_mapping_get_tid(sc, sas_address, handle); in mprsas_add_device()
906 if ((sc->use_phynum == 0) || in mprsas_add_device()
907 ((id = config_page.PhyNum) > sassc->maxtargets)) { in mprsas_add_device()
909 "Could not get ID for device with handle 0x%04x\n", in mprsas_add_device()
910 __FILE__, __LINE__, __func__, handle); in mprsas_add_device()
915 mpr_dprint(sc, MPR_MAPPING, "%s: Target ID for added device is %d.\n", in mprsas_add_device()
925 targ = &sassc->targets[id]; in mprsas_add_device()
926 if (!(targ->flags & MPR_TARGET_FLAGS_RAID_COMPONENT)) { in mprsas_add_device()
934 if (targ->handle != 0x0) { in mprsas_add_device()
936 "target id %d handle 0x%04x\n", id, targ->handle); in mprsas_add_device()
942 targ->devinfo = device_info; in mprsas_add_device()
943 targ->devname = le32toh(config_page.DeviceName.High); in mprsas_add_device()
944 targ->devname = (targ->devname << 32) | in mprsas_add_device()
946 targ->encl_handle = le16toh(config_page.EnclosureHandle); in mprsas_add_device()
947 targ->encl_slot = le16toh(config_page.Slot); in mprsas_add_device()
948 targ->encl_level = config_page.EnclosureLevel; in mprsas_add_device()
949 targ->connector_name[0] = config_page.ConnectorName[0]; in mprsas_add_device()
950 targ->connector_name[1] = config_page.ConnectorName[1]; in mprsas_add_device()
951 targ->connector_name[2] = config_page.ConnectorName[2]; in mprsas_add_device()
952 targ->connector_name[3] = config_page.ConnectorName[3]; in mprsas_add_device()
953 targ->handle = handle; in mprsas_add_device()
954 targ->parent_handle = le16toh(config_page.ParentDevHandle); in mprsas_add_device()
955 targ->sasaddr = mpr_to_u64(&config_page.SASAddress); in mprsas_add_device()
956 targ->parent_sasaddr = le64toh(parent_sas_address); in mprsas_add_device()
957 targ->parent_devinfo = parent_devinfo; in mprsas_add_device()
958 targ->tid = id; in mprsas_add_device()
959 targ->linkrate = (linkrate>>4); in mprsas_add_device()
960 targ->flags = 0; in mprsas_add_device()
962 targ->flags = MPR_TARGET_IS_SATA_SSD; in mprsas_add_device()
968 targ->scsi_req_desc_type = in mprsas_add_device()
973 targ->encl_level_valid = TRUE; in mprsas_add_device()
975 TAILQ_INIT(&targ->commands); in mprsas_add_device()
976 TAILQ_INIT(&targ->timedout_commands); in mprsas_add_device()
977 while (!SLIST_EMPTY(&targ->luns)) { in mprsas_add_device()
978 lun = SLIST_FIRST(&targ->luns); in mprsas_add_device()
979 SLIST_REMOVE_HEAD(&targ->luns, lun_link); in mprsas_add_device()
982 SLIST_INIT(&targ->luns); in mprsas_add_device()
984 mpr_describe_devinfo(targ->devinfo, devstring, 80); in mprsas_add_device()
985 mpr_dprint(sc, (MPR_INFO|MPR_MAPPING), "Found device <%s> <%s> " in mprsas_add_device()
986 "handle<0x%04x> enclosureHandle<0x%04x> slot %d\n", devstring, in mprsas_add_device()
987 mpr_describe_table(mpr_linkrate_names, targ->linkrate), in mprsas_add_device()
988 targ->handle, targ->encl_handle, targ->encl_slot); in mprsas_add_device()
989 if (targ->encl_level_valid) { in mprsas_add_device()
991 "and connector name (%4s)\n", targ->encl_level, in mprsas_add_device()
992 targ->connector_name); in mprsas_add_device()
995 mpr_dprint(sc, MPR_MAPPING, "Target id 0x%x added\n", targ->tid); in mprsas_add_device()
1006 for (i = 1; i < sc->num_reqs; i++) { in mprsas_add_device()
1007 cm = &sc->commands[i]; in mprsas_add_device()
1008 if (cm->cm_flags & MPR_CM_FLAGS_SATA_ID_TIMEOUT) { in mprsas_add_device()
1009 targ->timeouts++; in mprsas_add_device()
1010 cm->cm_flags |= MPR_CM_FLAGS_TIMEDOUT; in mprsas_add_device()
1012 if ((targ->tm = mprsas_alloc_tm(sc)) != NULL) { in mprsas_add_device()
1016 targ->tm->cm_targ = targ; in mprsas_add_device()
1017 mprsas_send_reset(sc, targ->tm, in mprsas_add_device()
1038 u64 *sas_address, u16 handle, u32 device_info, u8 *is_SATA_SSD) in mprsas_get_sas_address_for_sata_disk() argument
1053 rc = mprsas_get_sata_identify(sc, handle, &mpi_reply, in mprsas_get_sas_address_for_sata_disk()
1066 if (sc->spinup_wait_time > 0) { in mprsas_get_sas_address_for_sata_disk()
1069 sc->spinup_wait_time); in mprsas_get_sas_address_for_sata_disk()
1070 msleep(&sc->msleep_fake_chan, &sc->mpr_mtx, 0, in mprsas_get_sas_address_for_sata_disk()
1071 "mprid", sc->spinup_wait_time * hz); in mprsas_get_sas_address_for_sata_disk()
1080 "successfully for handle = 0x%x with try_count = %d\n", in mprsas_get_sas_address_for_sata_disk()
1081 __func__, handle, try_count); in mprsas_get_sas_address_for_sata_disk()
1083 mpr_dprint(sc, MPR_MAPPING, "%s: handle = 0x%x failed\n", in mprsas_get_sas_address_for_sata_disk()
1084 __func__, handle); in mprsas_get_sas_address_for_sata_disk()
1085 return -1; in mprsas_get_sas_address_for_sata_disk()
1132 mprsas_get_sata_identify(struct mpr_softc *sc, u16 handle, in mprsas_get_sata_identify() argument
1149 mpi_request = (MPI2_SATA_PASSTHROUGH_REQUEST *)cm->cm_req; in mprsas_get_sata_identify()
1151 mpi_request->Function = MPI2_FUNCTION_SATA_PASSTHROUGH; in mprsas_get_sata_identify()
1152 mpi_request->VF_ID = 0; in mprsas_get_sata_identify()
1153 mpi_request->DevHandle = htole16(handle); in mprsas_get_sata_identify()
1154 mpi_request->PassthroughFlags = (MPI2_SATA_PT_REQ_PT_FLAGS_PIO | in mprsas_get_sata_identify()
1156 mpi_request->DataLength = htole32(sz); in mprsas_get_sata_identify()
1157 mpi_request->CommandFIS[0] = 0x27; in mprsas_get_sata_identify()
1158 mpi_request->CommandFIS[1] = 0x80; in mprsas_get_sata_identify()
1159 mpi_request->CommandFIS[2] = (devinfo & in mprsas_get_sata_identify()
1161 cm->cm_sge = &mpi_request->SGL; in mprsas_get_sata_identify()
1162 cm->cm_sglsize = sizeof(MPI2_SGE_IO_UNION); in mprsas_get_sata_identify()
1163 cm->cm_flags = MPR_CM_FLAGS_DATAIN; in mprsas_get_sata_identify()
1164 cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; in mprsas_get_sata_identify()
1165 cm->cm_data = buffer; in mprsas_get_sata_identify()
1166 cm->cm_length = htole32(sz); in mprsas_get_sata_identify()
1174 cm->cm_timeout_handler = mprsas_ata_id_timeout; in mprsas_get_sata_identify()
1181 reply = (Mpi2SataPassthroughReply_t *)cm->cm_reply; in mprsas_get_sata_identify()
1196 if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) != in mprsas_get_sata_identify()
1199 "Error reading device %#x SATA PASSTHRU; iocstatus= 0x%x\n", in mprsas_get_sata_identify()
1200 handle, reply->IOCStatus); in mprsas_get_sata_identify()
1210 if ((cm->cm_flags & MPR_CM_FLAGS_SATA_ID_TIMEOUT) == 0) { in mprsas_get_sata_identify()
1229 free(cm->cm_data, M_MPR); in mprsas_ata_id_complete()
1246 cm->cm_flags |= MPR_CM_FLAGS_SATA_ID_TIMEOUT; in mprsas_ata_id_timeout()
1252 cm->cm_complete = mprsas_ata_id_complete; in mprsas_ata_id_timeout()
1256 mprsas_add_pcie_device(struct mpr_softc *sc, u16 handle, u8 linkrate) in mprsas_add_pcie_device() argument
1270 sassc = sc->sassc; in mprsas_add_pcie_device()
1273 MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle))) { in mprsas_add_pcie_device()
1274 printf("%s: error reading PCIe device page0\n", __func__); in mprsas_add_pcie_device()
1289 printf("%s: error reading PCIe device %#x page0\n", in mprsas_add_pcie_device()
1301 mpr_dprint(sc, MPR_INFO, "PCIe WWID from PCIe device page0 = %jx\n", in mprsas_add_pcie_device()
1305 MPI26_PCIE_DEVICE_PGAD_FORM_HANDLE, handle))) { in mprsas_add_pcie_device()
1306 printf("%s: error reading PCIe device page2\n", __func__); in mprsas_add_pcie_device()
1311 id = mpr_mapping_get_tid(sc, pcie_wwid, handle); in mprsas_add_pcie_device()
1314 "Could not get ID for device with handle 0x%04x\n", in mprsas_add_pcie_device()
1315 __FILE__, __LINE__, __func__, handle); in mprsas_add_pcie_device()
1319 mpr_dprint(sc, MPR_MAPPING, "%s: Target ID for added device is %d.\n", in mprsas_add_pcie_device()
1329 mpr_dprint(sc, MPR_MAPPING, "WWID from PCIe device page0 = %jx\n", in mprsas_add_pcie_device()
1331 targ = &sassc->targets[id]; in mprsas_add_pcie_device()
1332 targ->devinfo = device_info; in mprsas_add_pcie_device()
1333 targ->encl_handle = le16toh(config_page.EnclosureHandle); in mprsas_add_pcie_device()
1334 targ->encl_slot = le16toh(config_page.Slot); in mprsas_add_pcie_device()
1335 targ->encl_level = config_page.EnclosureLevel; in mprsas_add_pcie_device()
1336 targ->connector_name[0] = ((char *)&config_page.ConnectorName)[0]; in mprsas_add_pcie_device()
1337 targ->connector_name[1] = ((char *)&config_page.ConnectorName)[1]; in mprsas_add_pcie_device()
1338 targ->connector_name[2] = ((char *)&config_page.ConnectorName)[2]; in mprsas_add_pcie_device()
1339 targ->connector_name[3] = ((char *)&config_page.ConnectorName)[3]; in mprsas_add_pcie_device()
1340 targ->is_nvme = device_info & MPI26_PCIE_DEVINFO_NVME; in mprsas_add_pcie_device()
1341 targ->MDTS = config_page2.MaximumDataTransferSize; in mprsas_add_pcie_device()
1342 if (targ->is_nvme) in mprsas_add_pcie_device()
1343 targ->controller_reset_timeout = config_page2.ControllerResetTO; in mprsas_add_pcie_device()
1348 targ->encl_level_valid = TRUE; in mprsas_add_pcie_device()
1349 targ->handle = handle; in mprsas_add_pcie_device()
1350 targ->parent_handle = le16toh(config_page.ParentDevHandle); in mprsas_add_pcie_device()
1351 targ->sasaddr = mpr_to_u64(&config_page.WWID); in mprsas_add_pcie_device()
1352 targ->parent_sasaddr = le64toh(parent_wwid); in mprsas_add_pcie_device()
1353 targ->parent_devinfo = parent_devinfo; in mprsas_add_pcie_device()
1354 targ->tid = id; in mprsas_add_pcie_device()
1355 targ->linkrate = linkrate; in mprsas_add_pcie_device()
1356 targ->flags = 0; in mprsas_add_pcie_device()
1361 targ->scsi_req_desc_type = in mprsas_add_pcie_device()
1364 TAILQ_INIT(&targ->commands); in mprsas_add_pcie_device()
1365 TAILQ_INIT(&targ->timedout_commands); in mprsas_add_pcie_device()
1366 while (!SLIST_EMPTY(&targ->luns)) { in mprsas_add_pcie_device()
1367 lun = SLIST_FIRST(&targ->luns); in mprsas_add_pcie_device()
1368 SLIST_REMOVE_HEAD(&targ->luns, lun_link); in mprsas_add_pcie_device()
1371 SLIST_INIT(&targ->luns); in mprsas_add_pcie_device()
1373 mpr_describe_devinfo(targ->devinfo, devstring, 80); in mprsas_add_pcie_device()
1374 mpr_dprint(sc, (MPR_INFO|MPR_MAPPING), "Found PCIe device <%s> <%s> " in mprsas_add_pcie_device()
1375 "handle<0x%04x> enclosureHandle<0x%04x> slot %d\n", devstring, in mprsas_add_pcie_device()
1376 mpr_describe_table(mpr_pcie_linkrate_names, targ->linkrate), in mprsas_add_pcie_device()
1377 targ->handle, targ->encl_handle, targ->encl_slot); in mprsas_add_pcie_device()
1378 if (targ->encl_level_valid) { in mprsas_add_pcie_device()
1380 "and connector name (%4s)\n", targ->encl_level, in mprsas_add_pcie_device()
1381 targ->connector_name); in mprsas_add_pcie_device()
1384 mpr_dprint(sc, MPR_MAPPING, "Target id 0x%x added\n", targ->tid); in mprsas_add_pcie_device()
1392 mprsas_volume_add(struct mpr_softc *sc, u16 handle) in mprsas_volume_add() argument
1401 sassc = sc->sassc; in mprsas_volume_add()
1404 mpr_config_get_volume_wwid(sc, handle, &wwid); in mprsas_volume_add()
1412 id = mpr_mapping_get_raid_tid(sc, wwid, handle); in mprsas_volume_add()
1414 printf("%s: could not get ID for volume with handle 0x%04x and " in mprsas_volume_add()
1415 "WWID 0x%016llx\n", __func__, handle, in mprsas_volume_add()
1421 targ = &sassc->targets[id]; in mprsas_volume_add()
1422 targ->tid = id; in mprsas_volume_add()
1423 targ->handle = handle; in mprsas_volume_add()
1424 targ->devname = wwid; in mprsas_volume_add()
1425 targ->flags = MPR_TARGET_FLAGS_VOLUME; in mprsas_volume_add()
1426 TAILQ_INIT(&targ->commands); in mprsas_volume_add()
1427 TAILQ_INIT(&targ->timedout_commands); in mprsas_volume_add()
1428 while (!SLIST_EMPTY(&targ->luns)) { in mprsas_volume_add()
1429 lun = SLIST_FIRST(&targ->luns); in mprsas_volume_add()
1430 SLIST_REMOVE_HEAD(&targ->luns, lun_link); in mprsas_volume_add()
1433 SLIST_INIT(&targ->luns); in mprsas_volume_add()
1436 targ->tid, wwid); in mprsas_volume_add()
1447 * SATA direct-access device. This helps to ensure that data corruption is
1456 struct mprsas_softc *sassc = sc->sassc; in mprsas_SSU_to_SATA_devices()
1458 path_id_t pathid = cam_sim_path(sassc->sim); in mprsas_SSU_to_SATA_devices()
1467 * For each target, issue a StartStopUnit command to stop the device. in mprsas_SSU_to_SATA_devices()
1469 sc->SSU_started = TRUE; in mprsas_SSU_to_SATA_devices()
1470 sc->SSU_refcount = 0; in mprsas_SSU_to_SATA_devices()
1471 for (targetid = 0; targetid < sc->max_devices; targetid++) { in mprsas_SSU_to_SATA_devices()
1472 target = &sassc->targets[targetid]; in mprsas_SSU_to_SATA_devices()
1473 if (target->handle == 0x0) { in mprsas_SSU_to_SATA_devices()
1478 * The stop_at_shutdown flag will be set if this device is in mprsas_SSU_to_SATA_devices()
1479 * a SATA direct-access end device. in mprsas_SSU_to_SATA_devices()
1481 if (target->stop_at_shutdown) { in mprsas_SSU_to_SATA_devices()
1489 if (xpt_create_path(&ccb->ccb_h.path, xpt_periph, in mprsas_SSU_to_SATA_devices()
1497 xpt_path_string(ccb->ccb_h.path, path_str, in mprsas_SSU_to_SATA_devices()
1501 "handle %d\n", path_str, target->handle); in mprsas_SSU_to_SATA_devices()
1509 sc->SSU_refcount++; in mprsas_SSU_to_SATA_devices()
1510 ccb->ccb_h.target_id = in mprsas_SSU_to_SATA_devices()
1511 xpt_path_target_id(ccb->ccb_h.path); in mprsas_SSU_to_SATA_devices()
1512 ccb->ccb_h.ppriv_ptr1 = sassc; in mprsas_SSU_to_SATA_devices()
1513 scsi_start_stop(&ccb->csio, in mprsas_SSU_to_SATA_devices()
1542 while (sc->SSU_refcount > 0) { in mprsas_SSU_to_SATA_devices()
1545 xpt_sim_poll(sassc->sim); in mprsas_SSU_to_SATA_devices()
1547 if (--timeout == 0) { in mprsas_SSU_to_SATA_devices()
1564 sassc = (struct mprsas_softc *)done_ccb->ccb_h.ppriv_ptr1; in mprsas_stop_unit_done()
1566 xpt_path_string(done_ccb->ccb_h.path, path_str, sizeof(path_str)); in mprsas_stop_unit_done()
1567 mpr_dprint(sassc->sc, MPR_INFO, "Completing stop unit for %s\n", in mprsas_stop_unit_done()
1575 xpt_free_path(done_ccb->ccb_h.path); in mprsas_stop_unit_done()
1580 * mprsas_ir_shutdown - IR shutdown notification
1592 u16 ioc_pg8_flags = le16toh(sc->ioc_pg8.Flags); in mprsas_ir_shutdown()
1604 if (!sc->ir_firmware) in mprsas_ir_shutdown()
1608 // TODO-later, this should be looked up in the RAID config structure in mprsas_ir_shutdown()
1610 volume_mapping_flags = le16toh(sc->ioc_pg8.IRVolumeMappingFlags) & in mprsas_ir_shutdown()
1617 start_idx = sc->max_devices - sc->max_volumes; in mprsas_ir_shutdown()
1618 end_idx = start_idx + sc->max_volumes - 1; in mprsas_ir_shutdown()
1621 mt_entry = &sc->mapping_table[id]; in mprsas_ir_shutdown()
1622 if ((mt_entry->physical_id != 0) && in mprsas_ir_shutdown()
1623 (mt_entry->missing_count == 0)) { in mprsas_ir_shutdown()
1637 action = (MPI2_RAID_ACTION_REQUEST *)cm->cm_req; in mprsas_ir_shutdown()
1638 action->Function = MPI2_FUNCTION_RAID_ACTION; in mprsas_ir_shutdown()
1639 action->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED; in mprsas_ir_shutdown()
1640 cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; in mprsas_ir_shutdown()
1663 for (targetid = 0; targetid < sc->max_devices; targetid++) { in mprsas_ir_shutdown()
1664 target = &sc->sassc->targets[targetid]; in mprsas_ir_shutdown()
1665 if (target->handle == 0x0) { in mprsas_ir_shutdown()
1669 if (target->supports_SSU) { in mprsas_ir_shutdown()
1670 switch (sc->enable_ssu) { in mprsas_ir_shutdown()
1672 target->stop_at_shutdown = FALSE; in mprsas_ir_shutdown()
1675 target->stop_at_shutdown = TRUE; in mprsas_ir_shutdown()
1676 if (target->flags & MPR_TARGET_IS_SATA_SSD) { in mprsas_ir_shutdown()
1677 target->stop_at_shutdown = FALSE; in mprsas_ir_shutdown()
1681 target->stop_at_shutdown = TRUE; in mprsas_ir_shutdown()
1685 target->stop_at_shutdown = TRUE; in mprsas_ir_shutdown()
1686 if ((target->flags & in mprsas_ir_shutdown()
1688 target->stop_at_shutdown = FALSE; in mprsas_ir_shutdown()