Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
Beam Positoning Monitor - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Beam Positoning Monitor - Software
Commits
71f04b02
Commit
71f04b02
authored
Jun 12, 2015
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{include,src/dev_mngr}/dev_mngr.*: use libhutils ZCONFIG parsing
parent
57f2f6eb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
109 deletions
+6
-109
dev_mngr_core.h
include/dev_mngr_core.h
+0
-3
dev_mngr.c
src/dev_mngr/dev_mngr.c
+3
-3
dev_mngr_core.c
src/dev_mngr/dev_mngr_core.c
+3
-103
No files found.
include/dev_mngr_core.h
View file @
71f04b02
...
...
@@ -78,9 +78,6 @@ dmngr_err_e dmngr_scan_devs (dmngr_t *self, uint32_t *num_devs_found);
dmngr_err_e
dmngr_spawn_all_devios
(
dmngr_t
*
self
,
char
*
broker_endp
,
char
*
devio_log_filename
,
bool
respawn_killed_devio
);
/* Utility functions */
dmngr_err_e
dmngr_get_hints
(
zconfig_t
*
root_cfg
,
zhash_t
*
hints_h
);
#ifdef __cplusplus
}
#endif
...
...
src/dev_mngr/dev_mngr.c
View file @
71f04b02
...
...
@@ -150,8 +150,8 @@ int main (int argc, char *argv[])
/* Read DEVIO suggested bind endpoints and fill the hash table with
* the corresponding keys */
dmngr_err_e
err
=
dmngr
_get_hints
(
root_cfg
,
dmngr_hints
);
if
(
err
!=
DMNGR
_SUCCESS
)
{
hutils_err_e
herr
=
hutils
_get_hints
(
root_cfg
,
dmngr_hints
);
if
(
herr
!=
HUTILS
_SUCCESS
)
{
DBE_DEBUG
(
DBG_DEV_MNGR
|
DBG_LVL_FATAL
,
"[dev_mngr] Could not get hints "
"from configuration file
\n
"
);
goto
err_cfg_exit
;
...
...
@@ -227,7 +227,7 @@ int main (int argc, char *argv[])
dmngr_set_wait_clhd_handler
(
dmngr
,
&
hutils_wait_chld
);
dmngr_set_spawn_clhd_handler
(
dmngr
,
&
hutils_spawn_chld
);
err
=
dmngr_register_sig_handlers
(
dmngr
);
dmngr_err_e
err
=
dmngr_register_sig_handlers
(
dmngr
);
if
(
err
!=
DMNGR_SUCCESS
)
{
DBE_DEBUG
(
DBG_DEV_MNGR
|
DBG_LVL_FATAL
,
"[dev_mngr] dmngr_register_sig_handler error!
\n
"
);
goto
err_sig_handlers
;
...
...
src/dev_mngr/dev_mngr_core.c
View file @
71f04b02
...
...
@@ -40,33 +40,6 @@
#define DEVIO_BE_DEV_PATTERN "/dev/fpga%d"
#define DEVIO_BE_DEV_GLOB "/dev/fpga*"
/******************* Configuration file property names ************************/
#define DMNGR_FE_CFG_ENDP_MAX_PATH 256
#define DMNGR_FE_CFG_ENDP_PATH_PATTERN \
"/dev_io/board%u/bpm%u/afe/bind"
/* We don't expect our hash key to be bigger than this */
#define DMNGR_CFG_HASH_KEY_MAX_LEN 64
/* Our config hash key is composed of this pattern: board%u/bpm%u/afe
* or board%u/bpm%u/dbe */
#define DMNGR_CFG_BOARD_TYPE "%s"
#define DMNGR_CFG_BOARD_PATTERN "board%u"
#define DMNGR_CFG_BPM_TYPE "%s"
#define DMNGR_CFG_BPM_PATTERN "bpm%u"
#define DMNGR_CFG_DEVIO_MODEL_TYPE "%s"
#define DMNGR_CFG_AFE "afe"
#define DMNGR_CFG_DBE "dbe"
//#define DMNGR_CFG_HASH_KEY_PATTERN "%s/%s/%s"
#define DMNGR_CFG_HASH_KEY_PATTERN DMNGR_CFG_BOARD_TYPE \
"/" DMNGR_CFG_BPM_TYPE "/" \
DMNGR_CFG_DEVIO_MODEL_TYPE
#define DMNGR_CFG_HASH_KEY_PATTERN_COMPL \
DMNGR_CFG_BOARD_PATTERN \
"/" DMNGR_CFG_BPM_PATTERN "/" \
DMNGR_CFG_DEVIO_MODEL_TYPE
/* Arbitrary hard limit for the maximum number of AFE DEVIOs
* for each DBE DEVIO */
#define DEVIO_MAX_FE_DEVIOS 16
...
...
@@ -540,12 +513,12 @@ static dmngr_err_e _dmngr_scan_devs (dmngr_t *self, uint32_t *num_devs_found)
/* Stringify ID */
/* DBE_DEBUG (DBG_DEV_MNGR | DBG_LVL_TRACE,
"[dev_mngr_core:scan_devs] Stringify hash ID\n"); */
char
key
[
DMNGR
_CFG_HASH_KEY_MAX_LEN
];
char
key
[
HUTILS
_CFG_HASH_KEY_MAX_LEN
];
/* This follows the hierarchy found in the config file */
int
errs
=
snprintf
(
key
,
sizeof
(
key
),
DMNGR
_CFG_HASH_KEY_PATTERN_COMPL
,
int
errs
=
snprintf
(
key
,
sizeof
(
key
),
HUTILS
_CFG_HASH_KEY_PATTERN_COMPL
,
devio_info_id
,
/* BPM ID does not matter for DBE DEVIOs */
0
,
DMNGR
_CFG_DBE
);
HUTILS
_CFG_DBE
);
/* Only when the number of characters written is less than the whole buffer,
* it is guaranteed that the string was written successfully */
...
...
@@ -647,76 +620,3 @@ err_devio_info_alloc:
return
err
;
}
dmngr_err_e
dmngr_get_hints
(
zconfig_t
*
root_cfg
,
zhash_t
*
hints_h
)
{
assert
(
root_cfg
);
assert
(
hints_h
);
dmngr_err_e
err
=
DMNGR_SUCCESS
;
/* Read DEVIO suggested bind endpoints and fill the hash table with
* the corresponding keys */
/* First find the dev_io property */
zconfig_t
*
devio_cfg
=
zconfig_locate
(
root_cfg
,
"/dev_io"
);
ASSERT_TEST
(
devio_cfg
!=
NULL
,
"Could not find "
"dev_io property in configuration file"
,
err_cfg_exit
,
DMNGR_ERR_CFG
);
/* Now, find all of our child */
zconfig_t
*
board_cfg
=
zconfig_child
(
devio_cfg
);
ASSERT_TEST
(
board_cfg
!=
NULL
,
"Could not find "
"board* property in configuration file"
,
err_cfg_exit
,
DMNGR_ERR_CFG
);
/* Navigate through all of our board siblings */
for
(;
board_cfg
!=
NULL
;
board_cfg
=
zconfig_next
(
board_cfg
))
{
DBE_DEBUG
(
DBG_DEV_MNGR
|
DBG_LVL_TRACE
,
"Config file: "
"board_cfg name: %s
\n
"
,
zconfig_name
(
board_cfg
));
zconfig_t
*
bpm_cfg
=
zconfig_child
(
board_cfg
);
ASSERT_TEST
(
bpm_cfg
!=
NULL
,
"Could not find "
"bpm* property in configuration file"
,
err_cfg_exit
,
DMNGR_ERR_CFG
);
/* Navigate through all of our bpm siblings and fill the hash table */
for
(;
bpm_cfg
!=
NULL
;
bpm_cfg
=
zconfig_next
(
bpm_cfg
))
{
DBE_DEBUG
(
DBG_DEV_MNGR
|
DBG_LVL_TRACE
,
"Config file: "
"bpm_cfg name: %s
\n
"
,
zconfig_name
(
bpm_cfg
));
/* Now, we expect to find the bind address of this bpm/board instance
* in the configuration file */
char
*
hints_value
=
zconfig_resolve
(
bpm_cfg
,
"/afe/bind"
,
NULL
);
ASSERT_TEST
(
hints_value
!=
NULL
,
"[dev_mngr] Could not find "
"AFE bind address in configuration file"
,
err_cfg_exit
,
DMNGR_ERR_CFG
);
/* Now, we only need to generate a valid key to insert in the hash.
* we choose the combination of the type "board%u/bpm%u/afe" or
* board%u/bpm%u/dbe */
char
hints_key
[
DMNGR_CFG_HASH_KEY_MAX_LEN
];
int
errs
=
snprintf
(
hints_key
,
sizeof
(
hints_key
),
DMNGR_CFG_HASH_KEY_PATTERN
,
zconfig_name
(
board_cfg
),
zconfig_name
(
bpm_cfg
),
DMNGR_CFG_AFE
);
/* Only when the number of characters written is less than the whole buffer,
* it is guaranteed that the string was written successfully */
ASSERT_TEST
(
errs
>=
0
&&
(
size_t
)
errs
<
sizeof
(
hints_key
),
"[dev_mngr] Could not generate AFE bind address from "
"configuration file
\n
"
,
err_cfg_exit
,
DMNGR_ERR_CFG
);
DBE_DEBUG
(
DBG_DEV_MNGR
|
DBG_LVL_INFO
,
"[dev_mngr_core] AFE hint endpoint "
"hash key:
\"
%s
\"
, value:
\"
%s
\"\n
"
,
hints_key
,
hints_value
);
/* Insert this value in the hash table */
errs
=
zhash_insert
(
hints_h
,
hints_key
,
hints_value
);
ASSERT_TEST
(
errs
==
0
,
"Could not find insert AFE endpoint to "
"hash table"
,
err_cfg_exit
,
DMNGR_ERR_CFG
);
}
}
err_cfg_exit:
return
err
;
}
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