return 0;
}
-int pass_get_table(struct pass_resource *res, char *pass_conf_path)
-{
- struct pass_policy *policy;
- int ret;
-
- if (!res)
- return -EINVAL;
-
- policy = &res->policy;
-
- policy->state = PASS_UNUSED;
- policy->pmqos.state = PASS_UNUSED;
-
- policy->state = 0;
- policy->gov_type = 0;
- policy->num_levels = 0;
- policy->min_level = 0;
- policy->max_level = 0;
- policy->num_pass_cpu_stats = 0;
- policy->pass_cpu_threshold = 0;
- policy->up_threshold = 0;
- policy->down_threshold = 0;
- policy->init_level = 0;
- policy->prev_level = policy->init_level;
- policy->level_up_threshold = 0;
- policy->gov_timeout = 0;
- policy->last_time = 0;
-
- ret = config_parse(pass_conf_path, pass_load_config, policy);
- if (ret < 0) {
- _E("cannot parse %s\n", pass_conf_path);
- return -EINVAL;
- }
-
- /*
- int level;
-
- _I("%s| policy->state : %d\n",
- res->cdata.res_name, policy->state);
- _I("%s| policy->gov_type : %d\n",
- res->cdata.res_name, policy->gov_type);
- _I("%s| policy->num_levels : %d\n",
- res->cdata.res_name, policy->num_levels);
- _I("%s| policy->min_level : %d\n",
- res->cdata.res_name, policy->min_level);
- _I("%s| policy->max_level : %d\n",
- res->cdata.res_name, policy->max_level);
- _I("%s| policy->num_pass_cpu_stats : %d\n",
- res->cdata.res_name, policy->num_pass_cpu_stats);
- _I("%s| policy->pass_cpu_threshold : %d\n",
- res->cdata.res_name, policy->pass_cpu_threshold);
- _I("%s| policy->up_threshold : %d\n",
- res->cdata.res_name, policy->up_threshold);
- _I("%s| policy->down_threshold : %d\n",
- res->cdata.res_name, policy->down_threshold);
- _I("%s| policy->init_level : %d\n",
- res->cdata.res_name, policy->init_level);
- _I("%s| policy->level_up_threshold : %d\n",
- res->cdata.res_name, policy->level_up_threshold);
- _I("%s| policy->gov_timeout : %f\n",
- res->cdata.res_name, policy->gov_timeout);
-
- for (level = 0; level < policy->num_levels; level++) {
- _I("================================================\n");
- if (policy->levels[level].limit_max_freq)
- _I("%s| policy->levels[%d].limit_max_freq : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].limit_max_freq);
- if (policy->levels[level].limit_min_freq)
- _I("%s| policy->levels[%d].limit_min_freq : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].limit_min_freq);
- if (policy->levels[level].limit_min_cpu)
- _I("%s| policy->levels[%d].limit_min_cpu : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].limit_min_cpu);
- if (policy->levels[level].gov_timeout)
- _I("%s| policy->levels[%d].gov_timeout : %f\n",
- res->cdata.res_name, level,
- policy->levels[level].gov_timeout);
-
- if (policy->levels[level].num_down_cond)
- _I("%s| policy->levels[%d].num_down_cond : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].num_down_cond);
- if (policy->levels[level].down_cond[0].freq)
- _I("%s| policy->levels[%d].down_cond[0].freq : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].down_cond[0].freq);
- if (policy->levels[level].down_cond[0].nr_running)
- _I("%s| policy->levels[%d].down_cond[0].nr_running : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].down_cond[0].nr_running);
- if (policy->levels[level].down_cond[0].busy_cpu)
- _I("%s| policy->levels[%d].down_cond[0].busy_cpu : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].down_cond[0].busy_cpu);
-
- if (policy->levels[level].num_up_cond)
- _I("%s| policy->levels[%d].num_up_cond : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].num_up_cond);
- if (policy->levels[level].up_cond[0].freq)
- _I("%s| policy->levels[%d].up_cond[0].freq : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].up_cond[0].freq);
- if (policy->levels[level].up_cond[0].nr_running)
- _I("%s| policy->levels[%d].up_cond[0].nr_running : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].up_cond[0].nr_running);
- if (policy->levels[level].up_cond[0].busy_cpu)
- _I("%s| policy->levels[%d].up_cond[0].busy_cpu : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].up_cond[0].busy_cpu);
-
- if (policy->levels[level].num_left_cond)
- _I("%s| policy->levels[%d].num_left_cond : %d\n",
- res->cdata.res_name, level,
- policy->levels[level].num_left_cond);
- if (policy->levels[level].left_cond[0].freq)
- _I("%s| policy->levels[%d].left_cond[0].freq : %d\n",
- res->cdata.res_name, level, policy->levels[level].left_cond[0].freq);
- if (policy->levels[level].left_cond[0].nr_running)
- _I("%s| policy->levels[%d].left_cond[0].nr_running : %d\n",
- res->cdata.res_name, level, policy->levels[level].left_cond[0].nr_running);
- if (policy->levels[level].left_cond[0].busy_cpu)
- _I("%s| policy->levels[%d].left_cond[0].busy_cpu : %d\n",
- res->cdata.res_name, level, policy->levels[level].left_cond[0].busy_cpu);
-
- if (policy->levels[level].num_right_cond)
- _I("%s| policy->levels[%d].num_right_cond : %d\n",
- res->cdata.res_name, level, policy->levels[level].num_right_cond);
- if (policy->levels[level].right_cond[0].freq)
- _I("%s| policy->levels[%d].right_cond[0].freq : %d\n",
- res->cdata.res_name, level, policy->levels[level].right_cond[0].freq);
- if (policy->levels[level].right_cond[0].nr_running)
- _I("%s| policy->levels[%d].right_cond[0].nr_running : %d\n",
- res->cdata.res_name, level, policy->levels[level].right_cond[0].nr_running);
- if (policy->levels[level].right_cond[0].busy_cpu)
- _I("%s| policy->levels[%d].right_cond[0].busy_cpu : %d\n",
- res->cdata.res_name, level, policy->levels[level].right_cond[0].busy_cpu);
- }
- */
-
- if (policy->state == PASS_UNUSED)
- return -EINVAL;
-
- if (policy->pmqos.state == PASS_UNUSED)
- _W("%s don't include the list of pass-scenario\n");
- else if (policy->pmqos.state == PASS_OFF)
- _I("cannot use pass-scenario");
-
- return 0;
-}
-
-void pass_put_table(struct pass_resource *res)
-{
- struct pass_policy *policy;
-
- if (!res) {
- _E("cannot put pass table\n");
- return;
- }
-
- policy = &res->policy;
-
- if (policy->levels) {
- free(policy->levels);
- policy->levels = NULL;
- }
-
- if (policy->pmqos.scenarios) {
- free(policy->pmqos.scenarios);
- policy->pmqos.scenarios = NULL;
- }
-
- policy->pmqos.num_scenarios = 0;
-}
-
static int pass_parse_resource_data(struct parse_result *result,
void *user_data, int id)
{
return 0;
}
+
static int check_compatible(char *compatible, char *path_compatible)
{
char buf[BUFF_MAX];
return 0;
}
-static int pass_resource_config(struct parse_result *result, void *user_data)
+static int parse_resource(struct parse_result *result, void *user_data)
{
static char path_compatible[BUFF_MAX];
static bool is_compatible = false;
return 0;
}
-int pass_get_resource_config(struct pass *pass, char *pass_conf_path)
+/*
+ * pass_get_resource_config - Get all h/w resource information
+ *
+ * @pass: the instance of struct pass which contains all information
+ * @path: the path of configuration files (e.g., /etc/pass/pass.conf)
+ */
+int pass_get_resource_config(struct pass *pass, char *path)
{
- return config_parse(pass_conf_path, pass_resource_config, pass);
+ return config_parse(path, parse_resource, pass);
}
+/*
+ * pass_get_resource_config - Free h/w resource information
+ *
+ * @pass: the instance of struct pass which contains all information
+ */
void pass_put_resource_config(struct pass *pass)
{
free(pass->res);
pass->res = NULL;
pass->num_resources = 0;
}
+
+/*
+ * pass_get_each_resource_config - Get each h/w resource information
+ *
+ * @res: the instance of struct pass_resource
+ * @path: the path of configuration file for each h/w resource
+ */
+int pass_get_each_resource_config(struct pass_resource *res, char *path)
+{
+ struct pass_policy *policy;
+ int ret;
+
+ if (!res)
+ return -EINVAL;
+
+ policy = &res->policy;
+
+ policy->state = PASS_UNUSED;
+ policy->pmqos.state = PASS_UNUSED;
+
+ policy->state = 0;
+ policy->gov_type = 0;
+ policy->num_levels = 0;
+ policy->min_level = 0;
+ policy->max_level = 0;
+ policy->num_pass_cpu_stats = 0;
+ policy->pass_cpu_threshold = 0;
+ policy->up_threshold = 0;
+ policy->down_threshold = 0;
+ policy->init_level = 0;
+ policy->prev_level = policy->init_level;
+ policy->level_up_threshold = 0;
+ policy->gov_timeout = 0;
+ policy->last_time = 0;
+
+ ret = config_parse(path, pass_load_config, policy);
+ if (ret < 0) {
+ _E("cannot parse %s\n", path);
+ return -EINVAL;
+ }
+
+ /*
+ int level;
+
+ _I("%s| policy->state : %d\n",
+ res->cdata.res_name, policy->state);
+ _I("%s| policy->gov_type : %d\n",
+ res->cdata.res_name, policy->gov_type);
+ _I("%s| policy->num_levels : %d\n",
+ res->cdata.res_name, policy->num_levels);
+ _I("%s| policy->min_level : %d\n",
+ res->cdata.res_name, policy->min_level);
+ _I("%s| policy->max_level : %d\n",
+ res->cdata.res_name, policy->max_level);
+ _I("%s| policy->num_pass_cpu_stats : %d\n",
+ res->cdata.res_name, policy->num_pass_cpu_stats);
+ _I("%s| policy->pass_cpu_threshold : %d\n",
+ res->cdata.res_name, policy->pass_cpu_threshold);
+ _I("%s| policy->up_threshold : %d\n",
+ res->cdata.res_name, policy->up_threshold);
+ _I("%s| policy->down_threshold : %d\n",
+ res->cdata.res_name, policy->down_threshold);
+ _I("%s| policy->init_level : %d\n",
+ res->cdata.res_name, policy->init_level);
+ _I("%s| policy->level_up_threshold : %d\n",
+ res->cdata.res_name, policy->level_up_threshold);
+ _I("%s| policy->gov_timeout : %f\n",
+ res->cdata.res_name, policy->gov_timeout);
+
+ for (level = 0; level < policy->num_levels; level++) {
+ _I("================================================\n");
+ if (policy->levels[level].limit_max_freq)
+ _I("%s| policy->levels[%d].limit_max_freq : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].limit_max_freq);
+ if (policy->levels[level].limit_min_freq)
+ _I("%s| policy->levels[%d].limit_min_freq : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].limit_min_freq);
+ if (policy->levels[level].limit_min_cpu)
+ _I("%s| policy->levels[%d].limit_min_cpu : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].limit_min_cpu);
+ if (policy->levels[level].gov_timeout)
+ _I("%s| policy->levels[%d].gov_timeout : %f\n",
+ res->cdata.res_name, level,
+ policy->levels[level].gov_timeout);
+
+ if (policy->levels[level].num_down_cond)
+ _I("%s| policy->levels[%d].num_down_cond : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].num_down_cond);
+ if (policy->levels[level].down_cond[0].freq)
+ _I("%s| policy->levels[%d].down_cond[0].freq : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].down_cond[0].freq);
+ if (policy->levels[level].down_cond[0].nr_running)
+ _I("%s| policy->levels[%d].down_cond[0].nr_running : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].down_cond[0].nr_running);
+ if (policy->levels[level].down_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].down_cond[0].busy_cpu : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].down_cond[0].busy_cpu);
+
+ if (policy->levels[level].num_up_cond)
+ _I("%s| policy->levels[%d].num_up_cond : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].num_up_cond);
+ if (policy->levels[level].up_cond[0].freq)
+ _I("%s| policy->levels[%d].up_cond[0].freq : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].up_cond[0].freq);
+ if (policy->levels[level].up_cond[0].nr_running)
+ _I("%s| policy->levels[%d].up_cond[0].nr_running : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].up_cond[0].nr_running);
+ if (policy->levels[level].up_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].up_cond[0].busy_cpu : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].up_cond[0].busy_cpu);
+
+ if (policy->levels[level].num_left_cond)
+ _I("%s| policy->levels[%d].num_left_cond : %d\n",
+ res->cdata.res_name, level,
+ policy->levels[level].num_left_cond);
+ if (policy->levels[level].left_cond[0].freq)
+ _I("%s| policy->levels[%d].left_cond[0].freq : %d\n",
+ res->cdata.res_name, level, policy->levels[level].left_cond[0].freq);
+ if (policy->levels[level].left_cond[0].nr_running)
+ _I("%s| policy->levels[%d].left_cond[0].nr_running : %d\n",
+ res->cdata.res_name, level, policy->levels[level].left_cond[0].nr_running);
+ if (policy->levels[level].left_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].left_cond[0].busy_cpu : %d\n",
+ res->cdata.res_name, level, policy->levels[level].left_cond[0].busy_cpu);
+
+ if (policy->levels[level].num_right_cond)
+ _I("%s| policy->levels[%d].num_right_cond : %d\n",
+ res->cdata.res_name, level, policy->levels[level].num_right_cond);
+ if (policy->levels[level].right_cond[0].freq)
+ _I("%s| policy->levels[%d].right_cond[0].freq : %d\n",
+ res->cdata.res_name, level, policy->levels[level].right_cond[0].freq);
+ if (policy->levels[level].right_cond[0].nr_running)
+ _I("%s| policy->levels[%d].right_cond[0].nr_running : %d\n",
+ res->cdata.res_name, level, policy->levels[level].right_cond[0].nr_running);
+ if (policy->levels[level].right_cond[0].busy_cpu)
+ _I("%s| policy->levels[%d].right_cond[0].busy_cpu : %d\n",
+ res->cdata.res_name, level, policy->levels[level].right_cond[0].busy_cpu);
+ }
+ */
+
+ if (policy->state == PASS_UNUSED)
+ return -EINVAL;
+
+ if (policy->pmqos.state == PASS_UNUSED)
+ _W("%s don't include the list of pass-scenario\n");
+ else if (policy->pmqos.state == PASS_OFF)
+ _I("cannot use pass-scenario");
+
+ return 0;
+}
+
+/*
+ * pass_put_each_resource_config - Free each h/w resource information
+ *
+ * @res: the instance of struct pass_resource
+ */
+void pass_put_each_resource_config(struct pass_resource *res)
+{
+ struct pass_policy *policy;
+
+ if (!res) {
+ _E("cannot put pass table\n");
+ return;
+ }
+
+ policy = &res->policy;
+
+ if (policy->levels) {
+ free(policy->levels);
+ policy->levels = NULL;
+ }
+
+ if (policy->pmqos.scenarios) {
+ free(policy->pmqos.scenarios);
+ policy->pmqos.scenarios = NULL;
+ }
+
+ policy->pmqos.num_scenarios = 0;
+}