isst-core.c should contain generic core APIs only.
Platform specific implementations/configurations should be removed from
this file.
Introduce isst-core-mbox.c and move all mbox/mmio specific functions to
this file.
Introduce struct isst_platform_ops which contains a series of callbacks
that used by the core APIs but need platform specific implementation.
No functional changes are expected.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[srinivas.pandruvada@linux.intel.com: changelog edits]
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
-intel-speed-select-y += isst-config.o isst-core.o isst-display.o isst-daemon.o hfi-events.o
+intel-speed-select-y += isst-config.o isst-core.o isst-display.o isst-daemon.o hfi-events.o isst-core-mbox.o
int fd;
if (is_clx_n_platform())
- return 0;
+ goto set_platform_ops;
fd = open(pathname, O_RDWR);
if (fd < 0)
printf("Incompatible API versions; Upgrade of tool is required\n");
return -1;
}
+
+set_platform_ops:
+ if (isst_set_platform_ops()) {
+ fprintf(stderr, "Failed to set platform callbacks\n");
+ exit(0);
+ }
return 0;
}
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Intel Speed Select -- Enumerate and control features for Mailbox Interface
+ * Copyright (c) 2023 Intel Corporation.
+ */
+#include "isst.h"
+
+static int mbox_get_disp_freq_multiplier(void)
+{
+ return DISP_FREQ_MULTIPLIER;
+}
+
+static int mbox_get_trl_max_levels(void)
+{
+ return 3;
+}
+
+static char *mbox_get_trl_level_name(int level)
+{
+ switch (level) {
+ case 0:
+ return "sse";
+ case 1:
+ return "avx2";
+ case 2:
+ return "avx512";
+ default:
+ return NULL;
+ }
+}
+
+
+
+static struct isst_platform_ops mbox_ops = {
+ .get_disp_freq_multiplier = mbox_get_disp_freq_multiplier,
+ .get_trl_max_levels = mbox_get_trl_max_levels,
+ .get_trl_level_name = mbox_get_trl_level_name,
+};
+
+struct isst_platform_ops *mbox_get_platform_ops(void)
+{
+ return &mbox_ops;
+}
static int mbox_delay;
static int mbox_retries = 3;
+static struct isst_platform_ops *isst_ops;
+
+#define CHECK_CB(_name) \
+ do { \
+ if (!isst_ops || !isst_ops->_name) { \
+ fprintf(stderr, "Invalid ops\n"); \
+ exit(0); \
+ } \
+ } while (0)
+
+int isst_set_platform_ops(void)
+{
+ isst_ops = mbox_get_platform_ops();
+
+ if (!isst_ops)
+ return -1;
+ return 0;
+}
+
void isst_update_platform_param(enum isst_platform_param param, int value)
{
switch (param) {
int isst_get_disp_freq_multiplier(void)
{
- return DISP_FREQ_MULTIPLIER;
+ CHECK_CB(get_disp_freq_multiplier);
+ return isst_ops->get_disp_freq_multiplier();
}
int isst_get_trl_max_levels(void)
{
- return 3;
+ CHECK_CB(get_trl_max_levels);
+ return isst_ops->get_trl_max_levels();
}
char *isst_get_trl_level_name(int level)
{
- switch (level) {
- case 0:
- return "sse";
- case 1:
- return "avx2";
- case 2:
- return "avx512";
- default:
- return NULL;
- }
+ CHECK_CB(get_trl_level_name);
+ return isst_ops->get_trl_level_name(level);
}
int isst_is_punit_valid(struct isst_id *id)
ISST_PARAM_MBOX_RETRIES,
};
+struct isst_platform_ops {
+ int (*get_disp_freq_multiplier)(void);
+ int (*get_trl_max_levels)(void);
+ char *(*get_trl_level_name)(int level);
+};
+
extern int is_cpu_in_power_domain(int cpu, struct isst_id *id);
extern int get_topo_max_cpus(void);
extern int get_cpu_count(struct isst_id *id);
extern int isst_send_msr_command(unsigned int cpu, unsigned int command,
int write, unsigned long long *req_resp);
+extern int isst_set_platform_ops(void);
extern void isst_update_platform_param(enum isst_platform_param, int vale);
extern int isst_get_disp_freq_multiplier(void);
extern int isst_get_trl_max_levels(void);
extern void process_level_change(struct isst_id *id);
extern int hfi_main(void);
extern void hfi_exit(void);
+
+/* Interface specific callbacks */
+extern struct isst_platform_ops *mbox_get_platform_ops(void);
+
#endif