]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / drivers / raw / ifpga_rawdev / base / ifpga_feature_dev.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
3 */
4
5 #ifndef _IFPGA_FEATURE_DEV_H_
6 #define _IFPGA_FEATURE_DEV_H_
7
8 #include "ifpga_hw.h"
9
10 static inline struct ifpga_port_hw *
11 get_port(struct ifpga_hw *hw, u32 port_id)
12 {
13 if (!is_valid_port_id(hw, port_id))
14 return NULL;
15
16 return &hw->port[port_id];
17 }
18
19 #define ifpga_for_each_fme_feature(hw, feature) \
20 for ((feature) = (hw)->sub_feature; \
21 (feature) < (hw)->sub_feature + (FME_FEATURE_ID_MAX); (feature)++)
22
23 #define ifpga_for_each_port_feature(hw, feature) \
24 for ((feature) = (hw)->sub_feature; \
25 (feature) < (hw)->sub_feature + (PORT_FEATURE_ID_MAX); (feature)++)
26
27 static inline struct feature *
28 get_fme_feature_by_id(struct ifpga_fme_hw *fme, u64 id)
29 {
30 struct feature *feature;
31
32 ifpga_for_each_fme_feature(fme, feature) {
33 if (feature->id == id)
34 return feature;
35 }
36
37 return NULL;
38 }
39
40 static inline struct feature *
41 get_port_feature_by_id(struct ifpga_port_hw *port, u64 id)
42 {
43 struct feature *feature;
44
45 ifpga_for_each_port_feature(port, feature) {
46 if (feature->id == id)
47 return feature;
48 }
49
50 return NULL;
51 }
52
53 static inline void *
54 get_fme_feature_ioaddr_by_index(struct ifpga_fme_hw *fme, int index)
55 {
56 return fme->sub_feature[index].addr;
57 }
58
59 static inline void *
60 get_port_feature_ioaddr_by_index(struct ifpga_port_hw *port, int index)
61 {
62 return port->sub_feature[index].addr;
63 }
64
65 static inline bool
66 is_fme_feature_present(struct ifpga_fme_hw *fme, int index)
67 {
68 return !!get_fme_feature_ioaddr_by_index(fme, index);
69 }
70
71 static inline bool
72 is_port_feature_present(struct ifpga_port_hw *port, int index)
73 {
74 return !!get_port_feature_ioaddr_by_index(port, index);
75 }
76
77 int fpga_get_afu_uuid(struct ifpga_port_hw *port, struct uuid *uuid);
78
79 int __fpga_port_disable(struct ifpga_port_hw *port);
80 void __fpga_port_enable(struct ifpga_port_hw *port);
81
82 static inline int fpga_port_disable(struct ifpga_port_hw *port)
83 {
84 int ret;
85
86 spinlock_lock(&port->lock);
87 ret = __fpga_port_disable(port);
88 spinlock_unlock(&port->lock);
89 return ret;
90 }
91
92 static inline int fpga_port_enable(struct ifpga_port_hw *port)
93 {
94 spinlock_lock(&port->lock);
95 __fpga_port_enable(port);
96 spinlock_unlock(&port->lock);
97
98 return 0;
99 }
100
101 static inline int __fpga_port_reset(struct ifpga_port_hw *port)
102 {
103 int ret;
104
105 ret = __fpga_port_disable(port);
106 if (ret)
107 return ret;
108
109 __fpga_port_enable(port);
110
111 return 0;
112 }
113
114 static inline int fpga_port_reset(struct ifpga_port_hw *port)
115 {
116 int ret;
117
118 spinlock_lock(&port->lock);
119 ret = __fpga_port_reset(port);
120 spinlock_unlock(&port->lock);
121 return ret;
122 }
123
124 int do_pr(struct ifpga_hw *hw, u32 port_id, void *buffer, u32 size,
125 u64 *status);
126
127 int fme_get_prop(struct ifpga_fme_hw *fme, struct feature_prop *prop);
128 int fme_set_prop(struct ifpga_fme_hw *fme, struct feature_prop *prop);
129 int fme_set_irq(struct ifpga_fme_hw *fme, u32 feature_id, void *irq_set);
130
131 int fme_hw_init(struct ifpga_fme_hw *fme);
132 void fme_hw_uinit(struct ifpga_fme_hw *fme);
133 void port_hw_uinit(struct ifpga_port_hw *port);
134 int port_hw_init(struct ifpga_port_hw *port);
135 int port_clear_error(struct ifpga_port_hw *port);
136 void port_err_mask(struct ifpga_port_hw *port, bool mask);
137 int port_err_clear(struct ifpga_port_hw *port, u64 err);
138
139 extern struct feature_ops fme_hdr_ops;
140 extern struct feature_ops fme_thermal_mgmt_ops;
141 extern struct feature_ops fme_power_mgmt_ops;
142 extern struct feature_ops fme_global_err_ops;
143 extern struct feature_ops fme_pr_mgmt_ops;
144 extern struct feature_ops fme_global_iperf_ops;
145 extern struct feature_ops fme_global_dperf_ops;
146
147 int port_get_prop(struct ifpga_port_hw *port, struct feature_prop *prop);
148 int port_set_prop(struct ifpga_port_hw *port, struct feature_prop *prop);
149
150 /* This struct is used when parsing uafu irq_set */
151 struct fpga_uafu_irq_set {
152 u32 start;
153 u32 count;
154 s32 *evtfds;
155 };
156
157 int port_set_irq(struct ifpga_port_hw *port, u32 feature_id, void *irq_set);
158
159 extern struct feature_ops port_hdr_ops;
160 extern struct feature_ops port_error_ops;
161 extern struct feature_ops port_stp_ops;
162 extern struct feature_ops port_uint_ops;
163
164 /* help functions for feature ops */
165 int fpga_msix_set_block(struct feature *feature, unsigned int start,
166 unsigned int count, s32 *fds);
167
168 #endif /* _IFPGA_FEATURE_DEV_H_ */