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