summaryrefslogtreecommitdiffstats
path: root/tools/rmtool/include/rmtool.h
blob: 55166f8d4855bb1692e5aad1c52dd79983452c75 (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
/* rmtool.h - internal shared declarations for rmtool commands and output. */
#ifndef RMTOOL_H
#define RMTOOL_H

#include <stdio.h>
#include <stddef.h>
#include "rm_api.h"

#define RMTOOL_VERSION "0.1.0"

enum rm_format {
	RM_FMT_TABLE = 0,
	RM_FMT_JSON,
	RM_FMT_CSV,
};

struct rm_kv {
	const char *key;
	const char *value;
};

struct rm_ctx {
	int             gpu_minor;	/* -1 = first/default GPU */
	const char     *dev_path;	/* NULL = /dev/nvidiactl */
	enum rm_format  format;
	struct rm_client rm;
	int             have_rm;
};

/* output.c */
enum rm_format rm_format_parse(const char *name);
const char *rm_human_kib(NvU64 kib, char *buf, size_t len);
void rm_print_kv(const char *title, const struct rm_kv *kv, int n,
		 enum rm_format format);
void rm_print_table(const char *title, const char *const *headers,
		    const char *cells, size_t stride, int rows, int cols,
		    enum rm_format format);
void rm_hexdump(const void *data, size_t len);

/* query.c */
int rm_ctx_open(struct rm_ctx *ctx);
int rm_apply_common_opt(struct rm_ctx *ctx, int opt, const char *arg);
NvU32 rm_query_name(struct rm_ctx *ctx, char *buf, size_t len);
NvU32 rm_query_mc_arch(struct rm_ctx *ctx, NV2080_CTRL_MC_ARCH_INFO_PARAMS *p);
NvU32 rm_query_pci(struct rm_ctx *ctx, NV2080_CTRL_BUS_GET_PCI_INFO_PARAMS *p);
NvU32 rm_query_fb(struct rm_ctx *ctx, const NvU32 *indices, NvU32 *values,
		  NvU32 n);
NvU32 rm_query_engines(struct rm_ctx *ctx,
		       NV2080_CTRL_GPU_GET_ENGINES_V2_PARAMS *p);
NvU32 rm_query_fifo_table(struct rm_ctx *ctx,
			  NV2080_FIFO_DEVICE_ENTRY *entries,
			  NvU32 max_entries, NvU32 *n_entries);
const char *rm_arch_str(NvU32 architecture);
const char *rm_engine_type_name(NvU32 engine_type);
const char *rm_engine_name(const NV2080_FIFO_DEVICE_ENTRY *entries,
			   NvU32 n_entries, NvU32 engine_type);

/* gpu.c */
int cmd_gpu(int argc, char **argv, struct rm_ctx *ctx);

/* engine.c */
int cmd_engine(int argc, char **argv, struct rm_ctx *ctx);

/* mem.c */
int cmd_mem(int argc, char **argv, struct rm_ctx *ctx);

/* nv2080.c (includes sample) */
int cmd_nv2080(int argc, char **argv, struct rm_ctx *ctx);
int cmd_sample(int argc, char **argv, struct rm_ctx *ctx);

#endif /* RMTOOL_H */