#include <signal.h>
#include <limits.h>
-#include <rte_memcpy.h>
#include <rte_atomic.h>
+#include <rte_memcpy.h>
+#include <rte_memory.h>
+#include <rte_string_fns.h>
#include "power_acpi_cpufreq.h"
#include "power_common.h"
s = fgets(buf, sizeof(buf), f);
FOPS_OR_NULL_GOTO(s, out);
+ /* Strip off terminating '\n' */
+ strtok(buf, "\n");
/* Check if current governor is userspace */
if (strncmp(buf, POWER_GOVERNOR_USERSPACE,
goto out;
}
/* Save the original governor */
- snprintf(pi->governor_ori, sizeof(pi->governor_ori), "%s", buf);
+ strlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori));
/* Write 'userspace' to the governor */
val = fseek(f, 0, SEEK_SET);
val = fputs(POWER_GOVERNOR_USERSPACE, f);
FOPS_OR_ERR_GOTO(val, out);
+ /* We need to flush to see if the fputs succeeds */
+ val = fflush(f);
+ FOPS_OR_ERR_GOTO(val, out);
+
ret = 0;
RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been "
"set to user space successfully\n", pi->lcore_id);
{
struct rte_power_info *pi;
- if (lcore_id >= RTE_MAX_LCORE || !freqs) {
- RTE_LOG(ERR, POWER, "Invalid input parameter\n");
+ if (lcore_id >= RTE_MAX_LCORE) {
+ RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+ return 0;
+ }
+
+ if (freqs == NULL) {
+ RTE_LOG(ERR, POWER, "NULL buffer supplied\n");
return 0;
}
return 0;
}
+
+int power_acpi_get_capabilities(unsigned int lcore_id,
+ struct rte_power_core_capabilities *caps)
+{
+ struct rte_power_info *pi;
+
+ if (lcore_id >= RTE_MAX_LCORE) {
+ RTE_LOG(ERR, POWER, "Invalid lcore ID\n");
+ return -1;
+ }
+ if (caps == NULL) {
+ RTE_LOG(ERR, POWER, "Invalid argument\n");
+ return -1;
+ }
+
+ pi = &lcore_power_info[lcore_id];
+ caps->capabilities = 0;
+ caps->turbo = !!(pi->turbo_available);
+
+ return 0;
+}