ndtest.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef NDTEST_H
  3. #define NDTEST_H
  4. #include <linux/platform_device.h>
  5. #include <linux/libnvdimm.h>
  6. /* SCM device is unable to persist memory contents */
  7. #define PAPR_PMEM_UNARMED (1ULL << (63 - 0))
  8. /* SCM device failed to persist memory contents */
  9. #define PAPR_PMEM_SHUTDOWN_DIRTY (1ULL << (63 - 1))
  10. /* SCM device contents are not persisted from previous IPL */
  11. #define PAPR_PMEM_EMPTY (1ULL << (63 - 3))
  12. #define PAPR_PMEM_HEALTH_CRITICAL (1ULL << (63 - 4))
  13. /* SCM device will be garded off next IPL due to failure */
  14. #define PAPR_PMEM_HEALTH_FATAL (1ULL << (63 - 5))
  15. /* SCM contents cannot persist due to current platform health status */
  16. #define PAPR_PMEM_HEALTH_UNHEALTHY (1ULL << (63 - 6))
  17. /* Bits status indicators for health bitmap indicating unarmed dimm */
  18. #define PAPR_PMEM_UNARMED_MASK (PAPR_PMEM_UNARMED | \
  19. PAPR_PMEM_HEALTH_UNHEALTHY)
  20. #define PAPR_PMEM_SAVE_FAILED (1ULL << (63 - 10))
  21. /* Bits status indicators for health bitmap indicating unflushed dimm */
  22. #define PAPR_PMEM_BAD_SHUTDOWN_MASK (PAPR_PMEM_SHUTDOWN_DIRTY)
  23. /* Bits status indicators for health bitmap indicating unrestored dimm */
  24. #define PAPR_PMEM_BAD_RESTORE_MASK (PAPR_PMEM_EMPTY)
  25. /* Bit status indicators for smart event notification */
  26. #define PAPR_PMEM_SMART_EVENT_MASK (PAPR_PMEM_HEALTH_CRITICAL | \
  27. PAPR_PMEM_HEALTH_FATAL | \
  28. PAPR_PMEM_HEALTH_UNHEALTHY)
  29. #define PAPR_PMEM_SAVE_MASK (PAPR_PMEM_SAVE_FAILED)
  30. struct ndtest_config;
  31. struct ndtest_priv {
  32. struct platform_device pdev;
  33. struct device_node *dn;
  34. struct list_head resources;
  35. struct nvdimm_bus_descriptor bus_desc;
  36. struct nvdimm_bus *bus;
  37. struct ndtest_config *config;
  38. dma_addr_t *dcr_dma;
  39. dma_addr_t *label_dma;
  40. dma_addr_t *dimm_dma;
  41. };
  42. struct ndtest_blk_mmio {
  43. void __iomem *base;
  44. u64 size;
  45. u64 base_offset;
  46. u32 line_size;
  47. u32 num_lines;
  48. u32 table_size;
  49. };
  50. struct ndtest_dimm {
  51. struct device *dev;
  52. struct nvdimm *nvdimm;
  53. struct ndtest_blk_mmio *mmio;
  54. struct nd_region *blk_region;
  55. dma_addr_t address;
  56. unsigned long long flags;
  57. unsigned long config_size;
  58. void *label_area;
  59. char *uuid_str;
  60. unsigned int size;
  61. unsigned int handle;
  62. unsigned int fail_cmd;
  63. unsigned int physical_id;
  64. unsigned int num_formats;
  65. int id;
  66. int fail_cmd_code;
  67. u8 no_alias;
  68. };
  69. struct ndtest_mapping {
  70. u64 start;
  71. u64 size;
  72. u8 position;
  73. u8 dimm;
  74. };
  75. struct ndtest_region {
  76. struct nd_region *region;
  77. struct ndtest_mapping *mapping;
  78. u64 size;
  79. u8 type;
  80. u8 num_mappings;
  81. u8 range_index;
  82. };
  83. struct ndtest_config {
  84. struct ndtest_dimm *dimms;
  85. struct ndtest_region *regions;
  86. unsigned int dimm_count;
  87. unsigned int dimm_start;
  88. u8 num_regions;
  89. };
  90. #endif /* NDTEST_H */