GNU Linux-libre 4.19.264-gnu1
[releases.git] / drivers / net / ethernet / netronome / nfp / nfpcore / nfp.h
1 /*
2  * Copyright (C) 2015-2017 Netronome Systems, Inc.
3  *
4  * This software is dual licensed under the GNU General License Version 2,
5  * June 1991 as shown in the file COPYING in the top-level directory of this
6  * source tree or the BSD 2-Clause License provided below.  You have the
7  * option to license this software under the complete terms of either license.
8  *
9  * The BSD 2-Clause License:
10  *
11  *     Redistribution and use in source and binary forms, with or
12  *     without modification, are permitted provided that the following
13  *     conditions are met:
14  *
15  *      1. Redistributions of source code must retain the above
16  *         copyright notice, this list of conditions and the following
17  *         disclaimer.
18  *
19  *      2. Redistributions in binary form must reproduce the above
20  *         copyright notice, this list of conditions and the following
21  *         disclaimer in the documentation and/or other materials
22  *         provided with the distribution.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
28  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
29  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31  * SOFTWARE.
32  */
33
34 /*
35  * nfp.h
36  * Interface for NFP device access and query functions.
37  */
38
39 #ifndef __NFP_H__
40 #define __NFP_H__
41
42 #include <linux/device.h>
43 #include <linux/types.h>
44
45 #include "nfp_cpp.h"
46
47 /* Implemented in nfp_hwinfo.c */
48
49 struct nfp_hwinfo;
50 struct nfp_hwinfo *nfp_hwinfo_read(struct nfp_cpp *cpp);
51 const char *nfp_hwinfo_lookup(struct nfp_hwinfo *hwinfo, const char *lookup);
52 char *nfp_hwinfo_get_packed_strings(struct nfp_hwinfo *hwinfo);
53 u32 nfp_hwinfo_get_packed_str_size(struct nfp_hwinfo *hwinfo);
54
55 /* Implemented in nfp_nsp.c, low level functions */
56
57 struct nfp_nsp;
58
59 struct nfp_cpp *nfp_nsp_cpp(struct nfp_nsp *state);
60 bool nfp_nsp_config_modified(struct nfp_nsp *state);
61 void nfp_nsp_config_set_modified(struct nfp_nsp *state, bool modified);
62 void *nfp_nsp_config_entries(struct nfp_nsp *state);
63 unsigned int nfp_nsp_config_idx(struct nfp_nsp *state);
64 void nfp_nsp_config_set_state(struct nfp_nsp *state, void *entries,
65                               unsigned int idx);
66 void nfp_nsp_config_clear_state(struct nfp_nsp *state);
67 int nfp_nsp_read_eth_table(struct nfp_nsp *state, void *buf, unsigned int size);
68 int nfp_nsp_write_eth_table(struct nfp_nsp *state,
69                             const void *buf, unsigned int size);
70 int nfp_nsp_read_identify(struct nfp_nsp *state, void *buf, unsigned int size);
71 int nfp_nsp_read_sensors(struct nfp_nsp *state, unsigned int sensor_mask,
72                          void *buf, unsigned int size);
73
74 /* Implemented in nfp_resource.c */
75
76 /* All keys are CRC32-POSIX of the 8-byte identification string */
77
78 /* ARM/PCI vNIC Interfaces 0..3 */
79 #define NFP_RESOURCE_VNIC_PCI_0         "vnic.p0"
80 #define NFP_RESOURCE_VNIC_PCI_1         "vnic.p1"
81 #define NFP_RESOURCE_VNIC_PCI_2         "vnic.p2"
82 #define NFP_RESOURCE_VNIC_PCI_3         "vnic.p3"
83
84 /* NFP Hardware Info Database */
85 #define NFP_RESOURCE_NFP_HWINFO         "nfp.info"
86
87 /* Service Processor */
88 #define NFP_RESOURCE_NSP                "nfp.sp"
89 #define NFP_RESOURCE_NSP_DIAG           "arm.diag"
90
91 /* Netronone Flow Firmware Table */
92 #define NFP_RESOURCE_NFP_NFFW           "nfp.nffw"
93
94 /* MAC Statistics Accumulator */
95 #define NFP_RESOURCE_MAC_STATISTICS     "mac.stat"
96
97 int nfp_resource_table_init(struct nfp_cpp *cpp);
98
99 struct nfp_resource *
100 nfp_resource_acquire(struct nfp_cpp *cpp, const char *name);
101
102 void nfp_resource_release(struct nfp_resource *res);
103
104 int nfp_resource_wait(struct nfp_cpp *cpp, const char *name, unsigned int secs);
105
106 u32 nfp_resource_cpp_id(struct nfp_resource *res);
107
108 const char *nfp_resource_name(struct nfp_resource *res);
109
110 u64 nfp_resource_address(struct nfp_resource *res);
111
112 u64 nfp_resource_size(struct nfp_resource *res);
113
114 #endif /* !__NFP_H__ */