aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/nfp/nfpcore/nfp_rtsym.h
blob: 8b494211bc2145edfdee44b83d273065a101de41 (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
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright(c) 2018 Netronome Systems, Inc.
 * All rights reserved.
 */

#ifndef __NFP_RTSYM_H__
#define __NFP_RTSYM_H__

#define NFP_RTSYM_TYPE_NONE             0
#define NFP_RTSYM_TYPE_OBJECT           1
#define NFP_RTSYM_TYPE_FUNCTION         2
#define NFP_RTSYM_TYPE_ABS              3

#define NFP_RTSYM_TARGET_NONE           0
#define NFP_RTSYM_TARGET_LMEM           -1
#define NFP_RTSYM_TARGET_EMU_CACHE      -7

/*
 * Structure describing a run-time NFP symbol.
 *
 * The memory target of the symbol is generally the CPP target number and can be
 * used directly by the nfp_cpp API calls.  However, in some cases (i.e., for
 * local memory or control store) the target is encoded using a negative number.
 *
 * When the target type can not be used to fully describe the location of a
 * symbol the domain field is used to further specify the location (i.e., the
 * specific ME or island number).
 *
 * For ME target resources, 'domain' is an MEID.
 * For Island target resources, 'domain' is an island ID, with the one exception
 * of "sram" symbols for backward compatibility, which are viewed as global.
 */
struct nfp_rtsym {
	const char *name;
	uint64_t addr;
	uint64_t size;
	int type;
	int target;
	int domain;
};

struct nfp_rtsym_table;

struct nfp_rtsym_table *nfp_rtsym_table_read(struct nfp_cpp *cpp);

struct nfp_rtsym_table *
__nfp_rtsym_table_read(struct nfp_cpp *cpp, const struct nfp_mip *mip);

int nfp_rtsym_count(struct nfp_rtsym_table *rtbl);

const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx);

const struct nfp_rtsym *
nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name);

uint64_t nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
			   int *error);
uint8_t *
nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name,
	      unsigned int min_size, struct nfp_cpp_area **area);
#endif