コード例 #1
0
ファイル: mps_sas_lsi.c プロジェクト: coyizumi/cs111
static int
mpssas_volume_add(struct mps_softc *sc, u16 handle)
{
	struct mpssas_softc *sassc;
	struct mpssas_target *targ;
	u64 wwid;
	unsigned int id;
	int error = 0;
	struct mpssas_lun *lun;

	sassc = sc->sassc;
	mpssas_startup_increment(sassc);
	/* wwid is endian safe */
	mps_config_get_volume_wwid(sc, handle, &wwid);
	if (!wwid) {
		printf("%s: invalid WWID; cannot add volume to mapping table\n",
		    __func__);
		error = ENXIO;
		goto out;
	}

	id = mps_mapping_get_raid_id(sc, wwid, handle);
	if (id == MPS_MAP_BAD_ID) {
		printf("%s: could not get ID for volume with handle 0x%04x and "
		    "WWID 0x%016llx\n", __func__, handle,
		    (unsigned long long)wwid);
		error = ENXIO;
		goto out;
	}

	targ = &sassc->targets[id];
	targ->tid = id;
	targ->handle = handle;
	targ->devname = wwid;
	TAILQ_INIT(&targ->commands);
	TAILQ_INIT(&targ->timedout_commands);
	while(!SLIST_EMPTY(&targ->luns)) {
		lun = SLIST_FIRST(&targ->luns);
		SLIST_REMOVE_HEAD(&targ->luns, lun_link);
		free(lun, M_MPT2);
	}
	SLIST_INIT(&targ->luns);
#if __FreeBSD_version < 1000039
	if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
#endif
		mpssas_rescan_target(sc, targ);
	mps_dprint(sc, MPS_MAPPING, "RAID target id %d added (WWID = 0x%jx)\n",
	    targ->tid, wwid);
out:
	mpssas_startup_decrement(sassc);
	return (error);
}
コード例 #2
0
static int
mpssas_volume_add(struct mps_softc *sc, Mpi2EventIrConfigElement_t *element)
{
	struct mpssas_softc *sassc;
	struct mpssas_target *targ;
	u64 wwid;
	u16 handle = le16toh(element->VolDevHandle);
	unsigned int id;
	int error = 0;

	sassc = sc->sassc;
	mpssas_startup_increment(sassc);
	mps_config_get_volume_wwid(sc, handle, &wwid);
	if (!wwid) {
		kprintf("%s: invalid WWID; cannot add volume to mapping table\n",
		    __func__);
		error = ENXIO;
		goto out;
	}

	id = mps_mapping_get_raid_id(sc, wwid, handle);
	if (id == MPS_MAP_BAD_ID) {
		kprintf("%s: could not get ID for volume with handle 0x%04x and "
		    "WWID 0x%016llx\n", __func__, handle,
		    (unsigned long long)wwid);
		error = ENXIO;
		goto out;
	}

	targ = &sassc->targets[id];
	targ->tid = id;
	targ->handle = handle;
	targ->devname = wwid;
	TAILQ_INIT(&targ->commands);
	TAILQ_INIT(&targ->timedout_commands);
	SLIST_INIT(&targ->luns);
	if ((sassc->flags & MPSSAS_IN_STARTUP) == 0)
		mpssas_rescan_target(sc, targ);
	mps_dprint(sc, MPS_INFO, "RAID target id %d added (WWID = 0x%jx)\n",
	    targ->tid, wwid);
out:
	mpssas_startup_decrement(sassc);
	return (error);
}