xref: /openbmc/linux/drivers/s390/block/scm_blk.h (revision 0c6dfa75)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef SCM_BLK_H
3 #define SCM_BLK_H
4 
5 #include <linux/interrupt.h>
6 #include <linux/spinlock.h>
7 #include <linux/blkdev.h>
8 #include <linux/blk-mq.h>
9 #include <linux/list.h>
10 
11 #include <asm/debug.h>
12 #include <asm/eadm.h>
13 
14 #define SCM_NR_PARTS 8
15 #define SCM_QUEUE_DELAY 5
16 
17 struct scm_blk_dev {
18 	struct request_queue *rq;
19 	struct gendisk *gendisk;
20 	struct blk_mq_tag_set tag_set;
21 	struct scm_device *scmdev;
22 	spinlock_t lock;
23 	atomic_t queued_reqs;
24 	enum {SCM_OPER, SCM_WR_PROHIBIT} state;
25 	struct list_head finished_requests;
26 };
27 
28 struct scm_request {
29 	struct scm_blk_dev *bdev;
30 	struct aidaw *next_aidaw;
31 	struct request **request;
32 	struct aob *aob;
33 	struct list_head list;
34 	u8 retries;
35 	blk_status_t error;
36 };
37 
38 #define to_aobrq(rq) container_of((void *) rq, struct aob_rq_header, data)
39 
40 int scm_blk_dev_setup(struct scm_blk_dev *, struct scm_device *);
41 void scm_blk_dev_cleanup(struct scm_blk_dev *);
42 void scm_blk_set_available(struct scm_blk_dev *);
43 void scm_blk_irq(struct scm_device *, void *, blk_status_t);
44 
45 struct aidaw *scm_aidaw_fetch(struct scm_request *scmrq, unsigned int bytes);
46 
47 int scm_drv_init(void);
48 void scm_drv_cleanup(void);
49 
50 extern debug_info_t *scm_debug;
51 
52 #define SCM_LOG(imp, txt) do {					\
53 		debug_text_event(scm_debug, imp, txt);		\
54 	} while (0)
55 
56 static inline void SCM_LOG_HEX(int level, void *data, int length)
57 {
58 	debug_event(scm_debug, level, data, length);
59 }
60 
61 static inline void SCM_LOG_STATE(int level, struct scm_device *scmdev)
62 {
63 	struct {
64 		u64 address;
65 		u8 oper_state;
66 		u8 rank;
67 	} __packed data = {
68 		.address = scmdev->address,
69 		.oper_state = scmdev->attrs.oper_state,
70 		.rank = scmdev->attrs.rank,
71 	};
72 
73 	SCM_LOG_HEX(level, &data, sizeof(data));
74 }
75 
76 #endif /* SCM_BLK_H */
77