File tree 4 files changed +247
-82
lines changed
4 files changed +247
-82
lines changed Original file line number Diff line number Diff line change 49
49
50
50
#include "efa.h"
51
51
52
+ #ifdef _WIN32
53
+ #include "efawin.h"
54
+ #endif
55
+
52
56
static struct efa_context * * ctx_list ;
53
57
static int dev_cnt ;
54
58
@@ -81,6 +85,32 @@ static int efa_device_close(struct efa_context *ctx)
81
85
return 0 ;
82
86
}
83
87
88
+ #ifndef _WIN32
89
+
90
+ int efa_lib_init (void )
91
+ {
92
+ return 0 ;
93
+ }
94
+
95
+ #else // _WIN32
96
+
97
+ int efa_lib_init (void )
98
+ {
99
+ int ret ;
100
+ /*
101
+ * On Windows we need to load efawin dll to interact with
102
+ * efa device as there is no built-in verbs integration in the OS.
103
+ * efawin dll provides all the ibv_* functions on Windows.
104
+ * efa_load_efawin_lib function will replace stub ibv_* functions with
105
+ * functions from efawin dll
106
+ */
107
+ ret = efa_load_efawin_lib ();
108
+
109
+ return ret ;
110
+ }
111
+
112
+ #endif // _WIN32
113
+
84
114
int efa_device_init (void )
85
115
{
86
116
struct ibv_device * * device_list ;
@@ -89,6 +119,11 @@ int efa_device_init(void)
89
119
90
120
fastlock_init (& pd_list_lock );
91
121
122
+ ret = efa_lib_init ();
123
+ if (ret != 0 ) {
124
+ return ret ;
125
+ }
126
+
92
127
device_list = ibv_get_device_list (& dev_cnt );
93
128
if (device_list == NULL )
94
129
return - ENOMEM ;
@@ -154,6 +189,20 @@ bool efa_device_support_rdma_read(void)
154
189
#endif
155
190
}
156
191
192
+ #ifndef _WIN32
193
+
194
+ void efa_lib_close (void ) {
195
+ // Nothing to do when we are not compiling for Windows
196
+ }
197
+
198
+ #else // _WIN32
199
+
200
+ void efa_lib_close (void ) {
201
+ efa_free_efawin_lib ();
202
+ }
203
+
204
+ #endif // _WIN32
205
+
157
206
void efa_device_free (void )
158
207
{
159
208
int i ;
@@ -164,6 +213,7 @@ void efa_device_free(void)
164
213
free (pd_list );
165
214
free (ctx_list );
166
215
dev_cnt = 0 ;
216
+ efa_lib_close ();
167
217
fastlock_destroy (& pd_list_lock );
168
218
}
169
219
You can’t perform that action at this time.
0 commit comments