pstore_blk.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __PSTORE_BLK_H_
  3. #define __PSTORE_BLK_H_
  4. #include <linux/types.h>
  5. #include <linux/pstore.h>
  6. #include <linux/pstore_zone.h>
  7. /**
  8. * typedef pstore_blk_panic_write_op - panic write operation to block device
  9. *
  10. * @buf: the data to write
  11. * @start_sect: start sector to block device
  12. * @sects: sectors count on buf
  13. *
  14. * Return: On success, zero should be returned. Others excluding -ENOMSG
  15. * mean error. -ENOMSG means to try next zone.
  16. *
  17. * Panic write to block device must be aligned to SECTOR_SIZE.
  18. */
  19. typedef int (*pstore_blk_panic_write_op)(const char *buf, sector_t start_sect,
  20. sector_t sects);
  21. /**
  22. * struct pstore_blk_info - pstore/blk registration details
  23. *
  24. * @major: Which major device number to support with pstore/blk
  25. * @flags: The supported PSTORE_FLAGS_* from linux/pstore.h.
  26. * @panic_write:The write operation only used for the panic case.
  27. * This can be NULL, but is recommended to avoid losing
  28. * crash data if the kernel's IO path or work queues are
  29. * broken during a panic.
  30. * @devt: The dev_t that pstore/blk has attached to.
  31. * @nr_sects: Number of sectors on @devt.
  32. * @start_sect: Starting sector on @devt.
  33. */
  34. struct pstore_blk_info {
  35. unsigned int major;
  36. unsigned int flags;
  37. pstore_blk_panic_write_op panic_write;
  38. /* Filled in by pstore/blk after registration. */
  39. dev_t devt;
  40. sector_t nr_sects;
  41. sector_t start_sect;
  42. };
  43. int register_pstore_blk(struct pstore_blk_info *info);
  44. void unregister_pstore_blk(unsigned int major);
  45. /**
  46. * struct pstore_device_info - back-end pstore/blk driver structure.
  47. *
  48. * @total_size: The total size in bytes pstore/blk can use. It must be greater
  49. * than 4096 and be multiple of 4096.
  50. * @flags: Refer to macro starting with PSTORE_FLAGS defined in
  51. * linux/pstore.h. It means what front-ends this device support.
  52. * Zero means all backends for compatible.
  53. * @read: The general read operation. Both of the function parameters
  54. * @size and @offset are relative value to bock device (not the
  55. * whole disk).
  56. * On success, the number of bytes should be returned, others
  57. * means error.
  58. * @write: The same as @read, but the following error number:
  59. * -EBUSY means try to write again later.
  60. * -ENOMSG means to try next zone.
  61. * @erase: The general erase operation for device with special removing
  62. * job. Both of the function parameters @size and @offset are
  63. * relative value to storage.
  64. * Return 0 on success and others on failure.
  65. * @panic_write:The write operation only used for panic case. It's optional
  66. * if you do not care panic log. The parameters are relative
  67. * value to storage.
  68. * On success, the number of bytes should be returned, others
  69. * excluding -ENOMSG mean error. -ENOMSG means to try next zone.
  70. */
  71. struct pstore_device_info {
  72. unsigned long total_size;
  73. unsigned int flags;
  74. pstore_zone_read_op read;
  75. pstore_zone_write_op write;
  76. pstore_zone_erase_op erase;
  77. pstore_zone_write_op panic_write;
  78. };
  79. int register_pstore_device(struct pstore_device_info *dev);
  80. void unregister_pstore_device(struct pstore_device_info *dev);
  81. /**
  82. * struct pstore_blk_config - the pstore_blk backend configuration
  83. *
  84. * @device: Name of the desired block device
  85. * @max_reason: Maximum kmsg dump reason to store to block device
  86. * @kmsg_size: Total size of for kmsg dumps
  87. * @pmsg_size: Total size of the pmsg storage area
  88. * @console_size: Total size of the console storage area
  89. * @ftrace_size: Total size for ftrace logging data (for all CPUs)
  90. */
  91. struct pstore_blk_config {
  92. char device[80];
  93. enum kmsg_dump_reason max_reason;
  94. unsigned long kmsg_size;
  95. unsigned long pmsg_size;
  96. unsigned long console_size;
  97. unsigned long ftrace_size;
  98. };
  99. /**
  100. * pstore_blk_get_config - get a copy of the pstore_blk backend configuration
  101. *
  102. * @info: The sturct pstore_blk_config to be filled in
  103. *
  104. * Failure returns negative error code, and success returns 0.
  105. */
  106. int pstore_blk_get_config(struct pstore_blk_config *info);
  107. #endif