xref: /linux/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nffw.h (revision e5a52fd2b8cdb700b3c07b030e050a49ef3156b9)
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2015-2018 Netronome Systems, Inc. */
3 
4 /*
5  * nfp_nffw.h
6  * Authors: Jason McMullan <jason.mcmullan@netronome.com>
7  *          Francois H. Theron <francois.theron@netronome.com>
8  */
9 
10 #ifndef NFP_NFFW_H
11 #define NFP_NFFW_H
12 
13 /* Implemented in nfp_nffw.c */
14 
15 struct nfp_nffw_info;
16 
17 struct nfp_nffw_info *nfp_nffw_info_open(struct nfp_cpp *cpp);
18 void nfp_nffw_info_close(struct nfp_nffw_info *state);
19 int nfp_nffw_info_mip_first(struct nfp_nffw_info *state, u32 *cpp_id, u64 *off);
20 
21 /* Implemented in nfp_mip.c */
22 
23 struct nfp_mip;
24 
25 const struct nfp_mip *nfp_mip_open(struct nfp_cpp *cpp);
26 void nfp_mip_close(const struct nfp_mip *mip);
27 
28 const char *nfp_mip_name(const struct nfp_mip *mip);
29 void nfp_mip_symtab(const struct nfp_mip *mip, u32 *addr, u32 *size);
30 void nfp_mip_strtab(const struct nfp_mip *mip, u32 *addr, u32 *size);
31 
32 /* Implemented in nfp_rtsym.c */
33 
34 enum nfp_rtsym_type {
35 	NFP_RTSYM_TYPE_NONE	= 0,
36 	NFP_RTSYM_TYPE_OBJECT	= 1,
37 	NFP_RTSYM_TYPE_FUNCTION	= 2,
38 	NFP_RTSYM_TYPE_ABS	= 3,
39 };
40 
41 #define NFP_RTSYM_TARGET_NONE		0
42 #define NFP_RTSYM_TARGET_LMEM		-1
43 #define NFP_RTSYM_TARGET_EMU_CACHE	-7
44 
45 /**
46  * struct nfp_rtsym - RTSYM descriptor
47  * @name:	Symbol name
48  * @addr:	Address in the domain/target's address space
49  * @size:	Size (in bytes) of the symbol
50  * @type:	NFP_RTSYM_TYPE_* of the symbol
51  * @target:	CPP Target identifier, or NFP_RTSYM_TARGET_*
52  * @domain:	CPP Target Domain (island)
53  */
54 struct nfp_rtsym {
55 	const char *name;
56 	u64 addr;
57 	u64 size;
58 	enum nfp_rtsym_type type;
59 	int target;
60 	int domain;
61 };
62 
63 struct nfp_rtsym_table;
64 
65 struct nfp_rtsym_table *nfp_rtsym_table_read(struct nfp_cpp *cpp);
66 struct nfp_rtsym_table *
67 __nfp_rtsym_table_read(struct nfp_cpp *cpp, const struct nfp_mip *mip);
68 int nfp_rtsym_count(struct nfp_rtsym_table *rtbl);
69 const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx);
70 const struct nfp_rtsym *
71 nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name);
72 
73 u64 nfp_rtsym_size(const struct nfp_rtsym *rtsym);
74 int __nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
75 		     u8 action, u8 token, u64 off, void *buf, size_t len);
76 int nfp_rtsym_read(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
77 		   void *buf, size_t len);
78 int __nfp_rtsym_readl(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
79 		      u8 action, u8 token, u64 off, u32 *value);
80 int nfp_rtsym_readl(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
81 		    u32 *value);
82 int __nfp_rtsym_readq(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
83 		      u8 action, u8 token, u64 off, u64 *value);
84 int nfp_rtsym_readq(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
85 		    u64 *value);
86 int __nfp_rtsym_write(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
87 		      u8 action, u8 token, u64 off, void *buf, size_t len);
88 int nfp_rtsym_write(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
89 		    void *buf, size_t len);
90 int __nfp_rtsym_writel(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
91 		       u8 action, u8 token, u64 off, u32 value);
92 int nfp_rtsym_writel(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
93 		     u32 value);
94 int __nfp_rtsym_writeq(struct nfp_cpp *cpp, const struct nfp_rtsym *sym,
95 		       u8 action, u8 token, u64 off, u64 value);
96 int nfp_rtsym_writeq(struct nfp_cpp *cpp, const struct nfp_rtsym *sym, u64 off,
97 		     u64 value);
98 
99 u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
100 		      int *error);
101 int nfp_rtsym_write_le(struct nfp_rtsym_table *rtbl, const char *name,
102 		       u64 value);
103 u8 __iomem *
104 nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id,
105 	      unsigned int min_size, struct nfp_cpp_area **area);
106 
107 #endif /* NFP_NFFW_H */
108