scm_blk.h 1.7 KB

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