-/**
- * It is to get the available frequencies of the specific lcore by reading the
- * sys file.
- */
-static int
-power_get_available_freqs(struct rte_power_info *pi)
-{
- FILE *f;
- int ret = -1, i, count;
- char *p;
- char buf[BUFSIZ];
- char fullpath[PATH_MAX];
- char *freqs[RTE_MAX_LCORE_FREQS];
- char *s;
-
- rte_snprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_AVAIL_FREQ,
- pi->lcore_id);
- f = fopen(fullpath, "r");
- FOPEN_OR_ERR_RET(f, ret);
-
- s = fgets(buf, sizeof(buf), f);
- FOPS_OR_NULL_GOTO(s, out);
-
- /* Strip the line break if there is */
- p = strchr(buf, '\n');
- if (p != NULL)
- *p = 0;
-
- /* Split string into at most RTE_MAX_LCORE_FREQS frequencies */
- count = rte_strsplit(buf, sizeof(buf), freqs,
- RTE_MAX_LCORE_FREQS, ' ');
- if (count <= 0) {
- RTE_LOG(ERR, POWER, "No available frequency in "
- ""POWER_SYSFILE_AVAIL_FREQ"\n", pi->lcore_id);
- goto out;
- }
- if (count >= RTE_MAX_LCORE_FREQS) {
- RTE_LOG(ERR, POWER, "Too many available frequencies : %d\n",
- count);
- goto out;
- }
-
- /* Store the available frequncies into power context */
- for (i = 0, pi->nb_freqs = 0; i < count; i++) {
- POWER_DEBUG_TRACE("Lcore %u frequency[%d]: %s\n", pi->lcore_id,
- i, freqs[i]);
- pi->freqs[pi->nb_freqs++] = strtoul(freqs[i], &p,
- POWER_CONVERT_TO_DECIMAL);
- }
-
- ret = 0;
- POWER_DEBUG_TRACE("%d frequencie(s) of lcore %u are available\n",
- count, pi->lcore_id);
-out:
- fclose(f);
-
- return ret;
-}
-
-/**
- * It is to fopen the sys file for the future setting the lcore frequency.
- */
-static int
-power_init_for_setting_freq(struct rte_power_info *pi)
-{
- FILE *f;
- char fullpath[PATH_MAX];
- char buf[BUFSIZ];
- uint32_t i, freq;
- char *s;
-
- rte_snprintf(fullpath, sizeof(fullpath), POWER_SYSFILE_SETSPEED,
- pi->lcore_id);
- f = fopen(fullpath, "rw+");
- FOPEN_OR_ERR_RET(f, -1);
-
- s = fgets(buf, sizeof(buf), f);
- FOPS_OR_NULL_GOTO(s, out);
-
- freq = strtoul(buf, NULL, POWER_CONVERT_TO_DECIMAL);
- for (i = 0; i < pi->nb_freqs; i++) {
- if (freq == pi->freqs[i]) {
- pi->curr_idx = i;
- pi->f = f;
- return 0;
- }
- }
-
-out:
- fclose(f);
-
- return -1;