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