/* * Enable processor set plugin. */ int pool_pset_enable(void) { int error; nvlist_t *props; ASSERT(pool_lock_held()); ASSERT(INGLOBALZONE(curproc)); /* * Can't enable pools if there are existing cpu partitions. */ mutex_enter(&cpu_lock); if (cp_numparts > 1) { mutex_exit(&cpu_lock); return (EEXIST); } /* * We want to switch things such that everything that was tagged with * the special ALL_ZONES token now is explicitly visible to all zones: * first add individual zones to the visibility list then remove the * special "ALL_ZONES" token. There must only be the default pset * (PS_NONE) active if pools are being enabled, so we only need to * deal with it. * * We want to make pool_pset_enabled() start returning B_TRUE before * we call any of the visibility update functions. */ global_zone->zone_psetid = PS_NONE; /* * We need to explicitly handle the global zone since * zone_pset_set() won't modify it. */ pool_pset_visibility_add(PS_NONE, global_zone); /* * A NULL argument means the ALL_ZONES token. */ pool_pset_visibility_remove(PS_NONE, NULL); error = zone_walk(pool_pset_zone_pset_set, (void *)PS_NONE); ASSERT(error == 0); /* * It is safe to drop cpu_lock here. We're still * holding pool_lock so no new cpu partitions can * be created while we're here. */ mutex_exit(&cpu_lock); (void) nvlist_alloc(&pool_pset_default->pset_props, NV_UNIQUE_NAME, KM_SLEEP); props = pool_pset_default->pset_props; (void) nvlist_add_string(props, "pset.name", "pset_default"); (void) nvlist_add_string(props, "pset.comment", ""); (void) nvlist_add_int64(props, "pset.sys_id", PS_NONE); (void) nvlist_add_string(props, "pset.units", "population"); (void) nvlist_add_byte(props, "pset.default", 1); (void) nvlist_add_uint64(props, "pset.max", 65536); (void) nvlist_add_uint64(props, "pset.min", 1); pool_pset_mod = pool_cpu_mod = gethrtime(); return (0); }
/* * Create new processor set and give it a temporary name. */ int pool_pset_create(psetid_t *id) { char pset_name[40]; pool_pset_t *pset; psetid_t psetid; int err; ASSERT(pool_lock_held()); if ((err = cpupart_create(&psetid)) != 0) return (err); pset = kmem_alloc(sizeof (pool_pset_t), KM_SLEEP); pset->pset_id = *id = psetid; pset->pset_npools = 0; (void) nvlist_alloc(&pset->pset_props, NV_UNIQUE_NAME, KM_SLEEP); (void) nvlist_add_int64(pset->pset_props, "pset.sys_id", psetid); (void) nvlist_add_byte(pset->pset_props, "pset.default", 0); pool_pset_mod = gethrtime(); (void) snprintf(pset_name, sizeof (pset_name), "pset_%lld", pool_pset_mod); (void) nvlist_add_string(pset->pset_props, "pset.name", pset_name); list_insert_tail(&pool_pset_list, pset); return (0); }
/* ARGSUSED */ static int dlcosmk_info(ipp_action_id_t aid, int (*fn)(nvlist_t *, void *), void *arg, ipp_flags_t flags) { nvlist_t *nvlp; dlcosmk_data_t *dlcosmk_data; char *next_action; int err; ASSERT(fn != NULL); dlcosmk_data = (dlcosmk_data_t *)ipp_action_get_ptr(aid); ASSERT(dlcosmk_data != NULL); /* allocate nvlist to be passed back */ if ((err = nvlist_alloc(&nvlp, NV_UNIQUE_NAME, KM_NOSLEEP)) != 0) { dlcosmk0dbg(("dlcosmk_info: error allocating memory\n")); return (err); } /* look up next action with the next action id */ if ((err = ipp_action_name(dlcosmk_data->next_action, &next_action)) != 0) { dlcosmk0dbg(("dlcosmk_info: next action not available\n")); nvlist_free(nvlp); return (err); } /* add next action name */ if ((err = nvlist_add_string(nvlp, DLCOSMK_NEXT_ACTION_NAME, next_action)) != 0) { dlcosmk0dbg(("dlcosmk_info: error adding next action\n")); nvlist_free(nvlp); kmem_free(next_action, (strlen(next_action) + 1)); return (err); } /* free action name */ kmem_free(next_action, (strlen(next_action) + 1)); /* add config type */ if ((err = nvlist_add_byte(nvlp, IPP_CONFIG_TYPE, IPP_SET)) != 0) { dlcosmk0dbg(("dlcosmk_info: error adding config. type\n")); nvlist_free(nvlp); return (err); } /* just give the cos, since that is what is provided in the config */ if ((err = nvlist_add_byte(nvlp, DLCOSMK_COS, dlcosmk_data->usr_pri)) != 0) { dlcosmk0dbg(("dlcosmk_info: error adding cos\n")); nvlist_free(nvlp); return (err); } /* add gather stats boolean */ if ((err = nvlist_add_uint32(nvlp, IPP_ACTION_STATS_ENABLE, (dlcosmk_data->gather_stats ? 1 : 0))) != 0) { dlcosmk0dbg(("dlcosmk_info: error adding stats status\n")); nvlist_free(nvlp); return (err); } /* call back with nvlist */ err = fn(nvlp, arg); nvlist_free(nvlp); return (err); }
void fnvlist_add_byte(nvlist_t *nvl, const char *name, uchar_t val) { VERIFY0(nvlist_add_byte(nvl, name, val)); }
/* ARGSUSED */ static int tswtcl_info(ipp_action_id_t aid, int (*fn)(nvlist_t *, void *), void *arg, ipp_flags_t flags) { nvlist_t *nvlp; tswtcl_data_t *tswtcl_data; tswtcl_cfg_t *cfg_parms; char *next_action; int rc; tswtcl_data = (tswtcl_data_t *)ipp_action_get_ptr(aid); ASSERT(tswtcl_data != NULL); cfg_parms = tswtcl_data->cfg_parms; /* allocate nvlist to be passed back */ if ((rc = nvlist_alloc(&nvlp, NV_UNIQUE_NAME, KM_NOSLEEP)) != 0) { tswtcl0dbg(("tswtcl_info: memory allocation failure\n")); return (rc); } /* look up red next action with the next action id */ if ((rc = ipp_action_name(cfg_parms->red_action, &next_action)) != 0) { tswtcl0dbg(("tswtcl_info: red action not available\n")); nvlist_free(nvlp); return (rc); } /* add next action name */ if ((rc = nvlist_add_string(nvlp, TSWTCL_RED_ACTION_NAME, next_action)) != 0) { tswtcl0dbg(("tswtcl_info: error adding\n")); nvlist_free(nvlp); kmem_free(next_action, (strlen(next_action) + 1)); return (rc); } /* free action name */ kmem_free(next_action, (strlen(next_action) + 1)); /* look up yellow next action with the next action id */ if ((rc = ipp_action_name(cfg_parms->yellow_action, &next_action)) != 0) { tswtcl0dbg(("tswtcl_info: yellow action not available\n")); nvlist_free(nvlp); return (rc); } /* add next action name */ if ((rc = nvlist_add_string(nvlp, TSWTCL_YELLOW_ACTION_NAME, next_action)) != 0) { tswtcl0dbg(("tswtcl_info: error adding yellow action\n")); nvlist_free(nvlp); kmem_free(next_action, (strlen(next_action) + 1)); return (rc); } /* free action name */ kmem_free(next_action, (strlen(next_action) + 1)); /* look up green next action with the next action id */ if ((rc = ipp_action_name(cfg_parms->green_action, &next_action)) != 0) { tswtcl0dbg(("tswtcl_info: green action not available\n")); nvlist_free(nvlp); return (rc); } /* add next action name */ if ((rc = nvlist_add_string(nvlp, TSWTCL_GREEN_ACTION_NAME, next_action)) != 0) { tswtcl0dbg(("tswtcl_info: error adding green action\n")); nvlist_free(nvlp); kmem_free(next_action, (strlen(next_action) + 1)); return (rc); } /* free action name */ kmem_free(next_action, (strlen(next_action) + 1)); /* add config type */ if ((rc = nvlist_add_byte(nvlp, IPP_CONFIG_TYPE, IPP_SET)) != 0) { tswtcl0dbg(("tswtcl_info: error adding config_type\n")); nvlist_free(nvlp); return (rc); } /* add committed_rate */ if ((rc = nvlist_add_uint32(nvlp, TSWTCL_COMMITTED_RATE, cfg_parms->committed_rate)) != 0) { tswtcl0dbg(("tswtcl_info: error adding committed_rate\n")); nvlist_free(nvlp); return (rc); } /* add peak_rate */ if ((rc = nvlist_add_uint32(nvlp, TSWTCL_PEAK_RATE, cfg_parms->peak_rate)) != 0) { tswtcl0dbg(("tswtcl_info: error adding peak_rate\n")); nvlist_free(nvlp); return (rc); } /* add window */ if ((rc = nvlist_add_uint32(nvlp, TSWTCL_WINDOW, cfg_parms->window)) != 0) { tswtcl0dbg(("tswtcl_info: error adding window\n")); nvlist_free(nvlp); return (rc); } if ((rc = nvlist_add_uint32(nvlp, IPP_ACTION_STATS_ENABLE, (uint32_t)(uintptr_t)tswtcl_data->stats)) != 0) { tswtcl0dbg(("tswtcl_info: error adding stats status\n")); nvlist_free(nvlp); return (rc); } /* call back with nvlist */ rc = fn(nvlp, arg); nvlist_free(nvlp); return (rc); }
/* --- tapealert_sysevent - send a tapealert sysevent to n event handlers */ static int /* 0 successful */ tapealert_sysevent( char *src_fn, /* source filename */ int src_ln, /* source file line number */ dev_ent_t *un, /* device */ int flags_len, /* num valid tapealert flags */ uint64_t flags, /* tapealert flags */ uint64_t *seq_no) /* sysevent sequence number */ { int rtn = 1; time_t tm; nvlist_t *attr_list = NULL; sysevent_id_t eid; boolean_t free_attr_list = B_FALSE; char *str; *seq_no = 0; /* * build and send sysevent with active tapealert flags */ if (nvlist_alloc(&attr_list, 0, 0)) { DevLog(DL_DEBUG(12008), "alloc", strerror(errno)); goto done; } free_attr_list = B_TRUE; #ifdef DEBUG if (nvlist_add_string(attr_list, TAPEALERT_SRC_FILE, src_fn)) { DevLog(DL_DEBUG(12008), TAPEALERT_SRC_FILE, strerror(errno)); goto done; } if (nvlist_add_int32(attr_list, TAPEALERT_SRC_LINE, src_ln)) { DevLog(DL_DEBUG(12008), TAPEALERT_SRC_LINE, strerror(errno)); goto done; } #endif /* DEBUG */ if (nvlist_add_string(attr_list, TAPEALERT_VENDOR, (char *)un->vendor_id)) { DevLog(DL_DEBUG(12008), TAPEALERT_VENDOR, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_PRODUCT, (char *)un->product_id)) { DevLog(DL_DEBUG(12008), TAPEALERT_PRODUCT, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_USN, (char *)un->serial)) { DevLog(DL_DEBUG(12008), TAPEALERT_USN, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_REV, (char *)un->revision)) { DevLog(DL_DEBUG(12008), TAPEALERT_REV, strerror(errno)); goto done; } time(&tm); if (nvlist_add_int32(attr_list, TAPEALERT_TOD, tm)) { DevLog(DL_DEBUG(12008), TAPEALERT_TOD, strerror(errno)); goto done; } if (nvlist_add_int16(attr_list, TAPEALERT_EQ_ORD, un->eq)) { DevLog(DL_DEBUG(12008), TAPEALERT_EQ_ORD, strerror(errno)); goto done; } if (nvlist_add_string(attr_list, TAPEALERT_NAME, un->name)) { DevLog(DL_DEBUG(12008), TAPEALERT_NAME, strerror(errno)); goto done; } if (nvlist_add_byte(attr_list, TAPEALERT_VERSION, un->version)) { DevLog(DL_DEBUG(12008), TAPEALERT_VERSION, strerror(errno)); goto done; } if (nvlist_add_byte(attr_list, TAPEALERT_INQ_TYPE, un->scsi_type)) { DevLog(DL_DEBUG(12008), TAPEALERT_INQ_TYPE, strerror(errno)); goto done; } if (strlen(str = (char *)un->set) < 1) { str = TAPEALERT_EMPTY_STR; } if (nvlist_add_string(attr_list, TAPEALERT_SET, str)) { DevLog(DL_DEBUG(12008), TAPEALERT_SET, strerror(errno)); goto done; } if (nvlist_add_int16(attr_list, TAPEALERT_FSEQ, un->fseq)) { DevLog(DL_DEBUG(12008), TAPEALERT_FSEQ, strerror(errno)); goto done; } if (strlen(str = (char *)un->vsn) < 1) { str = TAPEALERT_EMPTY_STR; } if (nvlist_add_string(attr_list, TAPEALERT_VSN, str)) { DevLog(DL_DEBUG(12008), TAPEALERT_VSN, strerror(errno)); goto done; } if (nvlist_add_int16(attr_list, TAPEALERT_FLAGS_LEN, flags_len)) { DevLog(DL_DEBUG(12008), TAPEALERT_FLAGS_LEN, strerror(errno)); goto done; } if (nvlist_add_uint64(attr_list, TAPEALERT_FLAGS, flags)) { DevLog(DL_DEBUG(12008), TAPEALERT_FLAGS, strerror(errno)); goto done; } /* class, subclass, vendor, publisher, attribute list, event id */ if (sysevent_post_event(TAPEALERT_SE_CLASS, TAPEALERT_SE_SUBCLASS, TAPEALERT_SE_VENDOR, TAPEALERT_SE_PUBLISHER, attr_list, &eid) != 0) { DevLog(DL_DEBUG(12008), TAPEALERT_SE_PUBLISHER, strerror(errno)); goto done; } *seq_no = eid.eid_seq; /* * tapealert sysevent successfully sent. */ rtn = 0; done: if (free_attr_list == B_TRUE) { nvlist_free(attr_list); } return (rtn); }
/* ARGSUSED */ static int tokenmt_info(ipp_action_id_t aid, int (*fn)(nvlist_t *, void *), void *arg, ipp_flags_t flags) { nvlist_t *nvlp; tokenmt_data_t *tokenmt_data; tokenmt_cfg_t *cfg_parms; char *next_action; int32_t dscp_to_colour[64]; int rc; tokenmt_data = (tokenmt_data_t *)ipp_action_get_ptr(aid); ASSERT(tokenmt_data != NULL); cfg_parms = tokenmt_data->cfg_parms; /* allocate nvlist to be passed back */ if ((rc = nvlist_alloc(&nvlp, NV_UNIQUE_NAME, KM_NOSLEEP)) != 0) { tokenmt0dbg(("tokenmt_info: memory allocation failure\n")); return (rc); } /* look up red next action with the next action id */ if ((rc = ipp_action_name(cfg_parms->red_action, &next_action)) != 0) { tokenmt0dbg(("tokenmt_info: red_action not available\n")); nvlist_free(nvlp); return (rc); } /* add next action name */ if ((rc = nvlist_add_string(nvlp, TOKENMT_RED_ACTION_NAME, next_action)) != 0) { nvlist_free(nvlp); tokenmt0dbg(("tokenmt_info: error adding red_action\n")); kmem_free(next_action, (strlen(next_action) + 1)); return (rc); } /* free action name */ kmem_free(next_action, (strlen(next_action) + 1)); /* look up yellow next action with the next action id */ if (cfg_parms->yellow_action != TOKENMT_NO_ACTION) { if ((rc = ipp_action_name(cfg_parms->yellow_action, &next_action)) != 0) { tokenmt0dbg(("tokenmt_info: yellow_action not "\ "available\n")); nvlist_free(nvlp); return (rc); } /* add next action name */ if ((rc = nvlist_add_string(nvlp, TOKENMT_YELLOW_ACTION_NAME, next_action)) != 0) { nvlist_free(nvlp); tokenmt0dbg(("tokenmt_info: error adding "\ "yellow_action\n")); kmem_free(next_action, (strlen(next_action) + 1)); return (rc); } /* free action name */ kmem_free(next_action, (strlen(next_action) + 1)); } /* look up green next action with the next action id */ if ((rc = ipp_action_name(cfg_parms->green_action, &next_action)) != 0) { tokenmt0dbg(("tokenmt_info: green_action not available\n")); nvlist_free(nvlp); return (rc); } /* add next action name */ if ((rc = nvlist_add_string(nvlp, TOKENMT_GREEN_ACTION_NAME, next_action)) != 0) { nvlist_free(nvlp); tokenmt0dbg(("tokenmt_info: error adding green_action\n")); kmem_free(next_action, (strlen(next_action) + 1)); return (rc); } /* free action name */ kmem_free(next_action, (strlen(next_action) + 1)); /* add config type */ if ((rc = nvlist_add_byte(nvlp, IPP_CONFIG_TYPE, IPP_SET)) != 0) { tokenmt0dbg(("tokenmt_info: error adding config_type\n")); nvlist_free(nvlp); return (rc); } /* add committed_rate */ if ((rc = nvlist_add_uint32(nvlp, TOKENMT_COMMITTED_RATE, cfg_parms->committed_rate)) != 0) { tokenmt0dbg(("tokenmt_info: error adding committed_rate\n")); nvlist_free(nvlp); return (rc); } if (cfg_parms->tokenmt_type == TRTCL_TOKENMT) { /* add peak rate */ if ((rc = nvlist_add_uint32(nvlp, TOKENMT_PEAK_RATE, cfg_parms->peak_rate)) != 0) { tokenmt0dbg(("tokenmt_info: error adding peak_rate\n")); nvlist_free(nvlp); return (rc); } } /* add committed_burst */ if ((rc = nvlist_add_uint32(nvlp, TOKENMT_COMMITTED_BURST, cfg_parms->committed_burst)) != 0) { tokenmt0dbg(("tokenmt_info: error adding committed_burst\n")); nvlist_free(nvlp); return (rc); } /* add peak_burst */ if (cfg_parms->peak_burst != 0) { if ((rc = nvlist_add_uint32(nvlp, TOKENMT_PEAK_BURST, cfg_parms->peak_burst)) != 0) { tokenmt0dbg(("tokenmt_info: error adding peak "\ "burst\n")); nvlist_free(nvlp); return (rc); } } /* add colour aware */ if ((rc = nvlist_add_uint32(nvlp, TOKENMT_COLOUR_AWARE, cfg_parms->colour_aware)) != 0) { tokenmt0dbg(("tokenmt_info: error adding mode\n")); nvlist_free(nvlp); return (rc); } if (cfg_parms->colour_aware) { bcopy(cfg_parms->dscp_to_colour, dscp_to_colour, sizeof (cfg_parms->dscp_to_colour)); if ((rc = nvlist_add_int32_array(nvlp, TOKENMT_COLOUR_MAP, dscp_to_colour, 64)) != 0) { tokenmt0dbg(("tokenmt_info: error adding colour "\ "array\n")); nvlist_free(nvlp); return (rc); } } if ((rc = nvlist_add_uint32(nvlp, IPP_ACTION_STATS_ENABLE, (uint32_t)cfg_parms->stats)) != 0) { tokenmt0dbg(("tokenmt_info: error adding stats status\n")); nvlist_free(nvlp); return (rc); } /* call back with nvlist */ rc = fn(nvlp, arg); nvlist_free(nvlp); return (rc); }