FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_aen_handler:	AEN processing callback function from thread context
 * input:				Adapter soft state
 *
 * Asynchronous event handler
 */
AEN processing callback function from thread context
input:                               Adapter soft state

Asynchronous event handler
AEN processing callback function from thread context input : Adapter soft state Asynchronous event handler
void
mrsas_aen_handler(struct mrsas_softc *sc)
{
	union mrsas_evt_class_locale class_locale;
	int doscan = 0;
	u_int32_t seq_num;
 	int error, fail_aen = 0;
	if (sc == NULL) {
		printf("invalid instance!\n");
		return;
	}
	if (sc->evt_detail_mem) {
		switch (sc->evt_detail_mem->code) {
		case MR_EVT_PD_INSERTED:
			fail_aen = mrsas_get_pd_list(sc);
			if (!fail_aen)
				mrsas_bus_scan_sim(sc, sc->sim_1);
			else
				goto skip_register_aen;
			doscan = 0;
			break;
		case MR_EVT_PD_REMOVED:
			fail_aen = mrsas_get_pd_list(sc);
			if (!fail_aen)
				mrsas_bus_scan_sim(sc, sc->sim_1);
			else
				goto skip_register_aen;
			doscan = 0;
			break;
		case MR_EVT_LD_OFFLINE:
		case MR_EVT_CFG_CLEARED:
		case MR_EVT_LD_DELETED:
			mrsas_bus_scan_sim(sc, sc->sim_0);
			doscan = 0;
			break;
		case MR_EVT_LD_CREATED:
			fail_aen = mrsas_get_ld_list(sc);
			if (!fail_aen)
				mrsas_bus_scan_sim(sc, sc->sim_0);
			else
				goto skip_register_aen;
			doscan = 0;
			break;
		case MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED:
		case MR_EVT_FOREIGN_CFG_IMPORTED:
		case MR_EVT_LD_STATE_CHANGE:
			doscan = 1;
			break;
		default:
			doscan = 0;
			break;
		}
	} else {
		device_printf(sc->mrsas_dev, "invalid evt_detail\n");
		return;
	}
	if (doscan) {
		fail_aen = mrsas_get_pd_list(sc);
		if (!fail_aen) {
			mrsas_dprint(sc, MRSAS_AEN, "scanning ...sim 1\n");
			mrsas_bus_scan_sim(sc, sc->sim_1);
		} else
			goto skip_register_aen;
		fail_aen = mrsas_get_ld_list(sc);
		if (!fail_aen) {
			mrsas_dprint(sc, MRSAS_AEN, "scanning ...sim 0\n");
			mrsas_bus_scan_sim(sc, sc->sim_0);
		} else
			goto skip_register_aen;
	}
	seq_num = sc->evt_detail_mem->seq_num + 1;
	class_locale.members.reserved = 0;
	class_locale.members.locale = MR_EVT_LOCALE_ALL;
	class_locale.members.class = MR_EVT_CLASS_DEBUG;
	if (sc->aen_cmd != NULL)
		return;
	mtx_lock(&sc->aen_lock);
	error = mrsas_register_aen(sc, seq_num,
	    class_locale.word);
	mtx_unlock(&sc->aen_lock);
	if (error)
		device_printf(sc->mrsas_dev, "register aen failed error %x\n", error);
skip_register_aen:
	return;
}
void mrsas_aen_handler ( struct mrsas_softc * sc ) { union mrsas_evt_class_locale class_locale ; int doscan = 0 ; u_int32_t seq_num ; int error , fail_aen = 0 ; if ( sc == NULL ) { printf ( " \n " ) ; return ; } if ( sc -> evt_detail_mem ) { switch ( sc -> evt_detail_mem -> code ) { case MR_EVT_PD_INSERTED : fail_aen = mrsas_get_pd_list ( sc ) ; if ( ! fail_aen ) mrsas_bus_scan_sim ( sc , sc -> sim_1 ) ; else goto skip_register_aen ; doscan = 0 ; break ; case MR_EVT_PD_REMOVED : fail_aen = mrsas_get_pd_list ( sc ) ; if ( ! fail_aen ) mrsas_bus_scan_sim ( sc , sc -> sim_1 ) ; else goto skip_register_aen ; doscan = 0 ; break ; case MR_EVT_LD_OFFLINE : case MR_EVT_CFG_CLEARED : case MR_EVT_LD_DELETED : mrsas_bus_scan_sim ( sc , sc -> sim_0 ) ; doscan = 0 ; break ; case MR_EVT_LD_CREATED : fail_aen = mrsas_get_ld_list ( sc ) ; if ( ! fail_aen ) mrsas_bus_scan_sim ( sc , sc -> sim_0 ) ; else goto skip_register_aen ; doscan = 0 ; break ; case MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED : case MR_EVT_FOREIGN_CFG_IMPORTED : case MR_EVT_LD_STATE_CHANGE : doscan = 1 ; break ; default : doscan = 0 ; break ; } } else { device_printf ( sc -> mrsas_dev , " \n " ) ; return ; } if ( doscan ) { fail_aen = mrsas_get_pd_list ( sc ) ; if ( ! fail_aen ) { mrsas_dprint ( sc , MRSAS_AEN , " \n " ) ; mrsas_bus_scan_sim ( sc , sc -> sim_1 ) ; } else goto skip_register_aen ; fail_aen = mrsas_get_ld_list ( sc ) ; if ( ! fail_aen ) { mrsas_dprint ( sc , MRSAS_AEN , " \n " ) ; mrsas_bus_scan_sim ( sc , sc -> sim_0 ) ; } else goto skip_register_aen ; } seq_num = sc -> evt_detail_mem -> seq_num + 1 ; class_locale . members . reserved = 0 ; class_locale . members . locale = MR_EVT_LOCALE_ALL ; class_locale . members . class = MR_EVT_CLASS_DEBUG ; if ( sc -> aen_cmd != NULL ) return ; mtx_lock ( & sc -> aen_lock ) ; error = mrsas_register_aen ( sc , seq_num , class_locale . word ) ; mtx_unlock ( & sc -> aen_lock ) ; if ( error ) device_printf ( sc -> mrsas_dev , " \n " , error ) ; skip_register_aen : return ; }
mrsas_aen_handler:   AEN processing callback function from thread context
 input:                               Adapter soft state
mrsas_aen_handler : AEN processing callback function from thread context input : Adapter soft state
/* Register AEN with FW for latest sequence number plus 1 */