^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * CXL Flash Device Driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Written by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>, IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Matthew R. Ochs <mrochs@linux.vnet.ibm.com>, IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (C) 2015 IBM Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * modify it under the terms of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * as published by the Free Software Foundation; either version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * 2 of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #ifndef _CXLFLASH_IOCTL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define _CXLFLASH_IOCTL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Structure and definitions for all CXL Flash ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #define CXLFLASH_WWID_LEN 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * Structure and flag definitions CXL Flash superpipe ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define DK_CXLFLASH_VERSION_0 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct dk_cxlflash_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) __u16 version; /* Version data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __u16 rsvd[3]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __u64 flags; /* Input flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __u64 return_flags; /* Returned flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Return flag definitions available to all superpipe ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * Similar to the input flags, these are grown from the bottom-up with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * intention that ioctl-specific return flag definitions would grow from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * top-down, allowing the two sets to co-exist. While not required/enforced
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * at this time, this provides future flexibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define DK_CXLFLASH_ALL_PORTS_ACTIVE 0x0000000000000001ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define DK_CXLFLASH_APP_CLOSE_ADAP_FD 0x0000000000000002ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #define DK_CXLFLASH_CONTEXT_SQ_CMD_MODE 0x0000000000000004ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * General Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * -------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * The 'context_id' field of all ioctl structures contains the context
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * identifier for a context in the lower 32-bits (upper 32-bits are not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * to be used when identifying a context to the AFU). That said, the value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * in its entirety (all 64-bits) is to be treated as an opaque cookie and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * should be presented as such when issuing ioctls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * DK_CXLFLASH_ATTACH Notes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * ------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * Read/write access permissions are specified via the O_RDONLY, O_WRONLY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * and O_RDWR flags defined in the fcntl.h header file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * A valid adapter file descriptor (fd >= 0) is only returned on the initial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * attach (successful) of a context. When a context is shared(reused), the user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * is expected to already 'know' the adapter file descriptor associated with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define DK_CXLFLASH_ATTACH_REUSE_CONTEXT 0x8000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct dk_cxlflash_attach {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __u64 num_interrupts; /* Requested number of interrupts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) __u64 context_id; /* Returned context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) __u64 mmio_size; /* Returned size of MMIO area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) __u64 block_size; /* Returned block size, in bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) __u64 adap_fd; /* Returned adapter file descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) __u64 last_lba; /* Returned last LBA on the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) __u64 max_xfer; /* Returned max transfer size, blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct dk_cxlflash_detach {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) __u64 context_id; /* Context to detach */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct dk_cxlflash_udirect {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) __u64 context_id; /* Context to own physical resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) __u64 rsrc_handle; /* Returned resource handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) __u64 last_lba; /* Returned last LBA on the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #define DK_CXLFLASH_UVIRTUAL_NEED_WRITE_SAME 0x8000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct dk_cxlflash_uvirtual {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) __u64 context_id; /* Context to own virtual resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) __u64 lun_size; /* Requested size, in 4K blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) __u64 rsrc_handle; /* Returned resource handle */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) __u64 last_lba; /* Returned last LBA of LUN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) struct dk_cxlflash_release {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) __u64 context_id; /* Context owning resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) __u64 rsrc_handle; /* Resource handle to release */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct dk_cxlflash_resize {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) __u64 context_id; /* Context owning resources */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) __u64 rsrc_handle; /* Resource handle of LUN to resize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) __u64 req_size; /* New requested size, in 4K blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) __u64 last_lba; /* Returned last LBA of LUN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct dk_cxlflash_clone {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) __u64 context_id_src; /* Context to clone from */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) __u64 context_id_dst; /* Context to clone to */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) __u64 adap_fd_src; /* Source context adapter fd */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define DK_CXLFLASH_VERIFY_SENSE_LEN 18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #define DK_CXLFLASH_VERIFY_HINT_SENSE 0x8000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct dk_cxlflash_verify {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) __u64 context_id; /* Context owning resources to verify */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) __u64 rsrc_handle; /* Resource handle of LUN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) __u64 hint; /* Reasons for verify */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) __u64 last_lba; /* Returned last LBA of device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) __u8 sense_data[DK_CXLFLASH_VERIFY_SENSE_LEN]; /* SCSI sense data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) __u8 pad[6]; /* Pad to next 8-byte boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #define DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET 0x8000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct dk_cxlflash_recover_afu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) __u64 reason; /* Reason for recovery request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) __u64 context_id; /* Context to recover / updated ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) __u64 mmio_size; /* Returned size of MMIO area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) __u64 adap_fd; /* Returned adapter file descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) #define DK_CXLFLASH_MANAGE_LUN_WWID_LEN CXLFLASH_WWID_LEN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #define DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE 0x8000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) #define DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE 0x4000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #define DK_CXLFLASH_MANAGE_LUN_ALL_PORTS_ACCESSIBLE 0x2000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct dk_cxlflash_manage_lun {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct dk_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) __u8 wwid[DK_CXLFLASH_MANAGE_LUN_WWID_LEN]; /* Page83 WWID, NAA-6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) __u64 reserved[8]; /* Rsvd, future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) union cxlflash_ioctls {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct dk_cxlflash_attach attach;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct dk_cxlflash_detach detach;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct dk_cxlflash_udirect udirect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct dk_cxlflash_uvirtual uvirtual;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct dk_cxlflash_release release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct dk_cxlflash_resize resize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct dk_cxlflash_clone clone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) struct dk_cxlflash_verify verify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct dk_cxlflash_recover_afu recover_afu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) struct dk_cxlflash_manage_lun manage_lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #define MAX_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ioctls))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) #define CXL_MAGIC 0xCA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) #define CXL_IOWR(_n, _s) _IOWR(CXL_MAGIC, _n, struct _s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) * CXL Flash superpipe ioctls start at base of the reserved CXL_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) * region (0x80) and grow upwards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) #define DK_CXLFLASH_ATTACH CXL_IOWR(0x80, dk_cxlflash_attach)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) #define DK_CXLFLASH_USER_DIRECT CXL_IOWR(0x81, dk_cxlflash_udirect)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #define DK_CXLFLASH_RELEASE CXL_IOWR(0x82, dk_cxlflash_release)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #define DK_CXLFLASH_DETACH CXL_IOWR(0x83, dk_cxlflash_detach)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #define DK_CXLFLASH_VERIFY CXL_IOWR(0x84, dk_cxlflash_verify)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) #define DK_CXLFLASH_RECOVER_AFU CXL_IOWR(0x85, dk_cxlflash_recover_afu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define DK_CXLFLASH_MANAGE_LUN CXL_IOWR(0x86, dk_cxlflash_manage_lun)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define DK_CXLFLASH_USER_VIRTUAL CXL_IOWR(0x87, dk_cxlflash_uvirtual)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) #define DK_CXLFLASH_VLUN_RESIZE CXL_IOWR(0x88, dk_cxlflash_resize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) #define DK_CXLFLASH_VLUN_CLONE CXL_IOWR(0x89, dk_cxlflash_clone)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * Structure and flag definitions CXL Flash host ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) #define HT_CXLFLASH_VERSION_0 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct ht_cxlflash_hdr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) __u16 version; /* Version data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) __u16 subcmd; /* Sub-command */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) __u16 rsvd[2]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) __u64 flags; /* Input flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) __u64 return_flags; /* Returned flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) * Input flag definitions available to all host ioctls
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) * These are grown from the bottom-up with the intention that ioctl-specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) * input flag definitions would grow from the top-down, allowing the two sets
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) * to co-exist. While not required/enforced at this time, this provides future
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) * flexibility.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) #define HT_CXLFLASH_HOST_READ 0x0000000000000000ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #define HT_CXLFLASH_HOST_WRITE 0x0000000000000001ULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_CREATE_LUN 0x0001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_DELETE_LUN 0x0002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) #define HT_CXLFLASH_LUN_PROVISION_SUBCMD_QUERY_PORT 0x0003
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct ht_cxlflash_lun_provision {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) struct ht_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) __u16 port; /* Target port for provision request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) __u16 reserved16[3]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) __u64 size; /* Size of LUN (4K blocks) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) __u64 lun_id; /* SCSI LUN ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) __u8 wwid[CXLFLASH_WWID_LEN];/* Page83 WWID, NAA-6 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) __u64 max_num_luns; /* Maximum number of LUNs provisioned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) __u64 cur_num_luns; /* Current number of LUNs provisioned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) __u64 max_cap_port; /* Total capacity for port (4K blocks) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) __u64 cur_cap_port; /* Current capacity for port (4K blocks) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) #define HT_CXLFLASH_AFU_DEBUG_MAX_DATA_LEN 262144 /* 256K */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) #define HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) struct ht_cxlflash_afu_debug {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) struct ht_cxlflash_hdr hdr; /* Common fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) __u8 reserved8[4]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) __u8 afu_subcmd[HT_CXLFLASH_AFU_DEBUG_SUBCMD_LEN]; /* AFU subcommand,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) * (pass through)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) __u64 data_ea; /* Data buffer effective address */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) __u32 data_len; /* Data buffer length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) __u32 reserved32; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) __u64 reserved[8]; /* Reserved for future use */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) union cxlflash_ht_ioctls {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct ht_cxlflash_lun_provision lun_provision;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct ht_cxlflash_afu_debug afu_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) #define MAX_HT_CXLFLASH_IOCTL_SZ (sizeof(union cxlflash_ht_ioctls))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * CXL Flash host ioctls start at the top of the reserved CXL_MAGIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) * region (0xBF) and grow downwards.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) #define HT_CXLFLASH_LUN_PROVISION CXL_IOWR(0xBF, ht_cxlflash_lun_provision)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) #define HT_CXLFLASH_AFU_DEBUG CXL_IOWR(0xBE, ht_cxlflash_afu_debug)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) #endif /* ifndef _CXLFLASH_IOCTL_H */