xref: /linux/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib_common.h (revision a4eb44a6435d6d8f9e642407a4a06f65eb90ca04)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  *  Copyright (C) 2017 Chelsio Communications.  All rights reserved.
4  */
5 
6 #ifndef __CUDBG_LIB_COMMON_H__
7 #define __CUDBG_LIB_COMMON_H__
8 
9 #define CUDBG_SIGNATURE 67856866 /* CUDB in ascii */
10 
11 enum cudbg_dump_type {
12 	CUDBG_DUMP_TYPE_MINI = 1,
13 };
14 
15 enum cudbg_compression_type {
16 	CUDBG_COMPRESSION_NONE = 1,
17 	CUDBG_COMPRESSION_ZLIB,
18 };
19 
20 struct cudbg_hdr {
21 	u32 signature;
22 	u32 hdr_len;
23 	u16 major_ver;
24 	u16 minor_ver;
25 	u32 data_len;
26 	u32 hdr_flags;
27 	u16 max_entities;
28 	u8 chip_ver;
29 	u8 dump_type:3;
30 	u8 reserved1:1;
31 	u8 compress_type:4;
32 	u32 reserved[8];
33 };
34 
35 struct cudbg_entity_hdr {
36 	u32 entity_type;
37 	u32 start_offset;
38 	u32 size;
39 	int hdr_flags;
40 	u32 sys_warn;
41 	u32 sys_err;
42 	u8 num_pad;
43 	u8 flag;             /* bit 0 is used to indicate ext data */
44 	u8 reserved1[2];
45 	u32 next_ext_offset; /* pointer to next extended entity meta data */
46 	u32 reserved[5];
47 };
48 
49 struct cudbg_ver_hdr {
50 	u32 signature;
51 	u16 revision;
52 	u16 size;
53 };
54 
55 struct cudbg_buffer {
56 	u32 size;
57 	u32 offset;
58 	char *data;
59 };
60 
61 struct cudbg_error {
62 	int sys_err;
63 	int sys_warn;
64 	int app_err;
65 };
66 
67 #define CDUMP_MAX_COMP_BUF_SIZE ((64 * 1024) - 1)
68 #define CUDBG_CHUNK_SIZE ((CDUMP_MAX_COMP_BUF_SIZE / 1024) * 1024)
69 
70 int cudbg_get_buff(struct cudbg_init *pdbg_init,
71 		   struct cudbg_buffer *pdbg_buff, u32 size,
72 		   struct cudbg_buffer *pin_buff);
73 void cudbg_put_buff(struct cudbg_init *pdbg_init,
74 		    struct cudbg_buffer *pin_buff);
75 void cudbg_update_buff(struct cudbg_buffer *pin_buff,
76 		       struct cudbg_buffer *pout_buff);
77 #endif /* __CUDBG_LIB_COMMON_H__ */
78