This source file includes following definitions.
- scifdev_self
- scif_is_mgmt_node
- scifdev_is_p2p
- _scifdev_alive
1
2
3
4
5
6
7
8
9 #ifndef SCIF_MAIN_H
10 #define SCIF_MAIN_H
11
12 #include <linux/sched/signal.h>
13 #include <linux/pci.h>
14 #include <linux/miscdevice.h>
15 #include <linux/dmaengine.h>
16 #include <linux/iova.h>
17 #include <linux/anon_inodes.h>
18 #include <linux/file.h>
19 #include <linux/vmalloc.h>
20 #include <linux/scif.h>
21 #include "../common/mic_dev.h"
22
23 #define SCIF_MGMT_NODE 0
24 #define SCIF_DEFAULT_WATCHDOG_TO 30
25 #define SCIF_NODE_ACCEPT_TIMEOUT (3 * HZ)
26 #define SCIF_NODE_ALIVE_TIMEOUT (SCIF_DEFAULT_WATCHDOG_TO * HZ)
27 #define SCIF_RMA_TEMP_CACHE_LIMIT 0x20000
28
29
30
31
32
33 enum scif_msg_state {
34 OP_IDLE = 1,
35 OP_IN_PROGRESS,
36 OP_COMPLETED,
37 OP_FAILED
38 };
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 struct scif_info {
80 u8 nodeid;
81 u8 maxid;
82 u8 total;
83 u32 nr_zombies;
84 struct mutex eplock;
85 struct mutex connlock;
86 spinlock_t nb_connect_lock;
87 spinlock_t port_lock;
88 struct list_head uaccept;
89 struct list_head listen;
90 struct list_head zombie;
91 struct list_head connected;
92 struct list_head disconnected;
93 struct list_head nb_connect_list;
94 struct work_struct misc_work;
95 struct mutex conflock;
96 u8 en_msg_log;
97 u8 p2p_enable;
98 struct miscdevice mdev;
99 struct work_struct conn_work;
100 wait_queue_head_t exitwq;
101 struct scif_dev *loopb_dev;
102 struct workqueue_struct *loopb_wq;
103 char loopb_wqname[16];
104 struct work_struct loopb_work;
105 struct list_head loopb_recv_q;
106 bool card_initiated_exit;
107 spinlock_t rmalock;
108 struct mutex fencelock;
109 struct list_head rma;
110 struct list_head rma_tc;
111 struct list_head fence;
112 struct work_struct mmu_notif_work;
113 struct list_head mmu_notif_cleanup;
114 unsigned long rma_tc_limit;
115 };
116
117
118
119
120
121
122
123
124
125
126
127 struct scif_p2p_info {
128 u8 ppi_peer_id;
129 struct scatterlist *ppi_sg[2];
130 u64 sg_nentries[2];
131 dma_addr_t ppi_da[2];
132 u64 ppi_len[2];
133 #define SCIF_PPI_MMIO 0
134 #define SCIF_PPI_APER 1
135 struct list_head ppi_list;
136 };
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168 struct scif_dev {
169 u8 node;
170 struct list_head p2p;
171 struct scif_qp *qpairs;
172 struct workqueue_struct *intr_wq;
173 char intr_wqname[16];
174 struct work_struct intr_bh;
175 struct mutex lock;
176 struct scif_hw_dev *sdev;
177 int db;
178 int rdb;
179 struct mic_irq *cookie;
180 struct work_struct peer_add_work;
181 struct delayed_work p2p_dwork;
182 struct delayed_work qp_dwork;
183 int p2p_retry;
184 dma_addr_t base_addr;
185 struct mic_mw mmio;
186 struct scif_peer_dev __rcu *spdev;
187 bool node_remove_ack_pending;
188 bool exit_ack_pending;
189 wait_queue_head_t disconn_wq;
190 atomic_t disconn_rescnt;
191 enum scif_msg_state exit;
192 dma_addr_t qp_dma_addr;
193 int dma_ch_idx;
194 struct dma_pool *signal_pool;
195 };
196
197 extern bool scif_reg_cache_enable;
198 extern bool scif_ulimit_check;
199 extern struct scif_info scif_info;
200 extern struct idr scif_ports;
201 extern struct bus_type scif_peer_bus;
202 extern struct scif_dev *scif_dev;
203 extern const struct file_operations scif_fops;
204 extern const struct file_operations scif_anon_fops;
205
206
207 #define SCIF_NODE_QP_SIZE 0x10000
208
209 #include "scif_nodeqp.h"
210 #include "scif_rma.h"
211 #include "scif_rma_list.h"
212
213
214
215
216
217
218
219 static inline int scifdev_self(struct scif_dev *dev)
220 {
221 return dev->node == scif_info.nodeid;
222 }
223
224 static inline bool scif_is_mgmt_node(void)
225 {
226 return !scif_info.nodeid;
227 }
228
229
230
231
232
233
234
235 static inline bool scifdev_is_p2p(struct scif_dev *dev)
236 {
237 if (scif_is_mgmt_node())
238 return false;
239 else
240 return dev != &scif_dev[SCIF_MGMT_NODE] &&
241 !scifdev_self(dev);
242 }
243
244
245
246
247
248
249
250
251 static inline int _scifdev_alive(struct scif_dev *scifdev)
252 {
253 struct scif_peer_dev *spdev;
254
255 rcu_read_lock();
256 spdev = rcu_dereference(scifdev->spdev);
257 rcu_read_unlock();
258 return !!spdev;
259 }
260
261 #include "scif_epd.h"
262
263 void __init scif_init_debugfs(void);
264 void scif_exit_debugfs(void);
265 int scif_setup_intr_wq(struct scif_dev *scifdev);
266 void scif_destroy_intr_wq(struct scif_dev *scifdev);
267 void scif_cleanup_scifdev(struct scif_dev *dev);
268 void scif_handle_remove_node(int node);
269 void scif_disconnect_node(u32 node_id, bool mgmt_initiated);
270 void scif_free_qp(struct scif_dev *dev);
271 void scif_misc_handler(struct work_struct *work);
272 void scif_stop(struct scif_dev *scifdev);
273 irqreturn_t scif_intr_handler(int irq, void *data);
274 #endif