Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 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> |
Sebastian Ott | 12d9076 | 2017-01-25 16:18:53 +0100 | [diff] [blame^] | 7 | #include <linux/blk-mq.h> |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 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 | |
| 17 | struct scm_blk_dev { |
| 18 | struct tasklet_struct tasklet; |
| 19 | struct request_queue *rq; |
| 20 | struct gendisk *gendisk; |
Sebastian Ott | 12d9076 | 2017-01-25 16:18:53 +0100 | [diff] [blame^] | 21 | struct blk_mq_tag_set tag_set; |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 22 | struct scm_device *scmdev; |
| 23 | spinlock_t rq_lock; /* guard the request queue */ |
| 24 | spinlock_t lock; /* guard the rest of the blockdev */ |
| 25 | atomic_t queued_reqs; |
Sebastian Ott | 4fa3c01 | 2013-02-28 12:07:48 +0100 | [diff] [blame] | 26 | enum {SCM_OPER, SCM_WR_PROHIBIT} state; |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 27 | struct list_head finished_requests; |
| 28 | }; |
| 29 | |
| 30 | struct scm_request { |
| 31 | struct scm_blk_dev *bdev; |
Sebastian Ott | de88d0d | 2014-12-05 16:41:47 +0100 | [diff] [blame] | 32 | struct aidaw *next_aidaw; |
Sebastian Ott | 8622384 | 2014-12-05 16:47:17 +0100 | [diff] [blame] | 33 | struct request **request; |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 34 | struct aob *aob; |
| 35 | struct list_head list; |
| 36 | u8 retries; |
| 37 | int error; |
| 38 | }; |
| 39 | |
| 40 | #define to_aobrq(rq) container_of((void *) rq, struct aob_rq_header, data) |
| 41 | |
| 42 | int scm_blk_dev_setup(struct scm_blk_dev *, struct scm_device *); |
| 43 | void scm_blk_dev_cleanup(struct scm_blk_dev *); |
Sebastian Ott | 4fa3c01 | 2013-02-28 12:07:48 +0100 | [diff] [blame] | 44 | void scm_blk_set_available(struct scm_blk_dev *); |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 45 | void scm_blk_irq(struct scm_device *, void *, int); |
| 46 | |
Sebastian Ott | de88d0d | 2014-12-05 16:41:47 +0100 | [diff] [blame] | 47 | struct aidaw *scm_aidaw_fetch(struct scm_request *scmrq, unsigned int bytes); |
Sebastian Ott | 9d4df77 | 2014-12-05 16:32:13 +0100 | [diff] [blame] | 48 | |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 49 | int scm_drv_init(void); |
| 50 | void scm_drv_cleanup(void); |
| 51 | |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 52 | extern debug_info_t *scm_debug; |
| 53 | |
| 54 | #define SCM_LOG(imp, txt) do { \ |
| 55 | debug_text_event(scm_debug, imp, txt); \ |
| 56 | } while (0) |
| 57 | |
| 58 | static inline void SCM_LOG_HEX(int level, void *data, int length) |
| 59 | { |
Hendrik Brueckner | 8e6a828 | 2013-09-18 17:21:34 +0200 | [diff] [blame] | 60 | if (!debug_level_enabled(scm_debug, level)) |
Sebastian Ott | f30664e | 2012-08-28 16:50:38 +0200 | [diff] [blame] | 61 | return; |
| 62 | while (length > 0) { |
| 63 | debug_event(scm_debug, level, data, length); |
| 64 | length -= scm_debug->buf_size; |
| 65 | data += scm_debug->buf_size; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | static inline void SCM_LOG_STATE(int level, struct scm_device *scmdev) |
| 70 | { |
| 71 | struct { |
| 72 | u64 address; |
| 73 | u8 oper_state; |
| 74 | u8 rank; |
| 75 | } __packed data = { |
| 76 | .address = scmdev->address, |
| 77 | .oper_state = scmdev->attrs.oper_state, |
| 78 | .rank = scmdev->attrs.rank, |
| 79 | }; |
| 80 | |
| 81 | SCM_LOG_HEX(level, &data, sizeof(data)); |
| 82 | } |
| 83 | |
| 84 | #endif /* SCM_BLK_H */ |