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
36enum lun_mode {
37 MODE_NONE = 0,
38 MODE_VIRTUAL,
39 MODE_PHYSICAL
40};
41
42
43struct glun_info {
44 u64 max_lba;
45 u32 blk_len;
46 enum lun_mode mode;
47 int users;
48
49 u8 wwid[16];
50
51 struct mutex mutex;
52
53 struct blka blka;
54 struct list_head list;
55};
56
57
58struct llun_info {
59 u64 lun_id[MAX_FC_PORTS];
60 u32 lun_index;
61 u32 host_no;
62 u32 port_sel;
63 bool in_table;
64
65 u8 wwid[16];
66
67 struct glun_info *parent;
68 struct scsi_device *sdev;
69 struct list_head list;
70};
71
72struct lun_access {
73 struct llun_info *lli;
74 struct scsi_device *sdev;
75 struct list_head list;
76};
77
78enum ctx_ctrl {
79 CTX_CTRL_CLONE = (1 << 1),
80 CTX_CTRL_ERR = (1 << 2),
81 CTX_CTRL_ERR_FALLBACK = (1 << 3),
82 CTX_CTRL_NOPID = (1 << 4),
83 CTX_CTRL_FILE = (1 << 5)
84};
85
86#define ENCODE_CTXID(_ctx, _id) (((((u64)_ctx) & 0xFFFFFFFF0ULL) << 28) | _id)
87#define DECODE_CTXID(_val) (_val & 0xFFFFFFFF)
88
89struct ctx_info {
90 struct sisl_ctrl_map __iomem *ctrl_map;
91 struct sisl_rht_entry *rht_start;
92
93
94 u32 rht_out;
95 u32 rht_perms;
96 struct llun_info **rht_lun;
97 u8 *rht_needs_ws;
98
99 u64 ctxid;
100 u64 irqs;
101 pid_t pid;
102 bool initialized;
103 bool unavail;
104 bool err_recovery_active;
105 struct mutex mutex;
106 struct kref kref;
107 void *ctx;
108 struct cxlflash_cfg *cfg;
109 struct list_head luns;
110 const struct vm_operations_struct *cxl_mmap_vmops;
111 struct file *file;
112 struct list_head list;
113};
114
115struct cxlflash_global {
116 struct mutex mutex;
117 struct list_head gluns;
118 struct page *err_page;
119};
120
121int cxlflash_vlun_resize(struct scsi_device *sdev,
122 struct dk_cxlflash_resize *resize);
123int _cxlflash_vlun_resize(struct scsi_device *sdev, struct ctx_info *ctxi,
124 struct dk_cxlflash_resize *resize);
125
126int cxlflash_disk_release(struct scsi_device *sdev,
127 struct dk_cxlflash_release *release);
128int _cxlflash_disk_release(struct scsi_device *sdev, struct ctx_info *ctxi,
129 struct dk_cxlflash_release *release);
130
131int cxlflash_disk_clone(struct scsi_device *sdev,
132 struct dk_cxlflash_clone *clone);
133
134int cxlflash_disk_virtual_open(struct scsi_device *sdev, void *arg);
135
136int cxlflash_lun_attach(struct glun_info *gli, enum lun_mode mode, bool locked);
137void cxlflash_lun_detach(struct glun_info *gli);
138
139struct ctx_info *get_context(struct cxlflash_cfg *cfg, u64 rctxit, void *arg,
140 enum ctx_ctrl ctrl);
141void put_context(struct ctx_info *ctxi);
142
143struct sisl_rht_entry *get_rhte(struct ctx_info *ctxi, res_hndl_t rhndl,
144 struct llun_info *lli);
145
146struct sisl_rht_entry *rhte_checkout(struct ctx_info *ctxi,
147 struct llun_info *lli);
148void rhte_checkin(struct ctx_info *ctxi, struct sisl_rht_entry *rhte);
149
150void cxlflash_ba_terminate(struct ba_lun *ba_lun);
151
152int cxlflash_manage_lun(struct scsi_device *sdev,
153 struct dk_cxlflash_manage_lun *manage);
154
155int check_state(struct cxlflash_cfg *cfg);
156
157#endif
158