scm_blk.h 1.7 KB

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