1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /* Copyright (c) 2021 Hisilicon Limited. */
3 
4 #ifndef __HNS3_DEBUGFS_H
5 #define __HNS3_DEBUGFS_H
6 
7 #include "hnae3.h"
8 
9 #define HNS3_DBG_READ_LEN	65536
10 #define HNS3_DBG_READ_LEN_128KB	0x20000
11 #define HNS3_DBG_READ_LEN_1MB	0x100000
12 #define HNS3_DBG_READ_LEN_4MB	0x400000
13 #define HNS3_DBG_WRITE_LEN	1024
14 
15 #define HNS3_DBG_DATA_STR_LEN	32
16 #define HNS3_DBG_INFO_LEN	256
17 #define HNS3_DBG_ITEM_NAME_LEN	32
18 #define HNS3_DBG_FILE_NAME_LEN	16
19 
20 struct hns3_dbg_item {
21 	char name[HNS3_DBG_ITEM_NAME_LEN];
22 	u16 interval; /* blank numbers after the item */
23 };
24 
25 struct hns3_dbg_data {
26 	struct hnae3_handle *handle;
27 	enum hnae3_dbg_cmd cmd;
28 	u16 qid;
29 };
30 
31 enum hns3_dbg_dentry_type {
32 	HNS3_DBG_DENTRY_TM,
33 	HNS3_DBG_DENTRY_TX_BD,
34 	HNS3_DBG_DENTRY_RX_BD,
35 	HNS3_DBG_DENTRY_MAC,
36 	HNS3_DBG_DENTRY_REG,
37 	HNS3_DBG_DENTRY_QUEUE,
38 	HNS3_DBG_DENTRY_FD,
39 	HNS3_DBG_DENTRY_COMMON,
40 };
41 
42 struct hns3_dbg_dentry_info {
43 	const char *name;
44 	struct dentry *dentry;
45 };
46 
47 struct hns3_dbg_cmd_info {
48 	const char *name;
49 	enum hnae3_dbg_cmd cmd;
50 	enum hns3_dbg_dentry_type dentry;
51 	u32 buf_len;
52 	char *buf;
53 	int (*init)(struct hnae3_handle *handle, unsigned int cmd);
54 };
55 
56 struct hns3_dbg_func {
57 	enum hnae3_dbg_cmd cmd;
58 	int (*dbg_dump)(struct hnae3_handle *handle, char *buf, int len);
59 	int (*dbg_dump_bd)(struct hns3_dbg_data *data, char *buf, int len);
60 };
61 
62 struct hns3_dbg_cap_info {
63 	const char *name;
64 	enum HNAE3_DEV_CAP_BITS cap_bit;
65 };
66 
67 #endif
68