summaryrefslogtreecommitdiff
path: root/debugfs.h
blob: 7b2e2822c6db81991260fe444c499729705c9b05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright 2022 Google LLC.
 *
 * Author: Star Chang <starchang@google.com>
 */

#ifndef _WLAN_PTRACKER_DEBUGFS_H
#define _WLAN_PTRACKER_DEBUGFS_H

#include <linux/types.h>
#include <linux/mutex.h>
#include <linux/time64.h>
#include <linux/sysfs.h>
#include <linux/kobject.h>

struct wlan_ptracker_core;

struct wlan_ptracker_debugfs {
	struct dentry *root;
	struct kobject kobj;
	u32 dscp;
	u32 ac;
	u32 action;
	u32 log_level;
};

struct ptracker_kobj_attr {
	struct attribute attr;
	ssize_t (*show)(struct wlan_ptracker_debugfs *, char *);
	ssize_t (*store)(struct wlan_ptracker_debugfs *, const char *, size_t count);
};

enum {
	FEATURE_FLAG_TWT,
	FEATURE_FLAG_MAX
};

enum {
	ACTION_DSCP_UPDATE,
	ACTION_MAX,
};

struct scene_statistic {
	u64 awake;
	u64 asleep;
};

struct history_entry {
	u32 state;
	bool valid;
	struct timespec64 ts;
};

#define MODULE_NAME_MAX 64
struct history_manager {
	char name[MODULE_NAME_MAX];
	int cur;
	int round;
	int entry_count;
	int entry_size;
	struct mutex mutex;
	int (*priv_read)(struct wlan_ptracker_core *core, void *cur, void *next, char *buf, int len);
	u8 entries[0];
};

extern int wlan_ptracker_debugfs_init(struct wlan_ptracker_debugfs *debugfs);
extern void wlan_ptracker_debugfs_exit(struct wlan_ptracker_debugfs *debugfs);
extern struct history_manager *wlan_ptracker_history_create(int entry_count, int entry_size);
extern void wlan_ptracker_history_destroy(struct history_manager *hm);
extern void *wlan_ptracker_history_store(struct history_manager *hm, u32 state);
extern size_t wlan_ptracker_history_read(struct wlan_ptracker_core *core,
	struct history_manager *hm, char *buf, int len);

#endif  /* _WLAN_PTRACKER_DEBUGFS_H */