2 * CXL Flash Device Driver
4 * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
5 * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
7 * Copyright (C) 2015 IBM Corporation
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
15 #ifndef _CXLFLASH_IOCTL_H
16 #define _CXLFLASH_IOCTL_H
18 #include <linux/types.h>
21 * Structure and flag definitions CXL Flash superpipe ioctls
24 #define DK_CXLFLASH_VERSION_0 0
26 struct dk_cxlflash_hdr
{
27 __u16 version
; /* Version data */
28 __u16 rsvd
[3]; /* Reserved for future use */
29 __u64 flags
; /* Input flags */
30 __u64 return_flags
; /* Returned flags */
36 * The 'context_id' field of all ioctl structures contains the context
37 * identifier for a context in the lower 32-bits (upper 32-bits are not
38 * to be used when identifying a context to the AFU). That said, the value
39 * in its entirety (all 64-bits) is to be treated as an opaque cookie and
40 * should be presented as such when issuing ioctls.
42 * For DK_CXLFLASH_ATTACH ioctl, user specifies read/write access
43 * permissions via the O_RDONLY, O_WRONLY, and O_RDWR flags defined in
44 * the fcntl.h header file.
46 #define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
48 struct dk_cxlflash_attach
{
49 struct dk_cxlflash_hdr hdr
; /* Common fields */
50 __u64 num_interrupts
; /* Requested number of interrupts */
51 __u64 context_id
; /* Returned context */
52 __u64 mmio_size
; /* Returned size of MMIO area */
53 __u64 block_size
; /* Returned block size, in bytes */
54 __u64 adap_fd
; /* Returned adapter file descriptor */
55 __u64 last_lba
; /* Returned last LBA on the device */
56 __u64 max_xfer
; /* Returned max transfer size, blocks */
57 __u64 reserved
[8]; /* Reserved for future use */
60 struct dk_cxlflash_detach
{
61 struct dk_cxlflash_hdr hdr
; /* Common fields */
62 __u64 context_id
; /* Context to detach */
63 __u64 reserved
[8]; /* Reserved for future use */
66 struct dk_cxlflash_udirect
{
67 struct dk_cxlflash_hdr hdr
; /* Common fields */
68 __u64 context_id
; /* Context to own physical resources */
69 __u64 rsrc_handle
; /* Returned resource handle */
70 __u64 last_lba
; /* Returned last LBA on the device */
71 __u64 reserved
[8]; /* Reserved for future use */
74 struct dk_cxlflash_release
{
75 struct dk_cxlflash_hdr hdr
; /* Common fields */
76 __u64 context_id
; /* Context owning resources */
77 __u64 rsrc_handle
; /* Resource handle to release */
78 __u64 reserved
[8]; /* Reserved for future use */
81 #define DK_CXLFLASH_VERIFY_SENSE_LEN 18
82 #define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
84 struct dk_cxlflash_verify
{
85 struct dk_cxlflash_hdr hdr
; /* Common fields */
86 __u64 context_id
; /* Context owning resources to verify */
87 __u64 rsrc_handle
; /* Resource handle of LUN */
88 __u64 hint
; /* Reasons for verify */
89 __u64 last_lba
; /* Returned last LBA of device */
90 __u8 sense_data
[DK_CXLFLASH_VERIFY_SENSE_LEN
]; /* SCSI sense data */
91 __u8 pad
[6]; /* Pad to next 8-byte boundary */
92 __u64 reserved
[8]; /* Reserved for future use */
95 #define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
97 struct dk_cxlflash_recover_afu
{
98 struct dk_cxlflash_hdr hdr
; /* Common fields */
99 __u64 reason
; /* Reason for recovery request */
100 __u64 context_id
; /* Context to recover / updated ID */
101 __u64 mmio_size
; /* Returned size of MMIO area */
102 __u64 adap_fd
; /* Returned adapter file descriptor */
103 __u64 reserved
[8]; /* Reserved for future use */
106 #define DK_CXLFLASH_MANAGE_LUN_WWID_LEN 16
107 #define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
108 #define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
109 #define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
111 struct dk_cxlflash_manage_lun
{
112 struct dk_cxlflash_hdr hdr
; /* Common fields */
113 __u8 wwid
[DK_CXLFLASH_MANAGE_LUN_WWID_LEN
]; /* Page83 WWID, NAA-6 */
114 __u64 reserved
[8]; /* Rsvd, future use */
117 union cxlflash_ioctls
{
118 struct dk_cxlflash_attach attach
;
119 struct dk_cxlflash_detach detach
;
120 struct dk_cxlflash_udirect udirect
;
121 struct dk_cxlflash_release release
;
122 struct dk_cxlflash_verify verify
;
123 struct dk_cxlflash_recover_afu recover_afu
;
124 struct dk_cxlflash_manage_lun manage_lun
;
127 #define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
129 #define CXL_MAGIC 0xCA
130 #define CXL_IOWR(_n, _s) _IOWR(CXL_MAGIC, _n, struct _s)
132 #define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
133 #define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
134 #define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
135 #define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
136 #define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
137 #define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
138 #define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
140 #endif /* ifndef _CXLFLASH_IOCTL_H */