s390/scm: convert tasklet
[linux-2.6-block.git] / drivers / s390 / block / scm_blk.h
CommitLineData
f30664e2
SO
1#ifndef SCM_BLK_H
2#define SCM_BLK_H
3
4#include <linux/interrupt.h>
5#include <linux/spinlock.h>
6#include <linux/blkdev.h>
12d90762 7#include <linux/blk-mq.h>
f30664e2
SO
8#include <linux/genhd.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
17struct scm_blk_dev {
f30664e2
SO
18 struct request_queue *rq;
19 struct gendisk *gendisk;
12d90762 20 struct blk_mq_tag_set tag_set;
f30664e2
SO
21 struct scm_device *scmdev;
22 spinlock_t rq_lock; /* guard the request queue */
23 spinlock_t lock; /* guard the rest of the blockdev */
24 atomic_t queued_reqs;
4fa3c019 25 enum {SCM_OPER, SCM_WR_PROHIBIT} state;
f30664e2
SO
26 struct list_head finished_requests;
27};
28
29struct scm_request {
30 struct scm_blk_dev *bdev;
de88d0d2 31 struct aidaw *next_aidaw;
8622384f 32 struct request **request;
f30664e2
SO
33 struct aob *aob;
34 struct list_head list;
35 u8 retries;
36 int error;
37};
38
39#define to_aobrq(rq) container_of((void *) rq, struct aob_rq_header, data)
40
41int scm_blk_dev_setup(struct scm_blk_dev *, struct scm_device *);
42void scm_blk_dev_cleanup(struct scm_blk_dev *);
4fa3c019 43void scm_blk_set_available(struct scm_blk_dev *);
f30664e2
SO
44void scm_blk_irq(struct scm_device *, void *, int);
45
de88d0d2 46struct aidaw *scm_aidaw_fetch(struct scm_request *scmrq, unsigned int bytes);
9d4df77f 47
f30664e2
SO
48int scm_drv_init(void);
49void scm_drv_cleanup(void);
50
f30664e2
SO
51extern debug_info_t *scm_debug;
52
53#define SCM_LOG(imp, txt) do { \
54 debug_text_event(scm_debug, imp, txt); \
55 } while (0)
56
57static inline void SCM_LOG_HEX(int level, void *data, int length)
58{
8e6a8285 59 if (!debug_level_enabled(scm_debug, level))
f30664e2
SO
60 return;
61 while (length > 0) {
62 debug_event(scm_debug, level, data, length);
63 length -= scm_debug->buf_size;
64 data += scm_debug->buf_size;
65 }
66}
67
68static inline void SCM_LOG_STATE(int level, struct scm_device *scmdev)
69{
70 struct {
71 u64 address;
72 u8 oper_state;
73 u8 rank;
74 } __packed data = {
75 .address = scmdev->address,
76 .oper_state = scmdev->attrs.oper_state,
77 .rank = scmdev->attrs.rank,
78 };
79
80 SCM_LOG_HEX(level, &data, sizeof(data));
81}
82
83#endif /* SCM_BLK_H */