summaryrefslogtreecommitdiffstats
path: root/include/misc
diff options
context:
space:
mode:
authorAlastair D'Silva <alastair@d-silva.org>2019-03-27 01:31:32 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2019-05-02 12:55:01 -0400
commit75ca758adbafc81804c39b2c200ecdc819a6c042 (patch)
tree091664d0900e1c6ede2fad272f1561bee354a339 /include/misc
parent2f7d3d1453813cda13e5bace24093eac22cb5e61 (diff)
ocxl: Create a clear delineation between ocxl backend & frontend
The OCXL driver contains both frontend code for interacting with userspace, as well as backend code for interacting with the hardware. This patch separates the backend code from the frontend so that it can be used by other device drivers that communicate via OpenCAPI. Relocate dev, cdev & sysfs files to the frontend code to allow external drivers to maintain their own devices. Reference counting on the device in the backend is replaced with kref counting. Move file & sysfs layer initialisation from core.c (backend) to pci.c (frontend). Create an ocxl_function oriented interface for initing devices & enumerating AFUs. Signed-off-by: Alastair D'Silva <alastair@d-silva.org> Acked-by: Frederic Barrat <fbarrat@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'include/misc')
-rw-r--r--include/misc/ocxl.h119
1 files changed, 109 insertions, 10 deletions
diff --git a/include/misc/ocxl.h b/include/misc/ocxl.h
index 9530d3be1b30..8bafd748e380 100644
--- a/include/misc/ocxl.h
+++ b/include/misc/ocxl.h
@@ -16,11 +16,7 @@
16 16
17#define OCXL_AFU_NAME_SZ (24+1) /* add 1 for NULL termination */ 17#define OCXL_AFU_NAME_SZ (24+1) /* add 1 for NULL termination */
18 18
19/* 19
20 * The following 2 structures are a fairly generic way of representing
21 * the configuration data for a function and AFU, as read from the
22 * configuration space.
23 */
24struct ocxl_afu_config { 20struct ocxl_afu_config {
25 u8 idx; 21 u8 idx;
26 int dvsec_afu_control_pos; /* offset of AFU control DVSEC */ 22 int dvsec_afu_control_pos; /* offset of AFU control DVSEC */
@@ -49,12 +45,108 @@ struct ocxl_fn_config {
49 s8 max_afu_index; 45 s8 max_afu_index;
50}; 46};
51 47
52/* 48// These are opaque outside the ocxl driver
53 * Read the configuration space of a function and fill in a 49struct ocxl_afu;
54 * ocxl_fn_config structure with all the function details 50struct ocxl_fn;
51
52// Device detection & initialisation
53
54/**
55 * Open an OpenCAPI function on an OpenCAPI device
56 *
57 * @dev: The PCI device that contains the function
58 *
59 * Returns an opaque pointer to the function, or an error pointer (check with IS_ERR)
55 */ 60 */
56int ocxl_config_read_function(struct pci_dev *dev, 61struct ocxl_fn *ocxl_function_open(struct pci_dev *dev);
57 struct ocxl_fn_config *fn); 62
63/**
64 * Get the list of AFUs associated with a PCI function device
65 *
66 * Returns a list of struct ocxl_afu *
67 *
68 * @fn: The OpenCAPI function containing the AFUs
69 */
70struct list_head *ocxl_function_afu_list(struct ocxl_fn *fn);
71
72/**
73 * Fetch an AFU instance from an OpenCAPI function
74 *
75 * @fn: The OpenCAPI function to get the AFU from
76 * @afu_idx: The index of the AFU to get
77 *
78 * If successful, the AFU should be released with ocxl_afu_put()
79 *
80 * Returns a pointer to the AFU, or NULL on error
81 */
82struct ocxl_afu *ocxl_function_fetch_afu(struct ocxl_fn *fn, u8 afu_idx);
83
84/**
85 * Take a reference to an AFU
86 *
87 * @afu: The AFU to increment the reference count on
88 */
89void ocxl_afu_get(struct ocxl_afu *afu);
90
91/**
92 * Release a reference to an AFU
93 *
94 * @afu: The AFU to decrement the reference count on
95 */
96void ocxl_afu_put(struct ocxl_afu *afu);
97
98
99/**
100 * Get the configuration information for an OpenCAPI function
101 *
102 * @fn: The OpenCAPI function to get the config for
103 *
104 * Returns the function config, or NULL on error
105 */
106const struct ocxl_fn_config *ocxl_function_config(struct ocxl_fn *fn);
107
108/**
109 * Close an OpenCAPI function
110 *
111 * This will free any AFUs previously retrieved from the function, and
112 * detach and associated contexts. The contexts must by freed by the caller.
113 *
114 * @fn: The OpenCAPI function to close
115 *
116 */
117void ocxl_function_close(struct ocxl_fn *fn);
118
119// AFU Metadata
120
121/**
122 * Get a pointer to the config for an AFU
123 *
124 * @afu: a pointer to the AFU to get the config for
125 *
126 * Returns a pointer to the AFU config
127 */
128struct ocxl_afu_config *ocxl_afu_config(struct ocxl_afu *afu);
129
130/**
131 * Assign opaque hardware specific information to an OpenCAPI AFU.
132 *
133 * @dev: The PCI device associated with the OpenCAPI device
134 * @private: the opaque hardware specific information to assign to the driver
135 */
136void ocxl_afu_set_private(struct ocxl_afu *afu, void *private);
137
138/**
139 * Fetch the hardware specific information associated with an external OpenCAPI
140 * AFU. This may be consumed by an external OpenCAPI driver.
141 *
142 * @afu: The AFU
143 *
144 * Returns the opaque pointer associated with the device, or NULL if not set
145 */
146void *ocxl_afu_get_private(struct ocxl_afu *dev);
147
148
149// Functions left here are for compatibility with the cxlflash driver
58 150
59/* 151/*
60 * Read the configuration space of a function for the AFU specified by 152 * Read the configuration space of a function for the AFU specified by
@@ -142,6 +234,13 @@ int ocxl_config_terminate_pasid(struct pci_dev *dev,
142 int afu_control_offset, int pasid); 234 int afu_control_offset, int pasid);
143 235
144/* 236/*
237 * Read the configuration space of a function and fill in a
238 * ocxl_fn_config structure with all the function details
239 */
240int ocxl_config_read_function(struct pci_dev *dev,
241 struct ocxl_fn_config *fn);
242
243/*
145 * Set up the opencapi link for the function. 244 * Set up the opencapi link for the function.
146 * 245 *
147 * When called for the first time for a link, it sets up the Shared 246 * When called for the first time for a link, it sets up the Shared