1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
2 /* Copyright (C) 2015-2018 Netronome Systems, Inc. */
3 
4 /*
5  * nfp.h
6  * Interface for NFP device access and query functions.
7  */
8 
9 #ifndef __NFP_H__
10 #define __NFP_H__
11 
12 #include <linux/device.h>
13 #include <linux/types.h>
14 
15 #include "nfp_cpp.h"
16 
17 /* Implemented in nfp_hwinfo.c */
18 
19 struct nfp_hwinfo;
20 struct nfp_hwinfo *nfp_hwinfo_read(struct nfp_cpp *cpp);
21 const char *nfp_hwinfo_lookup(struct nfp_hwinfo *hwinfo, const char *lookup);
22 char *nfp_hwinfo_get_packed_strings(struct nfp_hwinfo *hwinfo);
23 u32 nfp_hwinfo_get_packed_str_size(struct nfp_hwinfo *hwinfo);
24 
25 /* Implemented in nfp_nsp.c, low level functions */
26 
27 struct nfp_nsp;
28 
29 struct nfp_cpp *nfp_nsp_cpp(struct nfp_nsp *state);
30 bool nfp_nsp_config_modified(struct nfp_nsp *state);
31 void nfp_nsp_config_set_modified(struct nfp_nsp *state, bool modified);
32 void *nfp_nsp_config_entries(struct nfp_nsp *state);
33 unsigned int nfp_nsp_config_idx(struct nfp_nsp *state);
34 void nfp_nsp_config_set_state(struct nfp_nsp *state, void *entries,
35 			      unsigned int idx);
36 void nfp_nsp_config_clear_state(struct nfp_nsp *state);
37 int nfp_nsp_read_eth_table(struct nfp_nsp *state, void *buf, unsigned int size);
38 int nfp_nsp_write_eth_table(struct nfp_nsp *state,
39 			    const void *buf, unsigned int size);
40 int nfp_nsp_read_identify(struct nfp_nsp *state, void *buf, unsigned int size);
41 int nfp_nsp_read_sensors(struct nfp_nsp *state, unsigned int sensor_mask,
42 			 void *buf, unsigned int size);
43 
44 /* Implemented in nfp_resource.c */
45 
46 /* All keys are CRC32-POSIX of the 8-byte identification string */
47 
48 /* ARM/PCI vNIC Interfaces 0..3 */
49 #define NFP_RESOURCE_VNIC_PCI_0		"vnic.p0"
50 #define NFP_RESOURCE_VNIC_PCI_1		"vnic.p1"
51 #define NFP_RESOURCE_VNIC_PCI_2		"vnic.p2"
52 #define NFP_RESOURCE_VNIC_PCI_3		"vnic.p3"
53 
54 /* NFP Hardware Info Database */
55 #define NFP_RESOURCE_NFP_HWINFO		"nfp.info"
56 
57 /* Service Processor */
58 #define NFP_RESOURCE_NSP		"nfp.sp"
59 #define NFP_RESOURCE_NSP_DIAG		"arm.diag"
60 
61 /* Netronone Flow Firmware Table */
62 #define NFP_RESOURCE_NFP_NFFW		"nfp.nffw"
63 
64 /* MAC Statistics Accumulator */
65 #define NFP_RESOURCE_MAC_STATISTICS	"mac.stat"
66 
67 int nfp_resource_table_init(struct nfp_cpp *cpp);
68 
69 struct nfp_resource *
70 nfp_resource_acquire(struct nfp_cpp *cpp, const char *name);
71 
72 void nfp_resource_release(struct nfp_resource *res);
73 
74 int nfp_resource_wait(struct nfp_cpp *cpp, const char *name, unsigned int secs);
75 
76 u32 nfp_resource_cpp_id(struct nfp_resource *res);
77 
78 const char *nfp_resource_name(struct nfp_resource *res);
79 
80 u64 nfp_resource_address(struct nfp_resource *res);
81 
82 u64 nfp_resource_size(struct nfp_resource *res);
83 
84 #endif /* !__NFP_H__ */
85