1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _CXLFLASH_SUPERPIPE_H
16#define _CXLFLASH_SUPERPIPE_H
17
18extern struct cxlflash_global global;
19
20
21
22
23
24
25
26
27
28
29#define MC_CHUNK_SIZE (1 << MC_RHT_NMASK)
30
31#define CMD_TIMEOUT 30
32#define CMD_RETRIES 5
33
34#define MAX_SECTOR_UNIT 512
35
36#define CHAN2PORT(_x) ((_x) + 1)
37#define PORT2CHAN(_x) ((_x) - 1)
38
39enum lun_mode {
40 MODE_NONE = 0,
41 MODE_VIRTUAL,
42 MODE_PHYSICAL
43};
44
45
46struct glun_info {
47 u64 max_lba;
48 u32 blk_len;
49 enum lun_mode mode;
50 int users;
51
52 u8 wwid[16];
53
54 struct mutex mutex;
55
56 struct blka blka;
57 struct list_head list;
58};
59
60
61struct llun_info {
62 u64 lun_id[CXLFLASH_NUM_FC_PORTS];
63 u32 lun_index;
64 u32 host_no;
65 u32 port_sel;
66 bool in_table;
67
68 u8 wwid[16];
69
70 struct glun_info *parent;
71 struct scsi_device *sdev;
72 struct list_head list;
73};
74
75struct lun_access {
76 struct llun_info *lli;
77 struct scsi_device *sdev;
78 struct list_head list;
79};
80
81enum ctx_ctrl {
82 CTX_CTRL_CLONE = (1 << 1),
83 CTX_CTRL_ERR = (1 << 2),
84 CTX_CTRL_ERR_FALLBACK = (1 << 3),
85 CTX_CTRL_NOPID = (1 << 4),
86 CTX_CTRL_FILE = (1 << 5)
87};
88
89#define ENCODE_CTXID(_ctx, _id) (((((u64)_ctx) & 0xFFFFFFFF0ULL) << 28) | _id)
90#define DECODE_CTXID(_val) (_val & 0xFFFFFFFF)
91
92struct ctx_info {
93 struct sisl_ctrl_map __iomem *ctrl_map;
94 struct sisl_rht_entry *rht_start;
95
96 u32 rht_out;
97 u32 rht_perms;
98 struct llun_info **rht_lun;
99 u8 *rht_needs_ws;
100
101 struct cxl_ioctl_start_work work;
102 u64 ctxid;
103 pid_t pid;
104 bool initialized;
105 bool unavail;
106 bool err_recovery_active;
107 struct mutex mutex;
108 struct kref kref;
109 struct cxl_context *ctx;
110 struct cxlflash_cfg *cfg;
111 struct list_head luns;
112 const struct vm_operations_struct *cxl_mmap_vmops;
113 struct file *file;
114 struct list_head list;
115};
116
117struct cxlflash_global {
118 struct mutex mutex;
119 struct list_head gluns;
120 struct page *err_page;
121};
122
123int cxlflash_vlun_resize(struct scsi_device *, struct dk_cxlflash_resize *);
124int _cxlflash_vlun_resize(struct scsi_device *, struct ctx_info *,
125 struct dk_cxlflash_resize *);
126
127int cxlflash_disk_release(struct scsi_device *, struct dk_cxlflash_release *);
128int _cxlflash_disk_release(struct scsi_device *, struct ctx_info *,
129 struct dk_cxlflash_release *);
130
131int cxlflash_disk_clone(struct scsi_device *, struct dk_cxlflash_clone *);
132
133int cxlflash_disk_virtual_open(struct scsi_device *, void *);
134
135int cxlflash_lun_attach(struct glun_info *, enum lun_mode, bool);
136void cxlflash_lun_detach(struct glun_info *);
137
138struct ctx_info *get_context(struct cxlflash_cfg *, u64, void *, enum ctx_ctrl);
139void put_context(struct ctx_info *);
140
141struct sisl_rht_entry *get_rhte(struct ctx_info *, res_hndl_t,
142 struct llun_info *);
143
144struct sisl_rht_entry *rhte_checkout(struct ctx_info *, struct llun_info *);
145void rhte_checkin(struct ctx_info *, struct sisl_rht_entry *);
146
147void cxlflash_ba_terminate(struct ba_lun *);
148
149int cxlflash_manage_lun(struct scsi_device *, struct dk_cxlflash_manage_lun *);
150
151int check_state(struct cxlflash_cfg *);
152
153#endif
154