@@ -255,3 +255,58 @@ err:
prerror("IMC Devices not added\n");
free(buf);
}
+
+/*
+ * opal_nest_imc_counters_control : This call controls the nest IMC microcode.
+ *
+ * mode : For now, this call supports only NEST_IMC_PRODUCTION_MODE.
+ * This mode can start/stop the Nest IMC Microcode for nest
+ * instrumentation from Host OS.
+ * operation : Start(0x0) or Stop(0x1) the engine.
+ *
+ * This call can be extended to include more operations to use the multiple
+ * debug modes provided by the nest IMC microcode and the parameters value_1
+ * and value_2 for the same purpose.
+ */
+static int64_t opal_nest_imc_counters_control(uint64_t mode,
+ uint64_t operation,
+ uint64_t value_1,
+ uint64_t value_2)
+{
+ u64 op, status;
+ struct imc_chip_cb *cb;
+
+ if ((mode != NEST_IMC_PRODUCTION_MODE) || value_1 || value_2)
+ return OPAL_PARAMETER;
+
+ /* Fetch the IMC control block structure */
+ cb = get_imc_cb();
+ status = be64_to_cpu(cb->imc_chip_run_status);
+
+ switch (operation) {
+ case OPAL_NEST_IMC_STOP:
+ /* Check whether the engine is already stopped */
+ if (status == NEST_IMC_PAUSE)
+ return OPAL_SUCCESS;
+
+ op = NEST_IMC_DISABLE;
+ break;
+ case OPAL_NEST_IMC_START:
+ /* Check whether the engine is already running */
+ if (status == NEST_IMC_RESUME)
+ return OPAL_SUCCESS;
+
+ op = NEST_IMC_ENABLE;
+ break;
+ default:
+ prerror("IMC: unknown operation for nest imc\n");
+ return OPAL_PARAMETER;
+ }
+
+ /* Write the command to the control block now */
+ cb->imc_chip_command = op;
+
+ return OPAL_SUCCESS;
+}
+
+opal_call(OPAL_NEST_IMC_COUNTERS_CONTROL, opal_nest_imc_counters_control, 4);
@@ -200,7 +200,8 @@
#define OPAL_XIVE_DUMP 142
#define OPAL_XIVE_RESERVED3 143
#define OPAL_XIVE_RESERVED4 144
-#define OPAL_LAST 144
+#define OPAL_NEST_IMC_COUNTERS_CONTROL 145
+#define OPAL_LAST 145
/* Device tree flags */
@@ -1137,6 +1138,12 @@ enum {
XIVE_DUMP_EMU_STATE = 5,
};
+/* Operation argument to Nest IMC Microcode */
+enum {
+ OPAL_NEST_IMC_STOP,
+ OPAL_NEST_IMC_START,
+};
+
#endif /* __ASSEMBLY__ */
#endif /* __OPAL_API_H */