Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rdma-mwe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Titouan Soulard
rdma-mwe
Commits
1a31dde3
Commit
1a31dde3
authored
Jan 16, 2024
by
Titouan Soulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trx-bridge: move configuration to opaque struct
parent
3591ec8e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
23 deletions
+25
-23
include/trx-bridge/bridge.h
include/trx-bridge/bridge.h
+10
-0
libtrx/trx_rdma.c
libtrx/trx_rdma.c
+2
-2
trx-bridge/bridge.c
trx-bridge/bridge.c
+13
-21
No files found.
include/trx-bridge/bridge.h
0 → 100644
View file @
1a31dde3
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "amarisoft/trx_driver.h"
#include "common/hashtable.h"
#include "libpotoml/toml.h"
libtrx/trx_rdma.c
View file @
1a31dde3
...
...
@@ -201,8 +201,8 @@ int trx_driver_init(TRXState *s) {
}
// String is owned by the driver, and freed in `trx_end_func`
sdr_context
->
server_addr
=
s
->
trx_get_param_string
(
NULL
,
"server_addr"
);
sdr_context
->
device_name
=
s
->
trx_get_param_string
(
NULL
,
"device_name"
);
sdr_context
->
server_addr
=
trx_get_param_string
(
s
,
"server_addr"
);
sdr_context
->
device_name
=
trx_get_param_string
(
s
,
"device_name"
);
if
(
!
sdr_context
->
device_name
)
{
fprintf
(
stderr
,
"Missing `device_name` parameter
\n
"
);
...
...
trx-bridge/bridge.c
View file @
1a31dde3
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "amarisoft/trx_driver.h"
#include "common/hashtable.h"
#include "libpotoml/toml.h"
// XXX: should be part of the `app_opaque` pointer
struct
PotomlTomlSubset
*
input_driver_config
;
struct
PotomlTomlSubset
*
output_driver_config
;
#include "trx-bridge/bridge.h"
char
*
bridge_trx_input_get_param_string
(
void
*
app_opaque
,
const
char
*
prop_name
)
{
return
potoml_toml_get_string
(
input_driver_config
,
prop_name
);
return
potoml_toml_get_string
(
(
struct
PotomlTomlSubset
*
)
app_opaque
,
prop_name
);
}
int
bridge_trx_input_get_param_double
(
void
*
app_opaque
,
double
*
pval
,
const
char
*
prop_name
)
{
return
potoml_toml_get_double
(
input_driver_config
,
prop_name
);
return
potoml_toml_get_double
(
(
struct
PotomlTomlSubset
*
)
app_opaque
,
prop_name
);
}
char
*
bridge_trx_output_get_param_string
(
void
*
app_opaque
,
const
char
*
prop_name
)
{
return
potoml_toml_get_string
(
output_driver_config
,
prop_name
);
return
potoml_toml_get_string
(
(
struct
PotomlTomlSubset
*
)
app_opaque
,
prop_name
);
}
int
bridge_trx_output_get_param_double
(
void
*
app_opaque
,
double
*
pval
,
const
char
*
prop_name
)
{
return
potoml_toml_get_double
(
output_driver_config
,
prop_name
);
return
potoml_toml_get_double
(
(
struct
PotomlTomlSubset
*
)
app_opaque
,
prop_name
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
struct
CommonHashtableTable
config
;
struct
PotomlTomlSubset
*
bridge_config
;
struct
PotomlTomlSubset
*
input_driver_config
;
struct
PotomlTomlSubset
*
output_driver_config
;
int
opt
;
char
result
;
...
...
@@ -70,9 +60,9 @@ int main(int argc, char *argv[]) {
strcpy
(
driver_config_dir
,
optarg
);
}
}
if
(
!
bridge_config_path
||
!
driver_config_dir
)
{
fprintf
(
stderr
,
"Missing required options: -c config_file and -p driver_config_dir
\n
"
);
fprintf
(
stderr
,
"Missing required options: -c config_file and -p driver_config_dir
\n
"
);
return
-
1
;
}
...
...
@@ -88,11 +78,11 @@ int main(int argc, char *argv[]) {
bridge_config
=
potoml_toml_create_subset
(
&
config
,
"bridge"
);
input_driver_config
=
potoml_toml_create_subset
(
&
config
,
"input-driver"
);
output_driver_config
=
potoml_toml_create_subset
(
&
config
,
"output-driver"
);
output_driver_config
=
potoml_toml_create_subset
(
&
config
,
"output-driver"
);
input_lib_name
=
potoml_toml_get_string
(
bridge_config
,
"input_driver_path"
);
output_lib_name
=
potoml_toml_get_string
(
bridge_config
,
"output_driver_path"
);
if
(
!
input_lib_name
||
!
output_lib_name
)
{
fprintf
(
stderr
,
"Could not find configuration parameters for input and output drivers path
\n
"
);
return
-
1
;
...
...
@@ -133,10 +123,12 @@ int main(int argc, char *argv[]) {
printf
(
"trx-bridge: setting driver configuration directory to %s
\n
"
,
driver_config_dir
);
input_trx_state
.
path
=
driver_config_dir
;
input_trx_state
.
trx_api_version
=
15
;
input_trx_state
.
app_opaque
=
input_driver_config
;
input_trx_state
.
trx_get_param_string
=
&
bridge_trx_input_get_param_string
;
input_trx_state
.
trx_get_param_double
=
&
bridge_trx_input_get_param_double
;
output_trx_state
.
trx_api_version
=
15
;
output_trx_state
.
app_opaque
=
output_driver_config
;
output_trx_state
.
trx_get_param_string
=
&
bridge_trx_output_get_param_string
;
output_trx_state
.
trx_get_param_double
=
&
bridge_trx_output_get_param_double
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment