xref: /linux-6.15/include/linux/pstore_blk.h (revision a0adc8ea)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef __PSTORE_BLK_H_
4 #define __PSTORE_BLK_H_
5 
6 #include <linux/types.h>
7 #include <linux/pstore.h>
8 #include <linux/pstore_zone.h>
9 
10 /**
11  * struct pstore_device_info - back-end pstore/blk driver structure.
12  *
13  * @total_size: The total size in bytes pstore/blk can use. It must be greater
14  *		than 4096 and be multiple of 4096.
15  * @flags:	Refer to macro starting with PSTORE_FLAGS defined in
16  *		linux/pstore.h. It means what front-ends this device support.
17  *		Zero means all backends for compatible.
18  * @read:	The general read operation. Both of the function parameters
19  *		@size and @offset are relative value to bock device (not the
20  *		whole disk).
21  *		On success, the number of bytes should be returned, others
22  *		means error.
23  * @write:	The same as @read, but the following error number:
24  *		-EBUSY means try to write again later.
25  *		-ENOMSG means to try next zone.
26  * @erase:	The general erase operation for device with special removing
27  *		job. Both of the function parameters @size and @offset are
28  *		relative value to storage.
29  *		Return 0 on success and others on failure.
30  * @panic_write:The write operation only used for panic case. It's optional
31  *		if you do not care panic log. The parameters are relative
32  *		value to storage.
33  *		On success, the number of bytes should be returned, others
34  *		excluding -ENOMSG mean error. -ENOMSG means to try next zone.
35  */
36 struct pstore_device_info {
37 	unsigned long total_size;
38 	unsigned int flags;
39 	pstore_zone_read_op read;
40 	pstore_zone_write_op write;
41 	pstore_zone_erase_op erase;
42 	pstore_zone_write_op panic_write;
43 };
44 
45 int  register_pstore_device(struct pstore_device_info *dev);
46 void unregister_pstore_device(struct pstore_device_info *dev);
47 
48 /**
49  * struct pstore_blk_config - the pstore_blk backend configuration
50  *
51  * @device:		Name of the desired block device
52  * @max_reason:		Maximum kmsg dump reason to store to block device
53  * @kmsg_size:		Total size of for kmsg dumps
54  * @pmsg_size:		Total size of the pmsg storage area
55  * @console_size:	Total size of the console storage area
56  * @ftrace_size:	Total size for ftrace logging data (for all CPUs)
57  */
58 struct pstore_blk_config {
59 	char device[80];
60 	enum kmsg_dump_reason max_reason;
61 	unsigned long kmsg_size;
62 	unsigned long pmsg_size;
63 	unsigned long console_size;
64 	unsigned long ftrace_size;
65 };
66 
67 /**
68  * pstore_blk_get_config - get a copy of the pstore_blk backend configuration
69  *
70  * @info:	The sturct pstore_blk_config to be filled in
71  *
72  * Failure returns negative error code, and success returns 0.
73  */
74 int pstore_blk_get_config(struct pstore_blk_config *info);
75 
76 #endif
77