summaryrefslogtreecommitdiff
path: root/include/linux/nvshm_stats.h
blob: da10e6197532403eef86dba8684104deb02a7582 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _NVSHM_STATS_H
#define _NVSHM_STATS_H

#include <linux/notifier.h>

enum nvshm_stats_type {
	/** Start marker. */
	NVSHM_STATS_START,
	/** End marker. */
	NVSHM_STATS_END,
	/** Sub structure. */
	NVSHM_STATS_SUB,
	/** Unsigned 32bit integer. */
	NVSHM_STATS_UINT32,
	/** Signed 32bit integer. */
	NVSHM_STATS_SINT32,
	/** Unsigned 64bit integer. */
	NVSHM_STATS_UINT64,
};

enum nvshm_stats_notification {
	NVSHM_STATS_MODEM_UP,
	NVSHM_STATS_MODEM_DOWN,
};

struct nvshm_stats_desc;

struct nvshm_stats_iter {
	const struct nvshm_stats_desc *desc;
	char *data;
};

/**
 * Find entry in statistics given a top-structure type name.
 * @param top_name Name of top-structure to look for
 * @param it Iterator returned
 * @return Pointer to enabled field on success, error pointer on error
 */
const u32 *nvshm_stats_top(
	const char *top_name,
	struct nvshm_stats_iter *it);

/**
 * Enter sub-structure given a iterator on a NVSHM_STATS_SUB-type entry.
 * @param it Iterator on entry
 * @param index Array index to select if array of sub-structures
 * @param sub_it Iterator on sub-structure
 * @return 0 on success, negative error code on error
 */
int nvshm_stats_sub(
	const struct nvshm_stats_iter *it,
	int index,
	struct nvshm_stats_iter *sub_it);

/**
 * Increment iterator to point to next entry.
 * @param it Iterator to be incremented
 * @return 0 on success, negative error code on error
 */
int nvshm_stats_next(
	struct nvshm_stats_iter *it);

/**
 * Return name for entry pointed by iterator.
 * @param it Iterator on entry
 * @return Entry name
 */
const char *nvshm_stats_name(
	const struct nvshm_stats_iter *it);

/**
 * Return type for entry pointed by iterator.
 * @param it Iterator on entry
 * @return Entry type
 */
enum nvshm_stats_type nvshm_stats_type(
	const struct nvshm_stats_iter *it);

/**
 * Return number of elements in array.
 * If pointed data is not an array, the returned value is 1.
 * @param it Iterator on entry
 * @return Number of elements
 */
int nvshm_stats_elems(const struct nvshm_stats_iter *it);

/**
 * Get pointer to value for entry pointed by iterator.
 * @param it Iterator on entry
 * @param index Array index if applicable
 * @return Entry value pointer, or error pointer on failure
 */
u32 *nvshm_stats_valueptr_uint32(
	const struct nvshm_stats_iter *it,
	int index);

/**
 * Get pointer to value for entry pointed by iterator.
 * @param it Iterator on entry
 * @param index Array index if applicable
 * @return Entry value pointer, or error pointer on failure
 */
s32 *nvshm_stats_valueptr_sint32(
	const struct nvshm_stats_iter *it,
	int index);

/**
 * Get pointer to value for entry pointed by iterator.
 * @param it Iterator on entry
 * @param index Array index if applicable
 * @return Entry value pointer, or error pointer on failure
 */
u64 *nvshm_stats_valueptr_uint64(
	const struct nvshm_stats_iter *it,
	int index);

/**
 * Register for modem notifications.
 * @param nb notifier block to register
 */
void nvshm_stats_register(struct notifier_block *nb);

/**
 * Unregister from modem notifications.
 * @param nb notifier block to unregister
 */
void nvshm_stats_unregister(struct notifier_block *nb);

#endif /* _NVSHM_STATS_H */