FreeBSD kernel CXGBE device code
cudbg_lib_common.h
Go to the documentation of this file.
1/*-
2 * Copyright (c) 2017 Chelsio Communications, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 *
28 */
29
30#ifndef __CUDBG_LIB_COMMON_H__
31#define __CUDBG_LIB_COMMON_H__
32
33/* Extended entity
34 *
35 * Layout of the cudbg dump file when extended entity is present.
36 *
37 *
38 * ----------------
39 * | Global header |
40 * |---------------|
41 * |entity headers |
42 * |---------------|
43 * | Entity data |
44 * | * |
45 * | * |
46 * | * |
47 * |---------------|
48 * |extended entity|
49 * | header |
50 * |---------------|
51 * |extended entity|
52 * | data |
53 * -----------------
54 *
55 *
56 * Extended entity: This comes into picture only when cudbg_collect() is called
57 * multiple times.
58 */
59
60#ifndef CUDBG_LITE
61#include "common/t4_hw.h"
62#endif
63
64#define CUDBG_SF_MAX_SECTOR (FLASH_CUDBG_START_SEC + FLASH_CUDBG_NSECS)
65#define CUDBG_SF_SECTOR_SIZE SF_SEC_SIZE
66#define CUDBG_START_SEC FLASH_CUDBG_START_SEC
67#define CUDBG_FLASH_SIZE FLASH_CUDBG_MAX_SIZE
68
69#define CUDBG_EXT_DATA_BIT 0
70#define CUDBG_EXT_DATA_VALID (1 << CUDBG_EXT_DATA_BIT)
71
72struct cudbg_hdr {
83};
84
93 u8 flag; /* bit 0 is used to indicate ext data */
95 u32 next_ext_offset; /* pointer to next extended entity meta data */
97};
98
103};
104
108 char *data;
109};
110
115};
116
118 int par_sec; /* Represent partially filled sector no */
119 int par_sec_offset; /* Offset in partially filled sector */
123 u32 hdr_data_len; /* Total data */
124 u32 skip_size; /* Total size of large entities. */
128};
129
133};
134
135#define HTONL_NIBBLE(data) ( \
136 (((uint32_t)(data) >> 28) & 0x0000000F) | \
137 (((uint32_t)(data) >> 20) & 0x000000F0) | \
138 (((uint32_t)(data) >> 12) & 0x00000F00) | \
139 (((uint32_t)(data) >> 4) & 0x0000F000) | \
140 (((uint32_t)(data) << 4) & 0x000F0000) | \
141 (((uint32_t)(data) << 12) & 0x00F00000) | \
142 (((uint32_t)(data) << 20) & 0x0F000000) | \
143 (((uint32_t)(data) << 28) & 0xF0000000))
144
145#define CDUMP_MAX_COMP_BUF_SIZE ((64 * 1024) - 1)
146#define CUDBG_CHUNK_SIZE ((CDUMP_MAX_COMP_BUF_SIZE/1024) * 1024)
147
148#define CUDBG_LEGACY_SIGNATURE 123
149#define CUDBG_SIGNATURE 67856866 /* CUDB in ascii */
150#define CUDBG_FL_SIGNATURE 0x4355464c /* CUFL in ascii */
151
152#define CUDBG_FL_MAJOR_VERSION 1
153#define CUDBG_FL_MINOR_VERSION 1
154#define CUDBG_FL_BUILD_VERSION 0
155
157int write_compression_hdr(struct cudbg_buffer *, struct cudbg_buffer *);
158int compress_buff(struct cudbg_buffer *, struct cudbg_buffer *);
159int get_scratch_buff(struct cudbg_buffer *, u32, struct cudbg_buffer *);
160void release_scratch_buff(struct cudbg_buffer *, struct cudbg_buffer *);
161int decompress_buffer(struct cudbg_buffer *, struct cudbg_buffer *);
162int validate_buffer(struct cudbg_buffer *compressed_buffer);
164 struct cudbg_buffer *pdc_buff);
165int get_entity_rev(struct cudbg_ver_hdr *ver_hdr);
166void sort_t(void *base, int num, int size,
167 int (*cmp_func)(const void *, const void *),
168 void (*swap_func)(void *, void *, int size));
169int cudbg_read_flash(void *handle, void *data, u32 size, int data_flag);
170int cudbg_write_flash(void *handle, u64 timestamp, void *data,
171 u32 start_offset, u32 start_hdr_offset,
172 u32 cur_entity_size,
173 u32 ext_size);
174#endif
int cudbg_write_flash(void *handle, u64 timestamp, void *data, u32 start_offset, u32 start_hdr_offset, u32 cur_entity_size, u32 ext_size)
int get_scratch_buff(struct cudbg_buffer *, u32, struct cudbg_buffer *)
Definition: cudbg_common.c:37
void release_scratch_buff(struct cudbg_buffer *, struct cudbg_buffer *)
Definition: cudbg_common.c:59
int compress_buff(struct cudbg_buffer *, struct cudbg_buffer *)
Definition: fastlz_api.c:209
void sort_t(void *base, int num, int size, int(*cmp_func)(const void *, const void *), void(*swap_func)(void *, void *, int size))
int get_entity_rev(struct cudbg_ver_hdr *ver_hdr)
int decompress_buffer_wrapper(struct cudbg_buffer *pc_buff, struct cudbg_buffer *pdc_buff)
int write_compression_hdr(struct cudbg_buffer *, struct cudbg_buffer *)
Definition: fastlz_api.c:144
#define CUDBG_SF_SECTOR_SIZE
int validate_buffer(struct cudbg_buffer *compressed_buffer)
Definition: fastlz_api.c:332
void update_skip_size(struct cudbg_flash_sec_info *, u32)
int decompress_buffer(struct cudbg_buffer *, struct cudbg_buffer *)
Definition: fastlz_api.c:340
int cudbg_read_flash(void *handle, void *data, u32 size, int data_flag)
uint64_t u64
Definition: osdep.h:62
uint8_t u8
Definition: osdep.h:59
uint16_t u16
Definition: osdep.h:60
uint32_t u32
Definition: osdep.h:61
char sec_data[CUDBG_SF_SECTOR_SIZE]
u32 reserved[8]
struct cudbg_flash_sec_info sec_info
struct cudbg_init dbg_init