summaryrefslogtreecommitdiffstats
path: root/kernel/gsp_emulation.h
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-13 19:07:41 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-09-13 19:07:41 -0400
commit4b745a1c2c0534a1850b6efe6710536b2225c3f4 (patch)
tree63cedd53fec1366c1d698c57f46fa57a64b9049d /kernel/gsp_emulation.h
parent00e54c13c7c9030c4d5f7151467f2d85a3730e29 (diff)
downloadopen-iov-4b745a1c2c0534a1850b6efe6710536b2225c3f4.tar.gz
open-iov-4b745a1c2c0534a1850b6efe6710536b2225c3f4.zip
Phase 1: Add GSP Emulation Engine (host-side)
- New kernel/gsp_emulation.h: GSP emulation context and API - New kernel/gsp_emulation.c: Per-mdev emulation thread with: - Adaptive polling of doorbell at BAR0+0x110C00 - Shared memory RPC processing (4KB at BAR0+0x1000) - Dispatch for all 12 RPC types via firmware-decompiled handlers - MSI-X completion interrupt injection via eventfd - Statistics tracking (processed/failed RPCs, latency) - Modified kernel/main.c: Integrate gsp_emu_init/cleanup in device lifecycle - Modified kernel/Makefile: Add gsp_emulation.o to build - Modified kernel/gsp_rpc_client.h: Export gsp_rpc_emulation_set/is_enabled
Diffstat (limited to 'kernel/gsp_emulation.h')
-rw-r--r--kernel/gsp_emulation.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/kernel/gsp_emulation.h b/kernel/gsp_emulation.h
new file mode 100644
index 0000000..c4ceb7a
--- /dev/null
+++ b/kernel/gsp_emulation.h
@@ -0,0 +1,69 @@
+/*
+ * GSP Emulation Engine for Host-Side GSP Emulation
+ * Replaces guest-side GSP communication with host kernel emulation
+ */
+
+#ifndef _GSP_EMULATION_H_
+#define _GSP_EMULATION_H_
+
+#include <linux/types.h>
+#include <linux/device.h>
+#include <linux/mutex.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <linux/list.h>
+#include <linux/kthread.h>
+#include <linux/eventfd.h>
+
+#include "nvidia-vgpu-vfio.h"
+#include "gsp_rpc_client.h"
+#include "bar_emulation.h"
+#include "irq.h"
+#include "memory.h"
+
+/* ============================================================
+ * GSP Emulation Context
+ * ============================================================ */
+
+struct gsp_emu_context {
+ struct nv_vgpu_device *vgpu;
+ struct task_struct *thread;
+ void __iomem *bar0_vaddr;
+ void __iomem *doorbell_reg;
+ void __iomem *shared_mem;
+ struct gsp_client *rpc_client;
+ spinlock_t lock;
+ bool running;
+ bool initialized;
+
+ /* Shared memory for RPC communication (4KB at BAR0+0x1000) */
+ void *shared_mem_virt;
+ dma_addr_t shared_mem_dma;
+ size_t shared_mem_size;
+
+ /* Statistics */
+ u64 processed_rpcs;
+ u64 failed_rpcs;
+ u64 total_latency_ns;
+
+ /* MSI-X injection */
+ struct eventfd_ctx *msix_trigger[NV_VGPU_MAX_IRQS];
+};
+
+/* ============================================================
+ * Public API
+ * ============================================================ */
+
+int gsp_emu_init(struct nv_vgpu_device *vgpu);
+void gsp_emu_cleanup(struct nv_vgpu_device *vgpu);
+int gsp_emu_process_rpc(struct gsp_emu_context *ctx);
+void gsp_emu_inject_completion_interrupt(struct gsp_emu_context *ctx, u32 seq_id);
+
+/* ============================================================
+ * Debug/Statistics
+ * ============================================================ */
+
+void gsp_emu_get_stats(struct gsp_emu_context *ctx,
+ u64 *processed, u64 *failed, u64 *total_latency_ns);
+
+#endif /* _GSP_EMULATION_H_ */ \ No newline at end of file