@@ -163,7 +163,8 @@ DK_CXLFLASH_ATTACH
163163
164164 - These tokens are only valid for the process under which they
165165 were created. The child of a forked process cannot continue
166- to use the context id or file descriptor created by its parent.
166+ to use the context id or file descriptor created by its parent
167+ (see DK_CXLFLASH_VLUN_CLONE for further details).
167168
168169 - These tokens are only valid for the lifetime of the context and
169170 the process under which they were created. Once either is
@@ -193,6 +194,45 @@ DK_CXLFLASH_USER_DIRECT
193194 treated as a resource handle that is returned to the user. The user
194195 is then able to use the handle to reference the LUN during I/O.
195196
197+ DK_CXLFLASH_USER_VIRTUAL
198+ ------------------------
199+ This ioctl is responsible for transitioning the LUN to virtual mode
200+ of access and configuring the AFU for virtual access from user space
201+ on a per-context basis. Additionally, the block size and last logical
202+ block address (LBA) are returned to the user.
203+
204+ As mentioned previously, when operating in user space access mode,
205+ LUNs may be accessed in whole or in part. Only one mode is allowed
206+ at a time and if one mode is active (outstanding references exist),
207+ requests to use the LUN in a different mode are denied.
208+
209+ The AFU is configured for virtual access from user space by adding
210+ an entry to the AFU's resource handle table. The index of the entry
211+ is treated as a resource handle that is returned to the user. The
212+ user is then able to use the handle to reference the LUN during I/O.
213+
214+ By default, the virtual LUN is created with a size of 0. The user
215+ would need to use the DK_CXLFLASH_VLUN_RESIZE ioctl to adjust the grow
216+ the virtual LUN to a desired size. To avoid having to perform this
217+ resize for the initial creation of the virtual LUN, the user has the
218+ option of specifying a size as part of the DK_CXLFLASH_USER_VIRTUAL
219+ ioctl, such that when success is returned to the user, the
220+ resource handle that is provided is already referencing provisioned
221+ storage. This is reflected by the last LBA being a non-zero value.
222+
223+ DK_CXLFLASH_VLUN_RESIZE
224+ -----------------------
225+ This ioctl is responsible for resizing a previously created virtual
226+ LUN and will fail if invoked upon a LUN that is not in virtual
227+ mode. Upon success, an updated last LBA is returned to the user
228+ indicating the new size of the virtual LUN associated with the
229+ resource handle.
230+
231+ The partitioning of virtual LUNs is jointly mediated by the cxlflash
232+ driver and the AFU. An allocation table is kept for each LUN that is
233+ operating in the virtual mode and used to program a LUN translation
234+ table that the AFU references when provided with a resource handle.
235+
196236DK_CXLFLASH_RELEASE
197237-------------------
198238 This ioctl is responsible for releasing a previously obtained
@@ -214,6 +254,27 @@ DK_CXLFLASH_DETACH
214254 success, all "tokens" which had been provided to the user from the
215255 DK_CXLFLASH_ATTACH onward are no longer valid.
216256
257+ DK_CXLFLASH_VLUN_CLONE
258+ ----------------------
259+ This ioctl is responsible for cloning a previously created
260+ context to a more recently created context. It exists solely to
261+ support maintaining user space access to storage after a process
262+ forks. Upon success, the child process (which invoked the ioctl)
263+ will have access to the same LUNs via the same resource handle(s)
264+ and fd2 as the parent, but under a different context.
265+
266+ Context sharing across processes is not supported with CXL and
267+ therefore each fork must be met with establishing a new context
268+ for the child process. This ioctl simplifies the state management
269+ and playback required by a user in such a scenario. When a process
270+ forks, child process can clone the parents context by first creating
271+ a context (via DK_CXLFLASH_ATTACH) and then using this ioctl to
272+ perform the clone from the parent to the child.
273+
274+ The clone itself is fairly simple. The resource handle and lun
275+ translation tables are copied from the parent context to the child's
276+ and then synced with the AFU.
277+
217278DK_CXLFLASH_VERIFY
218279------------------
219280 This ioctl is used to detect various changes such as the capacity of
0 commit comments