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 * typedef pstore_blk_panic_write_op - panic write operation to block device 12 * 13 * @buf: the data to write 14 * @start_sect: start sector to block device 15 * @sects: sectors count on buf 16 * 17 * Return: On success, zero should be returned. Others excluding -ENOMSG 18 * mean error. -ENOMSG means to try next zone. 19 * 20 * Panic write to block device must be aligned to SECTOR_SIZE. 21 */ 22typedef int (*pstore_blk_panic_write_op)(const char *buf, sector_t start_sect, 23 sector_t sects); 24 25/** 26 * struct pstore_blk_info - pstore/blk registration details 27 * 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. 37 */ 38struct pstore_blk_info { 39 unsigned int major; 40 unsigned int flags; 41 pstore_blk_panic_write_op panic_write; 42 43 /* Filled in by pstore/blk after registration. */ 44 dev_t devt; 45 sector_t nr_sects; 46 sector_t start_sect; 47}; 48 49int register_pstore_blk(struct pstore_blk_info *info); 50void unregister_pstore_blk(unsigned int major); 51 52/** 53 * struct pstore_device_info - back-end pstore/blk driver structure. 54 * 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 62 * whole disk). 63 * On success, the number of bytes should be returned, others 64 * means error. 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 74 * value to storage. 75 * On success, the number of bytes should be returned, others 76 * excluding -ENOMSG mean error. -ENOMSG means to try next zone. 77 */ 78struct pstore_device_info { 79 unsigned long total_size; 80 unsigned int flags; 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; 85}; 86 87int register_pstore_device(struct pstore_device_info *dev); 88void unregister_pstore_device(struct pstore_device_info *dev); 89 90/** 91 * struct pstore_blk_config - the pstore_blk backend configuration 92 * 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) 99 */ 100struct pstore_blk_config { 101 char device[80]; 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; 107}; 108 109/** 110 * pstore_blk_get_config - get a copy of the pstore_blk backend configuration 111 * 112 * @info: The sturct pstore_blk_config to be filled in 113 * 114 * Failure returns negative error code, and success returns 0. 115 */ 116int pstore_blk_get_config(struct pstore_blk_config *info); 117 118#endif 119