0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _CXLFLASH_SUPERPIPE_H
0012 #define _CXLFLASH_SUPERPIPE_H
0013
0014 extern struct cxlflash_global global;
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #define MC_CHUNK_SIZE (1 << MC_RHT_NMASK)
0026
0027 #define CMD_TIMEOUT 30
0028 #define CMD_RETRIES 5
0029
0030 #define MAX_SECTOR_UNIT 512
0031
0032 enum lun_mode {
0033 MODE_NONE = 0,
0034 MODE_VIRTUAL,
0035 MODE_PHYSICAL
0036 };
0037
0038
0039 struct glun_info {
0040 u64 max_lba;
0041 u32 blk_len;
0042 enum lun_mode mode;
0043 int users;
0044
0045 u8 wwid[16];
0046
0047 struct mutex mutex;
0048
0049 struct blka blka;
0050 struct list_head list;
0051 };
0052
0053
0054 struct llun_info {
0055 u64 lun_id[MAX_FC_PORTS];
0056 u32 lun_index;
0057 u32 host_no;
0058 u32 port_sel;
0059 bool in_table;
0060
0061 u8 wwid[16];
0062
0063 struct glun_info *parent;
0064 struct scsi_device *sdev;
0065 struct list_head list;
0066 };
0067
0068 struct lun_access {
0069 struct llun_info *lli;
0070 struct scsi_device *sdev;
0071 struct list_head list;
0072 };
0073
0074 enum ctx_ctrl {
0075 CTX_CTRL_CLONE = (1 << 1),
0076 CTX_CTRL_ERR = (1 << 2),
0077 CTX_CTRL_ERR_FALLBACK = (1 << 3),
0078 CTX_CTRL_NOPID = (1 << 4),
0079 CTX_CTRL_FILE = (1 << 5)
0080 };
0081
0082 #define ENCODE_CTXID(_ctx, _id) (((((u64)_ctx) & 0xFFFFFFFF0ULL) << 28) | _id)
0083 #define DECODE_CTXID(_val) (_val & 0xFFFFFFFF)
0084
0085 struct ctx_info {
0086 struct sisl_ctrl_map __iomem *ctrl_map;
0087 struct sisl_rht_entry *rht_start;
0088
0089
0090 u32 rht_out;
0091 u32 rht_perms;
0092 struct llun_info **rht_lun;
0093 u8 *rht_needs_ws;
0094
0095 u64 ctxid;
0096 u64 irqs;
0097 pid_t pid;
0098 bool initialized;
0099 bool unavail;
0100 bool err_recovery_active;
0101 struct mutex mutex;
0102 struct kref kref;
0103 void *ctx;
0104 struct cxlflash_cfg *cfg;
0105 struct list_head luns;
0106 const struct vm_operations_struct *cxl_mmap_vmops;
0107 struct file *file;
0108 struct list_head list;
0109 };
0110
0111 struct cxlflash_global {
0112 struct mutex mutex;
0113 struct list_head gluns;
0114 struct page *err_page;
0115 };
0116
0117 int cxlflash_vlun_resize(struct scsi_device *sdev,
0118 struct dk_cxlflash_resize *resize);
0119 int _cxlflash_vlun_resize(struct scsi_device *sdev, struct ctx_info *ctxi,
0120 struct dk_cxlflash_resize *resize);
0121
0122 int cxlflash_disk_release(struct scsi_device *sdev,
0123 struct dk_cxlflash_release *release);
0124 int _cxlflash_disk_release(struct scsi_device *sdev, struct ctx_info *ctxi,
0125 struct dk_cxlflash_release *release);
0126
0127 int cxlflash_disk_clone(struct scsi_device *sdev,
0128 struct dk_cxlflash_clone *clone);
0129
0130 int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg);
0131
0132 int cxlflash_lun_attach(struct glun_info *gli, enum lun_mode mode, bool locked);
0133 void cxlflash_lun_detach(struct glun_info *gli);
0134
0135 struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxit, void *arg,
0136 enum ctx_ctrl ctrl);
0137 void put_context(struct ctx_info *ctxi);
0138
0139 struct sisl_rht_entry *get_rhte(struct ctx_info *ctxi, res_hndl_t rhndl,
0140 struct llun_info *lli);
0141
0142 struct sisl_rht_entry *rhte_checkout(struct ctx_info *ctxi,
0143 struct llun_info *lli);
0144 void rhte_checkin(struct ctx_info *ctxi, struct sisl_rht_entry *rhte);
0145
0146 void cxlflash_ba_terminate(struct ba_lun *ba_lun);
0147
0148 int cxlflash_manage_lun(struct scsi_device *sdev,
0149 struct dk_cxlflash_manage_lun *manage);
0150
0151 int check_state(struct cxlflash_cfg *cfg);
0152
0153 #endif