FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_setup_sysctl:	setup sysctl values for mrsas
 * input:				Adapter instance soft state
 *
 * Setup sysctl entries for mrsas driver.
 */
setup sysctl values for mrsas
input:                               Adapter instance soft state

Setup sysctl entries for mrsas driver.
setup sysctl values for mrsas input : Adapter instance soft state Setup sysctl entries for mrsas driver .
static void
mrsas_setup_sysctl(struct mrsas_softc *sc)
{
	struct sysctl_ctx_list *sysctl_ctx = NULL;
	struct sysctl_oid *sysctl_tree = NULL;
	char tmpstr[80], tmpstr2[80];
	snprintf(tmpstr, sizeof(tmpstr), "MRSAS controller %d",
	    device_get_unit(sc->mrsas_dev));
	snprintf(tmpstr2, sizeof(tmpstr2), "%d", device_get_unit(sc->mrsas_dev));
	sysctl_ctx = device_get_sysctl_ctx(sc->mrsas_dev);
	if (sysctl_ctx != NULL)
		sysctl_tree = device_get_sysctl_tree(sc->mrsas_dev);
	if (sysctl_tree == NULL) {
		sysctl_ctx_init(&sc->sysctl_ctx);
		sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
		    SYSCTL_STATIC_CHILDREN(_hw_mrsas), OID_AUTO, tmpstr2,
		    CTLFLAG_RD, 0, tmpstr);
		if (sc->sysctl_tree == NULL)
			return;
		sysctl_ctx = &sc->sysctl_ctx;
		sysctl_tree = sc->sysctl_tree;
	}
	SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "disable_ocr", CTLFLAG_RW, &sc->disableOnlineCtrlReset, 0,
	    "Disable the use of OCR");
	SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "driver_version", CTLFLAG_RD, MRSAS_VERSION,
	    strlen(MRSAS_VERSION), "driver version");
	SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "reset_count", CTLFLAG_RD,
	    &sc->reset_count, 0, "number of ocr from start of the day");
	SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "fw_outstanding", CTLFLAG_RD,
	    &sc->fw_outstanding.val_rdonly, 0, "FW outstanding commands");
	SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "io_cmds_highwater", CTLFLAG_RD,
	    &sc->io_cmds_highwater, 0, "Max FW outstanding commands");
	SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "mrsas_debug", CTLFLAG_RW, &sc->mrsas_debug, 0,
	    "Driver debug level");
	SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "mrsas_io_timeout", CTLFLAG_RW, &sc->mrsas_io_timeout,
	    0, "Driver IO timeout value in mili-second.");
	SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "mrsas_fw_fault_check_delay", CTLFLAG_RW,
	    &sc->mrsas_fw_fault_check_delay,
	    0, "FW fault check thread delay in seconds. <default is 1 sec>");
	SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
	    OID_AUTO, "reset_in_progress", CTLFLAG_RD,
	    &sc->reset_in_progress, 0, "ocr in progress status");
}
static void mrsas_setup_sysctl ( struct mrsas_softc * sc ) { struct sysctl_ctx_list * sysctl_ctx = NULL ; struct sysctl_oid * sysctl_tree = NULL ; char tmpstr [ 80 ] , tmpstr2 [ 80 ] ; snprintf ( tmpstr , sizeof ( tmpstr ) , " " , device_get_unit ( sc -> mrsas_dev ) ) ; snprintf ( tmpstr2 , sizeof ( tmpstr2 ) , " " , device_get_unit ( sc -> mrsas_dev ) ) ; sysctl_ctx = device_get_sysctl_ctx ( sc -> mrsas_dev ) ; if ( sysctl_ctx != NULL ) sysctl_tree = device_get_sysctl_tree ( sc -> mrsas_dev ) ; if ( sysctl_tree == NULL ) { sysctl_ctx_init ( & sc -> sysctl_ctx ) ; sc -> sysctl_tree = SYSCTL_ADD_NODE ( & sc -> sysctl_ctx , SYSCTL_STATIC_CHILDREN ( _hw_mrsas ) , OID_AUTO , tmpstr2 , CTLFLAG_RD , 0 , tmpstr ) ; if ( sc -> sysctl_tree == NULL ) return ; sysctl_ctx = & sc -> sysctl_ctx ; sysctl_tree = sc -> sysctl_tree ; } SYSCTL_ADD_UINT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RW , & sc -> disableOnlineCtrlReset , 0 , " " ) ; SYSCTL_ADD_STRING ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RD , MRSAS_VERSION , strlen ( MRSAS_VERSION ) , " " ) ; SYSCTL_ADD_INT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RD , & sc -> reset_count , 0 , " " ) ; SYSCTL_ADD_INT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RD , & sc -> fw_outstanding . val_rdonly , 0 , " " ) ; SYSCTL_ADD_INT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RD , & sc -> io_cmds_highwater , 0 , " " ) ; SYSCTL_ADD_UINT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RW , & sc -> mrsas_debug , 0 , " " ) ; SYSCTL_ADD_UINT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RW , & sc -> mrsas_io_timeout , 0 , " " ) ; SYSCTL_ADD_UINT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RW , & sc -> mrsas_fw_fault_check_delay , 0 , " " ) ; SYSCTL_ADD_INT ( sysctl_ctx , SYSCTL_CHILDREN ( sysctl_tree ) , OID_AUTO , " " , CTLFLAG_RD , & sc -> reset_in_progress , 0 , " " ) ; }
mrsas_setup_sysctl:  setup sysctl values for mrsas
 input:                               Adapter instance soft state
mrsas_setup_sysctl : setup sysctl values for mrsas input : Adapter instance soft state
/*
	 * Setup the sysctl variable so the user can change the debug level
	 * on the fly.
	 */