summaryrefslogtreecommitdiff
path: root/include/misc/ocxl.h
diff options
context:
space:
mode:
authorAlastair D'Silva <alastair@d-silva.org>2019-03-27 16:31:33 +1100
committerMichael Ellerman <mpe@ellerman.id.au>2019-05-03 02:55:02 +1000
commitb9721d275cc2c5e6c07371239c827e0faf05a6b9 (patch)
tree06ac877469c44d3c14a93a013440150818c6567a /include/misc/ocxl.h
parent75ca758adbafc81804c39b2c200ecdc819a6c042 (diff)
ocxl: Allow external drivers to use OpenCAPI contexts
Most OpenCAPI operations require a valid context, so exposing these functions to external drivers is necessary. Signed-off-by: Alastair D'Silva <alastair@d-silva.org> Reviewed-by: Greg Kurz <groug@kaod.org> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'include/misc/ocxl.h')
-rw-r--r--include/misc/ocxl.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 8bafd748e380..e4704632eac5 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -48,6 +48,7 @@ struct ocxl_fn_config {
// These are opaque outside the ocxl driver
struct ocxl_afu;
struct ocxl_fn;
+struct ocxl_context;
// Device detection & initialisation
@@ -116,6 +117,44 @@ const struct ocxl_fn_config *ocxl_function_config(struct ocxl_fn *fn);
*/
void ocxl_function_close(struct ocxl_fn *fn);
+// Context allocation
+
+/**
+ * Allocate an OpenCAPI context
+ *
+ * @context: The OpenCAPI context to allocate, must be freed with ocxl_context_free
+ * @afu: The AFU the context belongs to
+ * @mapping: The mapping to unmap when the context is closed (may be NULL)
+ */
+int ocxl_context_alloc(struct ocxl_context **context, struct ocxl_afu *afu,
+ struct address_space *mapping);
+
+/**
+ * Free an OpenCAPI context
+ *
+ * @ctx: The OpenCAPI context to free
+ */
+void ocxl_context_free(struct ocxl_context *ctx);
+
+/**
+ * Grant access to an MM to an OpenCAPI context
+ * @ctx: The OpenCAPI context to attach
+ * @amr: The value of the AMR register to restrict access
+ * @mm: The mm to attach to the context
+ *
+ * Returns 0 on success, negative on failure
+ */
+int ocxl_context_attach(struct ocxl_context *ctx, u64 amr,
+ struct mm_struct *mm);
+
+/**
+ * Detach an MM from an OpenCAPI context
+ * @ctx: The OpenCAPI context to attach
+ *
+ * Returns 0 on success, negative on failure
+ */
+int ocxl_context_detach(struct ocxl_context *ctx);
+
// AFU Metadata
/**