2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2011-2015 LSI Corp.
5 * Copyright (c) 2013-2015 Avago Technologies
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * Avago Technologies (LSI) MPT-Fusion Host Adapter FreeBSD
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
35 /* Communications core for Avago Technologies (LSI) MPT2 */
37 /* TODO Move headers to mpsvar */
38 #include <sys/types.h>
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/selinfo.h>
43 #include <sys/module.h>
47 #include <sys/malloc.h>
49 #include <sys/sysctl.h>
50 #include <sys/endian.h>
51 #include <sys/queue.h>
52 #include <sys/kthread.h>
53 #include <sys/taskqueue.h>
56 #include <machine/bus.h>
57 #include <machine/resource.h>
60 #include <machine/stdarg.h>
63 #include <cam/cam_ccb.h>
64 #include <cam/cam_debug.h>
65 #include <cam/cam_sim.h>
66 #include <cam/cam_xpt_sim.h>
67 #include <cam/cam_xpt_periph.h>
68 #include <cam/cam_periph.h>
69 #include <cam/scsi/scsi_all.h>
70 #include <cam/scsi/scsi_message.h>
72 #include <dev/mps/mpi/mpi2_type.h>
73 #include <dev/mps/mpi/mpi2.h>
74 #include <dev/mps/mpi/mpi2_ioc.h>
75 #include <dev/mps/mpi/mpi2_sas.h>
76 #include <dev/mps/mpi/mpi2_cnfg.h>
77 #include <dev/mps/mpi/mpi2_init.h>
78 #include <dev/mps/mpi/mpi2_raid.h>
79 #include <dev/mps/mpi/mpi2_tool.h>
80 #include <dev/mps/mps_ioctl.h>
81 #include <dev/mps/mpsvar.h>
82 #include <dev/mps/mps_table.h>
83 #include <dev/mps/mps_sas.h>
85 /* For Hashed SAS Address creation for SATA Drives */
86 #define MPT2SAS_SN_LEN 20
87 #define MPT2SAS_MN_LEN 40
89 struct mps_fw_event_work {
92 TAILQ_ENTRY(mps_fw_event_work) ev_link;
95 union _sata_sas_address {
104 * define the IDENTIFY DEVICE structure
106 struct _ata_identify_device_data {
107 u16 reserved1[10]; /* 0-9 */
108 u16 serial_number[10]; /* 10-19 */
109 u16 reserved2[7]; /* 20-26 */
110 u16 model_number[20]; /* 27-46*/
111 u16 reserved3[170]; /* 47-216 */
112 u16 rotational_speed; /* 217 */
113 u16 reserved4[38]; /* 218-255 */
115 static u32 event_count;
116 static void mpssas_fw_work(struct mps_softc *sc,
117 struct mps_fw_event_work *fw_event);
118 static void mpssas_fw_event_free(struct mps_softc *,
119 struct mps_fw_event_work *);
120 static int mpssas_add_device(struct mps_softc *sc, u16 handle, u8 linkrate);
121 static int mpssas_get_sata_identify(struct mps_softc *sc, u16 handle,
122 Mpi2SataPassthroughReply_t *mpi_reply, char *id_buffer, int sz,
124 static void mpssas_ata_id_timeout(void *data);
125 int mpssas_get_sas_address_for_sata_disk(struct mps_softc *sc,
126 u64 *sas_address, u16 handle, u32 device_info, u8 *is_SATA_SSD);
127 static int mpssas_volume_add(struct mps_softc *sc,
129 static void mpssas_SSU_to_SATA_devices(struct mps_softc *sc);
130 static void mpssas_stop_unit_done(struct cam_periph *periph,
131 union ccb *done_ccb);
134 mpssas_evt_handler(struct mps_softc *sc, uintptr_t data,
135 MPI2_EVENT_NOTIFICATION_REPLY *event)
137 struct mps_fw_event_work *fw_event;
140 mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
141 MPS_DPRINT_EVENT(sc, sas, event);
142 mpssas_record_event(sc, event);
144 fw_event = malloc(sizeof(struct mps_fw_event_work), M_MPT2,
147 printf("%s: allocate failed for fw_event\n", __func__);
150 sz = le16toh(event->EventDataLength) * 4;
151 fw_event->event_data = malloc(sz, M_MPT2, M_ZERO|M_NOWAIT);
152 if (!fw_event->event_data) {
153 printf("%s: allocate failed for event_data\n", __func__);
154 free(fw_event, M_MPT2);
158 bcopy(event->EventData, fw_event->event_data, sz);
159 fw_event->event = event->Event;
160 if ((event->Event == MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST ||
161 event->Event == MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE ||
162 event->Event == MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST) &&
163 sc->track_mapping_events)
164 sc->pending_map_events++;
167 * When wait_for_port_enable flag is set, make sure that all the events
168 * are processed. Increment the startup_refcount and decrement it after
169 * events are processed.
171 if ((event->Event == MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST ||
172 event->Event == MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST) &&
173 sc->wait_for_port_enable)
174 mpssas_startup_increment(sc->sassc);
176 TAILQ_INSERT_TAIL(&sc->sassc->ev_queue, fw_event, ev_link);
177 taskqueue_enqueue(sc->sassc->ev_tq, &sc->sassc->ev_task);
182 mpssas_fw_event_free(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
185 free(fw_event->event_data, M_MPT2);
186 free(fw_event, M_MPT2);
190 * _mps_fw_work - delayed task for processing firmware events
191 * @sc: per adapter object
192 * @fw_event: The fw_event_work object
198 mpssas_fw_work(struct mps_softc *sc, struct mps_fw_event_work *fw_event)
200 struct mpssas_softc *sassc;
203 mps_dprint(sc, MPS_EVENT, "(%d)->(%s) Working on Event: [%x]\n",
204 event_count++,__func__,fw_event->event);
205 switch (fw_event->event) {
206 case MPI2_EVENT_SAS_TOPOLOGY_CHANGE_LIST:
208 MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *data;
209 MPI2_EVENT_SAS_TOPO_PHY_ENTRY *phy;
212 data = (MPI2_EVENT_DATA_SAS_TOPOLOGY_CHANGE_LIST *)
213 fw_event->event_data;
215 mps_mapping_topology_change_event(sc, fw_event->event_data);
217 for (i = 0; i < data->NumEntries; i++) {
219 switch (phy->PhyStatus & MPI2_EVENT_SAS_TOPO_RC_MASK) {
220 case MPI2_EVENT_SAS_TOPO_RC_TARG_ADDED:
221 if (mpssas_add_device(sc,
222 le16toh(phy->AttachedDevHandle),
224 mps_dprint(sc, MPS_ERROR, "%s: "
225 "failed to add device with handle "
227 le16toh(phy->AttachedDevHandle));
228 mpssas_prepare_remove(sassc, le16toh(
229 phy->AttachedDevHandle));
232 case MPI2_EVENT_SAS_TOPO_RC_TARG_NOT_RESPONDING:
233 mpssas_prepare_remove(sassc,le16toh(
234 phy->AttachedDevHandle));
236 case MPI2_EVENT_SAS_TOPO_RC_PHY_CHANGED:
237 case MPI2_EVENT_SAS_TOPO_RC_NO_CHANGE:
238 case MPI2_EVENT_SAS_TOPO_RC_DELAY_NOT_RESPONDING:
244 * refcount was incremented for this event in
245 * mpssas_evt_handler. Decrement it here because the event has
248 mpssas_startup_decrement(sassc);
251 case MPI2_EVENT_SAS_DISCOVERY:
253 MPI2_EVENT_DATA_SAS_DISCOVERY *data;
255 data = (MPI2_EVENT_DATA_SAS_DISCOVERY *)fw_event->event_data;
257 if (data->ReasonCode & MPI2_EVENT_SAS_DISC_RC_STARTED)
258 mps_dprint(sc, MPS_TRACE,"SAS discovery start event\n");
259 if (data->ReasonCode & MPI2_EVENT_SAS_DISC_RC_COMPLETED) {
260 mps_dprint(sc, MPS_TRACE,"SAS discovery stop event\n");
261 sassc->flags &= ~MPSSAS_IN_DISCOVERY;
262 mpssas_discovery_end(sassc);
266 case MPI2_EVENT_SAS_ENCL_DEVICE_STATUS_CHANGE:
268 Mpi2EventDataSasEnclDevStatusChange_t *data;
269 data = (Mpi2EventDataSasEnclDevStatusChange_t *)
270 fw_event->event_data;
271 mps_mapping_enclosure_dev_status_change_event(sc,
272 fw_event->event_data);
275 case MPI2_EVENT_IR_CONFIGURATION_CHANGE_LIST:
277 Mpi2EventIrConfigElement_t *element;
280 Mpi2EventDataIrConfigChangeList_t *event_data;
281 struct mpssas_target *targ;
284 event_data = fw_event->event_data;
285 foreign_config = (le32toh(event_data->Flags) &
286 MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG) ? 1 : 0;
289 (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0];
290 id = mps_mapping_get_raid_tid_from_handle(sc,
291 element->VolDevHandle);
293 mps_mapping_ir_config_change_event(sc, event_data);
295 for (i = 0; i < event_data->NumElements; i++, element++) {
296 switch (element->ReasonCode) {
297 case MPI2_EVENT_IR_CHANGE_RC_VOLUME_CREATED:
298 case MPI2_EVENT_IR_CHANGE_RC_ADDED:
299 if (!foreign_config) {
300 if (mpssas_volume_add(sc,
301 le16toh(element->VolDevHandle))){
302 printf("%s: failed to add RAID "
303 "volume with handle 0x%x\n",
304 __func__, le16toh(element->
309 case MPI2_EVENT_IR_CHANGE_RC_VOLUME_DELETED:
310 case MPI2_EVENT_IR_CHANGE_RC_REMOVED:
312 * Rescan after volume is deleted or removed.
314 if (!foreign_config) {
315 if (id == MPS_MAP_BAD_ID) {
316 printf("%s: could not get ID "
317 "for volume with handle "
318 "0x%04x\n", __func__,
319 le16toh(element->VolDevHandle));
323 targ = &sassc->targets[id];
325 targ->encl_slot = 0x0;
326 targ->encl_handle = 0x0;
327 targ->exp_dev_handle = 0x0;
329 targ->linkrate = 0x0;
330 mpssas_rescan_target(sc, targ);
331 printf("RAID target id 0x%x removed\n",
335 case MPI2_EVENT_IR_CHANGE_RC_PD_CREATED:
336 case MPI2_EVENT_IR_CHANGE_RC_HIDE:
338 * Phys Disk of a volume has been created. Hide
341 targ = mpssas_find_target_by_handle(sassc, 0,
342 element->PhysDiskDevHandle);
347 * Set raid component flags only if it is not
348 * WD. OR WrapDrive with
349 * WD_HIDE_ALWAYS/WD_HIDE_IF_VOLUME is set in
352 if((!sc->WD_available) ||
353 ((sc->WD_available &&
354 (sc->WD_hide_expose == MPS_WD_HIDE_ALWAYS)) ||
355 (sc->WD_valid_config && (sc->WD_hide_expose ==
356 MPS_WD_HIDE_IF_VOLUME)))) {
357 targ->flags |= MPS_TARGET_FLAGS_RAID_COMPONENT;
359 mpssas_rescan_target(sc, targ);
362 case MPI2_EVENT_IR_CHANGE_RC_PD_DELETED:
364 * Phys Disk of a volume has been deleted.
365 * Expose it to the OS.
367 if (mpssas_add_device(sc,
368 le16toh(element->PhysDiskDevHandle), 0)){
369 printf("%s: failed to add device with "
370 "handle 0x%x\n", __func__,
371 le16toh(element->PhysDiskDevHandle));
372 mpssas_prepare_remove(sassc, le16toh(element->
379 * refcount was incremented for this event in
380 * mpssas_evt_handler. Decrement it here because the event has
383 mpssas_startup_decrement(sassc);
386 case MPI2_EVENT_IR_VOLUME:
388 Mpi2EventDataIrVolume_t *event_data = fw_event->event_data;
391 * Informational only.
393 mps_dprint(sc, MPS_EVENT, "Received IR Volume event:\n");
394 switch (event_data->ReasonCode) {
395 case MPI2_EVENT_IR_VOLUME_RC_SETTINGS_CHANGED:
396 mps_dprint(sc, MPS_EVENT, " Volume Settings "
397 "changed from 0x%x to 0x%x for Volome with "
398 "handle 0x%x", le32toh(event_data->PreviousValue),
399 le32toh(event_data->NewValue),
400 le16toh(event_data->VolDevHandle));
402 case MPI2_EVENT_IR_VOLUME_RC_STATUS_FLAGS_CHANGED:
403 mps_dprint(sc, MPS_EVENT, " Volume Status "
404 "changed from 0x%x to 0x%x for Volome with "
405 "handle 0x%x", le32toh(event_data->PreviousValue),
406 le32toh(event_data->NewValue),
407 le16toh(event_data->VolDevHandle));
409 case MPI2_EVENT_IR_VOLUME_RC_STATE_CHANGED:
410 mps_dprint(sc, MPS_EVENT, " Volume State "
411 "changed from 0x%x to 0x%x for Volome with "
412 "handle 0x%x", le32toh(event_data->PreviousValue),
413 le32toh(event_data->NewValue),
414 le16toh(event_data->VolDevHandle));
416 struct mpssas_target *targ;
417 state = le32toh(event_data->NewValue);
419 case MPI2_RAID_VOL_STATE_MISSING:
420 case MPI2_RAID_VOL_STATE_FAILED:
421 mpssas_prepare_volume_remove(sassc, event_data->
425 case MPI2_RAID_VOL_STATE_ONLINE:
426 case MPI2_RAID_VOL_STATE_DEGRADED:
427 case MPI2_RAID_VOL_STATE_OPTIMAL:
428 targ = mpssas_find_target_by_handle(sassc, 0, event_data->VolDevHandle);
430 printf("%s %d: Volume handle 0x%x is already added \n",
431 __func__, __LINE__ , event_data->VolDevHandle);
434 if (mpssas_volume_add(sc, le16toh(event_data->VolDevHandle))) {
435 printf("%s: failed to add RAID "
436 "volume with handle 0x%x\n",
437 __func__, le16toh(event_data->
450 case MPI2_EVENT_IR_PHYSICAL_DISK:
452 Mpi2EventDataIrPhysicalDisk_t *event_data =
453 fw_event->event_data;
454 struct mpssas_target *targ;
457 * Informational only.
459 mps_dprint(sc, MPS_EVENT, "Received IR Phys Disk event:\n");
460 switch (event_data->ReasonCode) {
461 case MPI2_EVENT_IR_PHYSDISK_RC_SETTINGS_CHANGED:
462 mps_dprint(sc, MPS_EVENT, " Phys Disk Settings "
463 "changed from 0x%x to 0x%x for Phys Disk Number "
464 "%d and handle 0x%x at Enclosure handle 0x%x, Slot "
465 "%d", le32toh(event_data->PreviousValue),
466 le32toh(event_data->NewValue),
467 event_data->PhysDiskNum,
468 le16toh(event_data->PhysDiskDevHandle),
469 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
471 case MPI2_EVENT_IR_PHYSDISK_RC_STATUS_FLAGS_CHANGED:
472 mps_dprint(sc, MPS_EVENT, " Phys Disk Status changed "
473 "from 0x%x to 0x%x for Phys Disk Number %d and "
474 "handle 0x%x at Enclosure handle 0x%x, Slot %d",
475 le32toh(event_data->PreviousValue),
476 le32toh(event_data->NewValue), event_data->PhysDiskNum,
477 le16toh(event_data->PhysDiskDevHandle),
478 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
480 case MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED:
481 mps_dprint(sc, MPS_EVENT, " Phys Disk State changed "
482 "from 0x%x to 0x%x for Phys Disk Number %d and "
483 "handle 0x%x at Enclosure handle 0x%x, Slot %d",
484 le32toh(event_data->PreviousValue),
485 le32toh(event_data->NewValue), event_data->PhysDiskNum,
486 le16toh(event_data->PhysDiskDevHandle),
487 le16toh(event_data->EnclosureHandle), le16toh(event_data->Slot));
488 switch (event_data->NewValue) {
489 case MPI2_RAID_PD_STATE_ONLINE:
490 case MPI2_RAID_PD_STATE_DEGRADED:
491 case MPI2_RAID_PD_STATE_REBUILDING:
492 case MPI2_RAID_PD_STATE_OPTIMAL:
493 case MPI2_RAID_PD_STATE_HOT_SPARE:
494 targ = mpssas_find_target_by_handle(sassc, 0,
495 event_data->PhysDiskDevHandle);
497 if(!sc->WD_available) {
498 targ->flags |= MPS_TARGET_FLAGS_RAID_COMPONENT;
499 printf("%s %d: Found Target for handle 0x%x. \n",
500 __func__, __LINE__ , event_data->PhysDiskDevHandle);
501 } else if ((sc->WD_available &&
502 (sc->WD_hide_expose == MPS_WD_HIDE_ALWAYS)) ||
503 (sc->WD_valid_config && (sc->WD_hide_expose ==
504 MPS_WD_HIDE_IF_VOLUME))) {
505 targ->flags |= MPS_TARGET_FLAGS_RAID_COMPONENT;
506 printf("%s %d: WD: Found Target for handle 0x%x. \n",
507 __func__, __LINE__ , event_data->PhysDiskDevHandle);
511 case MPI2_RAID_PD_STATE_OFFLINE:
512 case MPI2_RAID_PD_STATE_NOT_CONFIGURED:
513 case MPI2_RAID_PD_STATE_NOT_COMPATIBLE:
515 targ = mpssas_find_target_by_handle(sassc, 0,
516 event_data->PhysDiskDevHandle);
518 targ->flags |= ~MPS_TARGET_FLAGS_RAID_COMPONENT;
519 printf("%s %d: Found Target for handle 0x%x. \n",
520 __func__, __LINE__ , event_data->PhysDiskDevHandle);
529 case MPI2_EVENT_IR_OPERATION_STATUS:
531 Mpi2EventDataIrOperationStatus_t *event_data =
532 fw_event->event_data;
535 * Informational only.
537 mps_dprint(sc, MPS_EVENT, "Received IR Op Status event:\n");
538 mps_dprint(sc, MPS_EVENT, " RAID Operation of %d is %d "
539 "percent complete for Volume with handle 0x%x",
540 event_data->RAIDOperation, event_data->PercentComplete,
541 le16toh(event_data->VolDevHandle));
544 case MPI2_EVENT_LOG_ENTRY_ADDED:
546 pMpi2EventDataLogEntryAdded_t logEntry;
547 uint16_t logQualifier;
550 logEntry = (pMpi2EventDataLogEntryAdded_t)fw_event->event_data;
551 logQualifier = logEntry->LogEntryQualifier;
553 if (logQualifier == MPI2_WD_LOG_ENTRY) {
554 logCode = logEntry->LogData[0];
557 case MPI2_WD_SSD_THROTTLING:
558 printf("WarpDrive Warning: IO Throttling has "
559 "occurred in the WarpDrive subsystem. "
560 "Check WarpDrive documentation for "
561 "additional details\n");
563 case MPI2_WD_DRIVE_LIFE_WARN:
564 printf("WarpDrive Warning: Program/Erase "
565 "Cycles for the WarpDrive subsystem in "
566 "degraded range. Check WarpDrive "
567 "documentation for additional details\n");
569 case MPI2_WD_DRIVE_LIFE_DEAD:
570 printf("WarpDrive Fatal Error: There are no "
571 "Program/Erase Cycles for the WarpDrive "
572 "subsystem. The storage device will be in "
573 "read-only mode. Check WarpDrive "
574 "documentation for additional details\n");
576 case MPI2_WD_RAIL_MON_FAIL:
577 printf("WarpDrive Fatal Error: The Backup Rail "
578 "Monitor has failed on the WarpDrive "
579 "subsystem. Check WarpDrive documentation "
580 "for additional details\n");
588 case MPI2_EVENT_SAS_DEVICE_STATUS_CHANGE:
589 case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
591 mps_dprint(sc, MPS_TRACE,"Unhandled event 0x%0X\n",
596 mps_dprint(sc, MPS_EVENT, "(%d)->(%s) Event Free: [%x]\n",event_count,__func__, fw_event->event);
597 mpssas_fw_event_free(sc, fw_event);
601 mpssas_firmware_event_work(void *arg, int pending)
603 struct mps_fw_event_work *fw_event;
604 struct mps_softc *sc;
606 sc = (struct mps_softc *)arg;
608 while ((fw_event = TAILQ_FIRST(&sc->sassc->ev_queue)) != NULL) {
609 TAILQ_REMOVE(&sc->sassc->ev_queue, fw_event, ev_link);
610 mpssas_fw_work(sc, fw_event);
616 mpssas_add_device(struct mps_softc *sc, u16 handle, u8 linkrate){
618 struct mpssas_softc *sassc;
619 struct mpssas_target *targ;
620 Mpi2ConfigReply_t mpi_reply;
621 Mpi2SasDevicePage0_t config_page;
622 uint64_t sas_address;
623 uint64_t parent_sas_address = 0;
624 u32 device_info, parent_devinfo = 0;
626 int ret = 1, error = 0, i;
627 struct mpssas_lun *lun;
629 struct mps_command *cm;
632 mpssas_startup_increment(sassc);
633 if (mps_config_get_sas_device_pg0(sc, &mpi_reply, &config_page,
634 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle) != 0) {
635 mps_dprint(sc, MPS_INFO|MPS_MAPPING|MPS_FAULT,
636 "Error reading SAS device %#x page0, iocstatus= 0x%x\n",
637 handle, mpi_reply.IOCStatus);
642 device_info = le32toh(config_page.DeviceInfo);
644 if (((device_info & MPI2_SAS_DEVICE_INFO_SMP_TARGET) == 0)
645 && (le16toh(config_page.ParentDevHandle) != 0)) {
646 Mpi2ConfigReply_t tmp_mpi_reply;
647 Mpi2SasDevicePage0_t parent_config_page;
649 if (mps_config_get_sas_device_pg0(sc, &tmp_mpi_reply,
650 &parent_config_page, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
651 le16toh(config_page.ParentDevHandle)) != 0) {
652 mps_dprint(sc, MPS_MAPPING|MPS_FAULT,
653 "Error reading parent SAS device %#x page0, "
655 le16toh(config_page.ParentDevHandle),
656 tmp_mpi_reply.IOCStatus);
658 parent_sas_address = parent_config_page.SASAddress.High;
659 parent_sas_address = (parent_sas_address << 32) |
660 parent_config_page.SASAddress.Low;
661 parent_devinfo = le32toh(parent_config_page.DeviceInfo);
664 /* TODO Check proper endianness */
665 sas_address = config_page.SASAddress.High;
666 sas_address = (sas_address << 32) | config_page.SASAddress.Low;
667 mps_dprint(sc, MPS_MAPPING, "Handle 0x%04x SAS Address from SAS device "
668 "page0 = %jx\n", handle, sas_address);
671 * Always get SATA Identify information because this is used to
672 * determine if Start/Stop Unit should be sent to the drive when the
673 * system is shutdown.
675 if (device_info & MPI2_SAS_DEVICE_INFO_SATA_DEVICE) {
676 ret = mpssas_get_sas_address_for_sata_disk(sc, &sas_address,
677 handle, device_info, &is_SATA_SSD);
679 mps_dprint(sc, MPS_MAPPING|MPS_ERROR,
680 "%s: failed to get disk type (SSD or HDD) for SATA "
681 "device with handle 0x%04x\n",
684 mps_dprint(sc, MPS_MAPPING, "Handle 0x%04x SAS Address "
685 "from SATA device = %jx\n", handle, sas_address);
691 * 1 - use the PhyNum field as a fallback to the mapping logic
692 * 0 - never use the PhyNum field
693 * -1 - only use the PhyNum field
695 * Note that using the Phy number to map a device can cause device adds
696 * to fail if multiple enclosures/expanders are in the topology. For
697 * example, if two devices are in the same slot number in two different
698 * enclosures within the topology, only one of those devices will be
699 * added. PhyNum mapping should not be used if multiple enclosures are
703 if (sc->use_phynum != -1)
704 id = mps_mapping_get_tid(sc, sas_address, handle);
705 if (id == MPS_MAP_BAD_ID) {
706 if ((sc->use_phynum == 0)
707 || ((id = config_page.PhyNum) > sassc->maxtargets)) {
708 mps_dprint(sc, MPS_INFO, "failure at %s:%d/%s()! "
709 "Could not get ID for device with handle 0x%04x\n",
710 __FILE__, __LINE__, __func__, handle);
715 mps_dprint(sc, MPS_MAPPING, "%s: Target ID for added device is %d.\n",
719 * Only do the ID check and reuse check if the target is not from a
720 * RAID Component. For Physical Disks of a Volume, the ID will be reused
721 * when a volume is deleted because the mapping entry for the PD will
722 * still be in the mapping table. The ID check should not be done here
723 * either since this PD is already being used.
725 targ = &sassc->targets[id];
726 if (!(targ->flags & MPS_TARGET_FLAGS_RAID_COMPONENT)) {
727 if (mpssas_check_id(sassc, id) != 0) {
728 mps_dprint(sc, MPS_MAPPING|MPS_INFO,
729 "Excluding target id %d\n", id);
734 if (targ->handle != 0x0) {
735 mps_dprint(sc, MPS_MAPPING, "Attempting to reuse "
736 "target id %d handle 0x%04x\n", id, targ->handle);
742 targ->devinfo = device_info;
743 targ->devname = le32toh(config_page.DeviceName.High);
744 targ->devname = (targ->devname << 32) |
745 le32toh(config_page.DeviceName.Low);
746 targ->encl_handle = le16toh(config_page.EnclosureHandle);
747 targ->encl_slot = le16toh(config_page.Slot);
748 targ->handle = handle;
749 targ->parent_handle = le16toh(config_page.ParentDevHandle);
750 targ->sasaddr = mps_to_u64(&config_page.SASAddress);
751 targ->parent_sasaddr = le64toh(parent_sas_address);
752 targ->parent_devinfo = parent_devinfo;
754 targ->linkrate = (linkrate>>4);
757 targ->flags = MPS_TARGET_IS_SATA_SSD;
759 TAILQ_INIT(&targ->commands);
760 TAILQ_INIT(&targ->timedout_commands);
761 while(!SLIST_EMPTY(&targ->luns)) {
762 lun = SLIST_FIRST(&targ->luns);
763 SLIST_REMOVE_HEAD(&targ->luns, lun_link);
766 SLIST_INIT(&targ->luns);
768 mps_describe_devinfo(targ->devinfo, devstring, 80);
769 mps_dprint(sc, MPS_MAPPING, "Found device <%s> <%s> <0x%04x> <%d/%d>\n",
770 devstring, mps_describe_table(mps_linkrate_names, targ->linkrate),
771 targ->handle, targ->encl_handle, targ->encl_slot);
773 #if __FreeBSD_version < 1000039
774 if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
776 mpssas_rescan_target(sc, targ);
777 mps_dprint(sc, MPS_MAPPING, "Target id 0x%x added\n", targ->tid);
780 * Check all commands to see if the SATA_ID_TIMEOUT flag has been set.
781 * If so, send a Target Reset TM to the target that was just created.
782 * An Abort Task TM should be used instead of a Target Reset, but that
783 * would be much more difficult because targets have not been fully
784 * discovered yet, and LUN's haven't been setup. So, just reset the
785 * target instead of the LUN.
787 for (i = 1; i < sc->num_reqs; i++) {
788 cm = &sc->commands[i];
789 if (cm->cm_flags & MPS_CM_FLAGS_SATA_ID_TIMEOUT) {
791 cm->cm_state = MPS_CM_STATE_TIMEDOUT;
793 if ((targ->tm = mpssas_alloc_tm(sc)) != NULL) {
794 mps_dprint(sc, MPS_INFO, "%s: sending Target "
795 "Reset for stuck SATA identify command "
796 "(cm = %p)\n", __func__, cm);
797 targ->tm->cm_targ = targ;
798 mpssas_send_reset(sc, targ->tm,
799 MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET);
801 mps_dprint(sc, MPS_ERROR, "Failed to allocate "
802 "tm for Target Reset after SATA ID command "
803 "timed out (cm %p)\n", cm);
806 * No need to check for more since the target is
807 * already being reset.
814 * Free the commands that may not have been freed from the SATA ID call
816 for (i = 1; i < sc->num_reqs; i++) {
817 cm = &sc->commands[i];
818 if (cm->cm_flags & MPS_CM_FLAGS_SATA_ID_TIMEOUT) {
819 mps_free_command(sc, cm);
822 mpssas_startup_decrement(sassc);
827 mpssas_get_sas_address_for_sata_disk(struct mps_softc *sc,
828 u64 *sas_address, u16 handle, u32 device_info, u8 *is_SATA_SSD)
830 Mpi2SataPassthroughReply_t mpi_reply;
831 int i, rc, try_count;
833 union _sata_sas_address hash_address;
834 struct _ata_identify_device_data ata_identify;
835 u8 buffer[MPT2SAS_MN_LEN + MPT2SAS_SN_LEN];
839 memset(&ata_identify, 0, sizeof(ata_identify));
842 rc = mpssas_get_sata_identify(sc, handle, &mpi_reply,
843 (char *)&ata_identify, sizeof(ata_identify), device_info);
845 ioc_status = le16toh(mpi_reply.IOCStatus)
846 & MPI2_IOCSTATUS_MASK;
847 sas_status = mpi_reply.SASStatus;
848 switch (ioc_status) {
849 case MPI2_IOCSTATUS_SUCCESS:
851 case MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR:
852 /* No sense sleeping. this error won't get better */
855 if (sc->spinup_wait_time > 0) {
856 mps_dprint(sc, MPS_INFO, "Sleeping %d seconds "
857 "after SATA ID error to wait for spinup\n",
858 sc->spinup_wait_time);
859 msleep(&sc->msleep_fake_chan, &sc->mps_mtx, 0,
860 "mpsid", sc->spinup_wait_time * hz);
863 } while (((rc && (rc != EWOULDBLOCK)) ||
865 (ioc_status != MPI2_IOCSTATUS_SCSI_PROTOCOL_ERROR))
866 || sas_status) && (try_count < 5));
868 if (rc == 0 && !ioc_status && !sas_status) {
869 mps_dprint(sc, MPS_MAPPING, "%s: got SATA identify "
870 "successfully for handle = 0x%x with try_count = %d\n",
871 __func__, handle, try_count);
873 mps_dprint(sc, MPS_MAPPING, "%s: handle = 0x%x failed\n",
877 /* Copy & byteswap the 40 byte model number to a buffer */
878 for (i = 0; i < MPT2SAS_MN_LEN; i += 2) {
879 buffer[i] = ((u8 *)ata_identify.model_number)[i + 1];
880 buffer[i + 1] = ((u8 *)ata_identify.model_number)[i];
882 /* Copy & byteswap the 20 byte serial number to a buffer */
883 for (i = 0; i < MPT2SAS_SN_LEN; i += 2) {
884 buffer[MPT2SAS_MN_LEN + i] =
885 ((u8 *)ata_identify.serial_number)[i + 1];
886 buffer[MPT2SAS_MN_LEN + i + 1] =
887 ((u8 *)ata_identify.serial_number)[i];
889 bufferptr = (u32 *)buffer;
890 /* There are 60 bytes to hash down to 8. 60 isn't divisible by 8,
891 * so loop through the first 56 bytes (7*8),
892 * and then add in the last dword.
894 hash_address.word.low = 0;
895 hash_address.word.high = 0;
896 for (i = 0; (i < ((MPT2SAS_MN_LEN+MPT2SAS_SN_LEN)/8)); i++) {
897 hash_address.word.low += *bufferptr;
899 hash_address.word.high += *bufferptr;
902 /* Add the last dword */
903 hash_address.word.low += *bufferptr;
904 /* Make sure the hash doesn't start with 5, because it could clash
905 * with a SAS address. Change 5 to a D.
907 if ((hash_address.word.high & 0x000000F0) == (0x00000050))
908 hash_address.word.high |= 0x00000080;
909 *sas_address = (u64)hash_address.wwid[0] << 56 |
910 (u64)hash_address.wwid[1] << 48 | (u64)hash_address.wwid[2] << 40 |
911 (u64)hash_address.wwid[3] << 32 | (u64)hash_address.wwid[4] << 24 |
912 (u64)hash_address.wwid[5] << 16 | (u64)hash_address.wwid[6] << 8 |
913 (u64)hash_address.wwid[7];
914 if (ata_identify.rotational_speed == 1) {
922 mpssas_get_sata_identify(struct mps_softc *sc, u16 handle,
923 Mpi2SataPassthroughReply_t *mpi_reply, char *id_buffer, int sz, u32 devinfo)
925 Mpi2SataPassthroughRequest_t *mpi_request;
926 Mpi2SataPassthroughReply_t *reply = NULL;
927 struct mps_command *cm;
931 buffer = malloc( sz, M_MPT2, M_NOWAIT | M_ZERO);
935 if ((cm = mps_alloc_command(sc)) == NULL) {
936 free(buffer, M_MPT2);
939 mpi_request = (MPI2_SATA_PASSTHROUGH_REQUEST *)cm->cm_req;
940 bzero(mpi_request,sizeof(MPI2_SATA_PASSTHROUGH_REQUEST));
941 mpi_request->Function = MPI2_FUNCTION_SATA_PASSTHROUGH;
942 mpi_request->VF_ID = 0;
943 mpi_request->DevHandle = htole16(handle);
944 mpi_request->PassthroughFlags = (MPI2_SATA_PT_REQ_PT_FLAGS_PIO |
945 MPI2_SATA_PT_REQ_PT_FLAGS_READ);
946 mpi_request->DataLength = htole32(sz);
947 mpi_request->CommandFIS[0] = 0x27;
948 mpi_request->CommandFIS[1] = 0x80;
949 mpi_request->CommandFIS[2] = (devinfo &
950 MPI2_SAS_DEVICE_INFO_ATAPI_DEVICE) ? 0xA1 : 0xEC;
951 cm->cm_sge = &mpi_request->SGL;
952 cm->cm_sglsize = sizeof(MPI2_SGE_IO_UNION);
953 cm->cm_flags = MPS_CM_FLAGS_SGE_SIMPLE | MPS_CM_FLAGS_DATAIN;
954 cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
955 cm->cm_data = buffer;
956 cm->cm_length = htole32(sz);
959 * Start a timeout counter specifically for the SATA ID command. This
960 * is used to fix a problem where the FW does not send a reply sometimes
961 * when a bad disk is in the topology. So, this is used to timeout the
962 * command so that processing can continue normally.
964 mps_dprint(sc, MPS_XINFO, "%s start timeout counter for SATA ID "
965 "command\n", __func__);
966 callout_reset(&cm->cm_callout, MPS_ATA_ID_TIMEOUT * hz,
967 mpssas_ata_id_timeout, cm);
968 error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
969 mps_dprint(sc, MPS_XINFO, "%s stop timeout counter for SATA ID "
970 "command\n", __func__);
971 /* XXX KDM need to fix the case where this command is destroyed */
972 callout_stop(&cm->cm_callout);
975 reply = (Mpi2SataPassthroughReply_t *)cm->cm_reply;
976 if (error || (reply == NULL)) {
979 * If the request returns an error then we need to do a diag
982 mps_dprint(sc, MPS_INFO|MPS_FAULT|MPS_MAPPING,
983 "Request for SATA PASSTHROUGH page completed with error %d",
988 bcopy(buffer, id_buffer, sz);
989 bcopy(reply, mpi_reply, sizeof(Mpi2SataPassthroughReply_t));
990 if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) !=
991 MPI2_IOCSTATUS_SUCCESS) {
992 mps_dprint(sc, MPS_INFO|MPS_MAPPING|MPS_FAULT,
993 "Error reading device %#x SATA PASSTHRU; iocstatus= 0x%x\n",
994 handle, reply->IOCStatus);
1000 * If the SATA_ID_TIMEOUT flag has been set for this command, don't free
1001 * it. The command will be freed after sending a target reset TM. If
1002 * the command did timeout, use EWOULDBLOCK.
1005 && (cm->cm_flags & MPS_CM_FLAGS_SATA_ID_TIMEOUT) == 0)
1006 mps_free_command(sc, cm);
1007 else if (error == 0)
1008 error = EWOULDBLOCK;
1009 free(buffer, M_MPT2);
1014 mpssas_ata_id_timeout(void *data)
1016 struct mps_softc *sc;
1017 struct mps_command *cm;
1019 cm = (struct mps_command *)data;
1021 mtx_assert(&sc->mps_mtx, MA_OWNED);
1023 mps_dprint(sc, MPS_INFO, "%s checking ATA ID command %p sc %p\n",
1025 if ((callout_pending(&cm->cm_callout)) ||
1026 (!callout_active(&cm->cm_callout))) {
1027 mps_dprint(sc, MPS_INFO, "%s ATA ID command almost timed out\n",
1031 callout_deactivate(&cm->cm_callout);
1034 * Run the interrupt handler to make sure it's not pending. This
1035 * isn't perfect because the command could have already completed
1036 * and been re-used, though this is unlikely.
1038 mps_intr_locked(sc);
1039 if (cm->cm_state == MPS_CM_STATE_FREE) {
1040 mps_dprint(sc, MPS_INFO, "%s ATA ID command almost timed out\n",
1045 mps_dprint(sc, MPS_INFO, "ATA ID command timeout cm %p\n", cm);
1048 * Send wakeup() to the sleeping thread that issued this ATA ID command.
1049 * wakeup() will cause msleep to return a 0 (not EWOULDBLOCK), and this
1050 * will keep reinit() from being called. This way, an Abort Task TM can
1051 * be issued so that the timed out command can be cleared. The Abort
1052 * Task cannot be sent from here because the driver has not completed
1053 * setting up targets. Instead, the command is flagged so that special
1054 * handling will be used to send the abort.
1056 cm->cm_flags |= MPS_CM_FLAGS_SATA_ID_TIMEOUT;
1061 mpssas_volume_add(struct mps_softc *sc, u16 handle)
1063 struct mpssas_softc *sassc;
1064 struct mpssas_target *targ;
1068 struct mpssas_lun *lun;
1071 mpssas_startup_increment(sassc);
1072 /* wwid is endian safe */
1073 mps_config_get_volume_wwid(sc, handle, &wwid);
1075 printf("%s: invalid WWID; cannot add volume to mapping table\n",
1081 id = mps_mapping_get_raid_tid(sc, wwid, handle);
1082 if (id == MPS_MAP_BAD_ID) {
1083 printf("%s: could not get ID for volume with handle 0x%04x and "
1084 "WWID 0x%016llx\n", __func__, handle,
1085 (unsigned long long)wwid);
1090 targ = &sassc->targets[id];
1092 targ->handle = handle;
1093 targ->devname = wwid;
1094 TAILQ_INIT(&targ->commands);
1095 TAILQ_INIT(&targ->timedout_commands);
1096 while(!SLIST_EMPTY(&targ->luns)) {
1097 lun = SLIST_FIRST(&targ->luns);
1098 SLIST_REMOVE_HEAD(&targ->luns, lun_link);
1101 SLIST_INIT(&targ->luns);
1102 #if __FreeBSD_version < 1000039
1103 if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
1105 mpssas_rescan_target(sc, targ);
1106 mps_dprint(sc, MPS_MAPPING, "RAID target id %d added (WWID = 0x%jx)\n",
1109 mpssas_startup_decrement(sassc);
1114 * mpssas_SSU_to_SATA_devices
1115 * @sc: per adapter object
1117 * Looks through the target list and issues a StartStopUnit SCSI command to each
1118 * SATA direct-access device. This helps to ensure that data corruption is
1119 * avoided when the system is being shut down. This must be called after the IR
1120 * System Shutdown RAID Action is sent if in IR mode.
1125 mpssas_SSU_to_SATA_devices(struct mps_softc *sc)
1127 struct mpssas_softc *sassc = sc->sassc;
1129 path_id_t pathid = cam_sim_path(sassc->sim);
1130 target_id_t targetid;
1131 struct mpssas_target *target;
1133 struct timeval cur_time, start_time;
1136 * For each target, issue a StartStopUnit command to stop the device.
1138 sc->SSU_started = TRUE;
1139 sc->SSU_refcount = 0;
1140 for (targetid = 0; targetid < sc->max_devices; targetid++) {
1141 target = &sassc->targets[targetid];
1142 if (target->handle == 0x0) {
1146 ccb = xpt_alloc_ccb_nowait();
1148 mps_dprint(sc, MPS_FAULT, "Unable to alloc CCB to stop "
1154 * The stop_at_shutdown flag will be set if this device is
1155 * a SATA direct-access end device.
1157 if (target->stop_at_shutdown) {
1158 if (xpt_create_path(&ccb->ccb_h.path,
1159 xpt_periph, pathid, targetid,
1160 CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
1161 mps_dprint(sc, MPS_FAULT, "Unable to create "
1162 "LUN path to stop unit.\n");
1166 xpt_path_string(ccb->ccb_h.path, path_str,
1169 mps_dprint(sc, MPS_INFO, "Sending StopUnit: path %s "
1170 "handle %d\n", path_str, target->handle);
1173 * Issue a START STOP UNIT command for the target.
1174 * Increment the SSU counter to be used to count the
1175 * number of required replies.
1177 mps_dprint(sc, MPS_INFO, "Incrementing SSU count\n");
1179 ccb->ccb_h.target_id =
1180 xpt_path_target_id(ccb->ccb_h.path);
1181 ccb->ccb_h.ppriv_ptr1 = sassc;
1182 scsi_start_stop(&ccb->csio,
1184 mpssas_stop_unit_done,
1196 * Wait until all of the SSU commands have completed or time has
1197 * expired (60 seconds). Pause for 100ms each time through. If any
1198 * command times out, the target will be reset in the SCSI command
1201 getmicrotime(&start_time);
1202 while (sc->SSU_refcount) {
1203 pause("mpswait", hz/10);
1205 getmicrotime(&cur_time);
1206 if ((cur_time.tv_sec - start_time.tv_sec) > 60) {
1207 mps_dprint(sc, MPS_FAULT, "Time has expired waiting "
1208 "for SSU commands to complete.\n");
1215 mpssas_stop_unit_done(struct cam_periph *periph, union ccb *done_ccb)
1217 struct mpssas_softc *sassc;
1220 if (done_ccb == NULL)
1223 sassc = (struct mpssas_softc *)done_ccb->ccb_h.ppriv_ptr1;
1225 xpt_path_string(done_ccb->ccb_h.path, path_str, sizeof(path_str));
1226 mps_dprint(sassc->sc, MPS_INFO, "Completing stop unit for %s\n",
1230 * Nothing more to do except free the CCB and path. If the command
1231 * timed out, an abort reset, then target reset will be issued during
1232 * the SCSI Command process.
1234 xpt_free_path(done_ccb->ccb_h.path);
1235 xpt_free_ccb(done_ccb);
1239 * mpssas_ir_shutdown - IR shutdown notification
1240 * @sc: per adapter object
1242 * Sending RAID Action to alert the Integrated RAID subsystem of the IOC that
1243 * the host system is shutting down.
1248 mpssas_ir_shutdown(struct mps_softc *sc)
1250 u16 volume_mapping_flags;
1251 u16 ioc_pg8_flags = le16toh(sc->ioc_pg8.Flags);
1252 struct dev_mapping_table *mt_entry;
1253 u32 start_idx, end_idx;
1254 unsigned int id, found_volume = 0;
1255 struct mps_command *cm;
1256 Mpi2RaidActionRequest_t *action;
1257 target_id_t targetid;
1258 struct mpssas_target *target;
1260 mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
1262 /* is IR firmware build loaded? */
1263 if (!sc->ir_firmware)
1266 /* are there any volumes? Look at IR target IDs. */
1267 // TODO-later, this should be looked up in the RAID config structure
1268 // when it is implemented.
1269 volume_mapping_flags = le16toh(sc->ioc_pg8.IRVolumeMappingFlags) &
1270 MPI2_IOCPAGE8_IRFLAGS_MASK_VOLUME_MAPPING_MODE;
1271 if (volume_mapping_flags == MPI2_IOCPAGE8_IRFLAGS_LOW_VOLUME_MAPPING) {
1273 if (ioc_pg8_flags & MPI2_IOCPAGE8_FLAGS_RESERVED_TARGETID_0)
1276 start_idx = sc->max_devices - sc->max_volumes;
1277 end_idx = start_idx + sc->max_volumes - 1;
1279 for (id = start_idx; id < end_idx; id++) {
1280 mt_entry = &sc->mapping_table[id];
1281 if ((mt_entry->physical_id != 0) &&
1282 (mt_entry->missing_count == 0)) {
1291 if ((cm = mps_alloc_command(sc)) == NULL) {
1292 printf("%s: command alloc failed\n", __func__);
1296 action = (MPI2_RAID_ACTION_REQUEST *)cm->cm_req;
1297 action->Function = MPI2_FUNCTION_RAID_ACTION;
1298 action->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED;
1299 cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
1301 mps_wait_command(sc, &cm, 5, CAN_SLEEP);
1305 * Don't check for reply, just leave.
1308 mps_free_command(sc, cm);
1312 * All of the targets must have the correct value set for
1313 * 'stop_at_shutdown' for the current 'enable_ssu' sysctl variable.
1315 * The possible values for the 'enable_ssu' variable are:
1316 * 0: disable to SSD and HDD
1317 * 1: disable only to HDD (default)
1318 * 2: disable only to SSD
1319 * 3: enable to SSD and HDD
1320 * anything else will default to 1.
1322 for (targetid = 0; targetid < sc->max_devices; targetid++) {
1323 target = &sc->sassc->targets[targetid];
1324 if (target->handle == 0x0) {
1328 if (target->supports_SSU) {
1329 switch (sc->enable_ssu) {
1330 case MPS_SSU_DISABLE_SSD_DISABLE_HDD:
1331 target->stop_at_shutdown = FALSE;
1333 case MPS_SSU_DISABLE_SSD_ENABLE_HDD:
1334 target->stop_at_shutdown = TRUE;
1335 if (target->flags & MPS_TARGET_IS_SATA_SSD) {
1336 target->stop_at_shutdown = FALSE;
1339 case MPS_SSU_ENABLE_SSD_ENABLE_HDD:
1340 target->stop_at_shutdown = TRUE;
1342 case MPS_SSU_ENABLE_SSD_DISABLE_HDD:
1344 target->stop_at_shutdown = TRUE;
1345 if ((target->flags &
1346 MPS_TARGET_IS_SATA_SSD) == 0) {
1347 target->stop_at_shutdown = FALSE;
1353 mpssas_SSU_to_SATA_devices(sc);