scm_blk.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef SCM_BLK_H
  2. #define SCM_BLK_H
  3. #include <linux/interrupt.h>
  4. #include <linux/spinlock.h>
  5. #include <linux/blkdev.h>
  6. #include <linux/genhd.h>
  7. #include <linux/list.h>
  8. #include <asm/debug.h>
  9. #include <asm/eadm.h>
  10. #define SCM_NR_PARTS 8
  11. #define SCM_QUEUE_DELAY 5
  12. struct scm_blk_dev {
  13. struct tasklet_struct tasklet;
  14. struct request_queue *rq;
  15. struct gendisk *gendisk;
  16. struct scm_device *scmdev;
  17. spinlock_t rq_lock; /* guard the request queue */
  18. spinlock_t lock; /* guard the rest of the blockdev */
  19. atomic_t queued_reqs;
  20. struct list_head finished_requests;
  21. };
  22. struct scm_request {
  23. struct scm_blk_dev *bdev;
  24. struct request *request;
  25. struct aidaw *aidaw;
  26. struct aob *aob;
  27. struct list_head list;
  28. u8 retries;
  29. int error;
  30. };
  31. #define to_aobrq(rq) container_of((void *) rq, struct aob_rq_header, data)
  32. int scm_blk_dev_setup(struct scm_blk_dev *, struct scm_device *);
  33. void scm_blk_dev_cleanup(struct scm_blk_dev *);
  34. void scm_blk_irq(struct scm_device *, void *, int);
  35. int scm_drv_init(void);
  36. void scm_drv_cleanup(void);
  37. extern debug_info_t *scm_debug;
  38. #define SCM_LOG(imp, txt) do { \
  39. debug_text_event(scm_debug, imp, txt); \
  40. } while (0)
  41. static inline void SCM_LOG_HEX(int level, void *data, int length)
  42. {
  43. if (level > scm_debug->level)
  44. return;
  45. while (length > 0) {
  46. debug_event(scm_debug, level, data, length);
  47. length -= scm_debug->buf_size;
  48. data += scm_debug->buf_size;
  49. }
  50. }
  51. static inline void SCM_LOG_STATE(int level, struct scm_device *scmdev)
  52. {
  53. struct {
  54. u64 address;
  55. u8 oper_state;
  56. u8 rank;
  57. } __packed data = {
  58. .address = scmdev->address,
  59. .oper_state = scmdev->attrs.oper_state,
  60. .rank = scmdev->attrs.rank,
  61. };
  62. SCM_LOG_HEX(level, &data, sizeof(data));
  63. }
  64. #endif /* SCM_BLK_H */