FreeBSD/sys/dev/mps/mps_sas_lsi.c
/**
 * mpssas_ir_shutdown - IR shutdown notification
 * @sc: per adapter object
 *
 * Sending RAID Action to alert the Integrated RAID subsystem of the IOC that
 * the host system is shutting down.
 *
 * Return nothing.
 */
IR shutdown notification
@sc: per adapter object

Sending RAID Action to alert the Integrated RAID subsystem of the IOC that
the host system is shutting down.

Return nothing.
IR shutdown notification @sc : per adapter object Sending RAID Action to alert the Integrated RAID subsystem of the IOC that the host system is shutting down . Return nothing .
void
mpssas_ir_shutdown(struct mps_softc *sc)
{
	u16 volume_mapping_flags;
	u16 ioc_pg8_flags = le16toh(sc->ioc_pg8.Flags);
	struct dev_mapping_table *mt_entry;
	u32 start_idx, end_idx;
	unsigned int id, found_volume = 0;
	struct mps_command *cm;
	Mpi2RaidActionRequest_t	*action;
	target_id_t targetid;
	struct mpssas_target *target;
	mps_dprint(sc, MPS_TRACE, "%s\n", __func__);
	if (!sc->ir_firmware)
		goto out;
	volume_mapping_flags = le16toh(sc->ioc_pg8.IRVolumeMappingFlags) &
	    MPI2_IOCPAGE8_IRFLAGS_MASK_VOLUME_MAPPING_MODE;
	if (volume_mapping_flags == MPI2_IOCPAGE8_IRFLAGS_LOW_VOLUME_MAPPING) {
		start_idx = 0;
		if (ioc_pg8_flags & MPI2_IOCPAGE8_FLAGS_RESERVED_TARGETID_0)
			start_idx = 1;
	} else
		start_idx = sc->max_devices - sc->max_volumes;
	end_idx = start_idx + sc->max_volumes - 1;
	for (id = start_idx; id < end_idx; id++) {
		mt_entry = &sc->mapping_table[id];
		if ((mt_entry->physical_id != 0) &&
		    (mt_entry->missing_count == 0)) {
			found_volume = 1;
			break;
		}
	}
	if (!found_volume)
		goto out;
	if ((cm = mps_alloc_command(sc)) == NULL) {
		printf("%s: command alloc failed\n", __func__);
		goto out;
	}
	action = (MPI2_RAID_ACTION_REQUEST *)cm->cm_req;
	action->Function = MPI2_FUNCTION_RAID_ACTION;
	action->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED;
	cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
	mps_lock(sc);
	mps_wait_command(sc, cm, 5, CAN_SLEEP);
	mps_unlock(sc);
	if (cm)
		mps_free_command(sc, cm);
out:
	for (targetid = 0; targetid < sc->facts->MaxTargets; targetid++) {
		target = &sc->sassc->targets[targetid];
		if (target->handle == 0x0) {
			continue;
		}
		if (target->supports_SSU) {
			switch (sc->enable_ssu) {
			case MPS_SSU_DISABLE_SSD_DISABLE_HDD:
				target->stop_at_shutdown = FALSE;
				break;
			case MPS_SSU_DISABLE_SSD_ENABLE_HDD:
				target->stop_at_shutdown = TRUE;
				if (target->flags & MPS_TARGET_IS_SATA_SSD) {
					target->stop_at_shutdown = FALSE;
				}
				break;
			case MPS_SSU_ENABLE_SSD_ENABLE_HDD:
				target->stop_at_shutdown = TRUE;
				break;
			case MPS_SSU_ENABLE_SSD_DISABLE_HDD:
			default:
				target->stop_at_shutdown = TRUE;
				if ((target->flags &
				    MPS_TARGET_IS_SATA_SSD) == 0) {
					target->stop_at_shutdown = FALSE;
				}
				break;
			}
		}
	}
	mpssas_SSU_to_SATA_devices(sc);
}
void mpssas_ir_shutdown ( struct mps_softc * sc ) { u16 volume_mapping_flags ; u16 ioc_pg8_flags = le16toh ( sc -> ioc_pg8 . Flags ) ; struct dev_mapping_table * mt_entry ; u32 start_idx , end_idx ; unsigned int id , found_volume = 0 ; struct mps_command * cm ; Mpi2RaidActionRequest_t * action ; target_id_t targetid ; struct mpssas_target * target ; mps_dprint ( sc , MPS_TRACE , " \n " , __func__ ) ; if ( ! sc -> ir_firmware ) goto out ; volume_mapping_flags = le16toh ( sc -> ioc_pg8 . IRVolumeMappingFlags ) & MPI2_IOCPAGE8_IRFLAGS_MASK_VOLUME_MAPPING_MODE ; if ( volume_mapping_flags == MPI2_IOCPAGE8_IRFLAGS_LOW_VOLUME_MAPPING ) { start_idx = 0 ; if ( ioc_pg8_flags & MPI2_IOCPAGE8_FLAGS_RESERVED_TARGETID_0 ) start_idx = 1 ; } else start_idx = sc -> max_devices - sc -> max_volumes ; end_idx = start_idx + sc -> max_volumes - 1 ; for ( id = start_idx ; id < end_idx ; id ++ ) { mt_entry = & sc -> mapping_table [ id ] ; if ( ( mt_entry -> physical_id != 0 ) && ( mt_entry -> missing_count == 0 ) ) { found_volume = 1 ; break ; } } if ( ! found_volume ) goto out ; if ( ( cm = mps_alloc_command ( sc ) ) == NULL ) { printf ( " \n " , __func__ ) ; goto out ; } action = ( MPI2_RAID_ACTION_REQUEST * ) cm -> cm_req ; action -> Function = MPI2_FUNCTION_RAID_ACTION ; action -> Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED ; cm -> cm_desc . Default . RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE ; mps_lock ( sc ) ; mps_wait_command ( sc , cm , 5 , CAN_SLEEP ) ; mps_unlock ( sc ) ; if ( cm ) mps_free_command ( sc , cm ) ; out : for ( targetid = 0 ; targetid < sc -> facts -> MaxTargets ; targetid ++ ) { target = & sc -> sassc -> targets [ targetid ] ; if ( target -> handle == 0x0 ) { continue ; } if ( target -> supports_SSU ) { switch ( sc -> enable_ssu ) { case MPS_SSU_DISABLE_SSD_DISABLE_HDD : target -> stop_at_shutdown = FALSE ; break ; case MPS_SSU_DISABLE_SSD_ENABLE_HDD : target -> stop_at_shutdown = TRUE ; if ( target -> flags & MPS_TARGET_IS_SATA_SSD ) { target -> stop_at_shutdown = FALSE ; } break ; case MPS_SSU_ENABLE_SSD_ENABLE_HDD : target -> stop_at_shutdown = TRUE ; break ; case MPS_SSU_ENABLE_SSD_DISABLE_HDD : default : target -> stop_at_shutdown = TRUE ; if ( ( target -> flags & MPS_TARGET_IS_SATA_SSD ) == 0 ) { target -> stop_at_shutdown = FALSE ; } break ; } } } mpssas_SSU_to_SATA_devices ( sc ) ; }
mpssas_ir_shutdown - IR shutdown notification
 @sc: per adapter object
mpssas_ir_shutdown - IR shutdown notification @sc : per adapter object
/* is IR firmware build loaded? */ /* are there any volumes?  Look at IR target IDs. */ // TODO-later, this should be looked up in the RAID config structure // when it is implemented. /*
	 * Don't check for reply, just leave.
	 */ /*
	 * All of the targets must have the correct value set for
	 * 'stop_at_shutdown' for the current 'enable_ssu' sysctl variable.
	 *
	 * The possible values for the 'enable_ssu' variable are:
	 * 0: disable to SSD and HDD
	 * 1: disable only to HDD (default)
	 * 2: disable only to SSD
	 * 3: enable to SSD and HDD
	 * anything else will default to 1.
	 */