New upstream version 18.08
[deb_dpdk.git] / drivers / net / nfp / nfpcore / nfp_rtsym.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 Netronome Systems, Inc.
3  * All rights reserved.
4  */
5
6 #ifndef __NFP_RTSYM_H__
7 #define __NFP_RTSYM_H__
8
9 #define NFP_RTSYM_TYPE_NONE             0
10 #define NFP_RTSYM_TYPE_OBJECT           1
11 #define NFP_RTSYM_TYPE_FUNCTION         2
12 #define NFP_RTSYM_TYPE_ABS              3
13
14 #define NFP_RTSYM_TARGET_NONE           0
15 #define NFP_RTSYM_TARGET_LMEM           -1
16 #define NFP_RTSYM_TARGET_EMU_CACHE      -7
17
18 /*
19  * Structure describing a run-time NFP symbol.
20  *
21  * The memory target of the symbol is generally the CPP target number and can be
22  * used directly by the nfp_cpp API calls.  However, in some cases (i.e., for
23  * local memory or control store) the target is encoded using a negative number.
24  *
25  * When the target type can not be used to fully describe the location of a
26  * symbol the domain field is used to further specify the location (i.e., the
27  * specific ME or island number).
28  *
29  * For ME target resources, 'domain' is an MEID.
30  * For Island target resources, 'domain' is an island ID, with the one exception
31  * of "sram" symbols for backward compatibility, which are viewed as global.
32  */
33 struct nfp_rtsym {
34         const char *name;
35         uint64_t addr;
36         uint64_t size;
37         int type;
38         int target;
39         int domain;
40 };
41
42 struct nfp_rtsym_table;
43
44 struct nfp_rtsym_table *nfp_rtsym_table_read(struct nfp_cpp *cpp);
45
46 struct nfp_rtsym_table *
47 __nfp_rtsym_table_read(struct nfp_cpp *cpp, const struct nfp_mip *mip);
48
49 int nfp_rtsym_count(struct nfp_rtsym_table *rtbl);
50
51 const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx);
52
53 const struct nfp_rtsym *
54 nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name);
55
56 uint64_t nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
57                            int *error);
58 uint8_t *
59 nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name,
60               unsigned int min_size, struct nfp_cpp_area **area);
61 #endif