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