Skip to content

Commit afb5d03

Browse files
authored
Merge pull request ofiwg#7263 from gurusrik/efa_prov_windows
prov/efa: Get efa provider ready to be compiled for Windows
2 parents 7a05279 + 8bbc060 commit afb5d03

File tree

4 files changed

+247
-82
lines changed

4 files changed

+247
-82
lines changed

prov/efa/src/efa_device.c

+50
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949

5050
#include "efa.h"
5151

52+
#ifdef _WIN32
53+
#include "efawin.h"
54+
#endif
55+
5256
static struct efa_context **ctx_list;
5357
static int dev_cnt;
5458

@@ -81,6 +85,32 @@ static int efa_device_close(struct efa_context *ctx)
8185
return 0;
8286
}
8387

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+
84114
int efa_device_init(void)
85115
{
86116
struct ibv_device **device_list;
@@ -89,6 +119,11 @@ int efa_device_init(void)
89119

90120
fastlock_init(&pd_list_lock);
91121

122+
ret = efa_lib_init();
123+
if (ret != 0) {
124+
return ret;
125+
}
126+
92127
device_list = ibv_get_device_list(&dev_cnt);
93128
if (device_list == NULL)
94129
return -ENOMEM;
@@ -154,6 +189,20 @@ bool efa_device_support_rdma_read(void)
154189
#endif
155190
}
156191

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+
157206
void efa_device_free(void)
158207
{
159208
int i;
@@ -164,6 +213,7 @@ void efa_device_free(void)
164213
free(pd_list);
165214
free(ctx_list);
166215
dev_cnt = 0;
216+
efa_lib_close();
167217
fastlock_destroy(&pd_list_lock);
168218
}
169219

0 commit comments

Comments
 (0)