Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
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
White Rabbit Switch - Software
Commits
7e4799f3
Commit
7e4799f3
authored
Dec 01, 2016
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/libwr: move timeout functions from HAL
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
b9d40358
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
11 deletions
+55
-11
Makefile
userspace/libwr/Makefile
+2
-1
timeout.h
userspace/libwr/include/libwr/timeout.h
+16
-0
timeout.c
userspace/libwr/timeout.c
+27
-0
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+5
-5
hal_timing.c
userspace/wrsw_hal/hal_timing.c
+5
-5
No files found.
userspace/libwr/Makefile
View file @
7e4799f3
...
@@ -3,7 +3,8 @@ OBJS = init.o fpga_io.o util.o pps_gen.o i2c.o shw_io.o i2c_bitbang.o \
...
@@ -3,7 +3,8 @@ OBJS = init.o fpga_io.o util.o pps_gen.o i2c.o shw_io.o i2c_bitbang.o \
ptpd_netif.o hal_client.o
\
ptpd_netif.o hal_client.o
\
shmem.o rt_client.o
\
shmem.o rt_client.o
\
dot-config.o wrs-msg.o
\
dot-config.o wrs-msg.o
\
mac.o
mac.o
\
timeout.o
LIB
=
libwr.a
LIB
=
libwr.a
...
...
userspace/libwr/include/libwr/timeout.h
0 → 100644
View file @
7e4799f3
#ifndef __TIMEOUT_H
#define __TIMEOUT_H
#include <stdint.h>
#include <libwr/util.h>
typedef
struct
{
int
repeat
;
uint64_t
start_tics
;
uint64_t
timeout
;
}
timeout_t
;
int
libwr_tmo_init
(
timeout_t
*
tmo
,
uint32_t
milliseconds
,
int
repeat
);
int
libwr_tmo_restart
(
timeout_t
*
tmo
);
int
libwr_tmo_expired
(
timeout_t
*
tmo
);
#endif
userspace/
wrsw_hal/timeout.h
→
userspace/
libwr/timeout.c
View file @
7e4799f3
#ifndef __TIMEOUT_H
#define __TIMEOUT_H
#include <stdio.h>
#include <stdint.h>
#include <stdint.h>
#include <sys/time.h>
#include <sys/time.h>
#include "libwr/util.h"
#include <libwr/timeout.h>
typedef
struct
{
int
repeat
;
uint64_t
start_tics
;
uint64_t
timeout
;
}
timeout_t
;
static
inline
int
tmo_init
(
timeout_t
*
tmo
,
uint32_t
milliseconds
,
int
repeat
)
int
libwr_tmo_init
(
timeout_t
*
tmo
,
uint32_t
milliseconds
,
int
repeat
)
{
{
tmo
->
repeat
=
repeat
;
tmo
->
repeat
=
repeat
;
tmo
->
start_tics
=
get_monotonic_us
();
tmo
->
start_tics
=
get_monotonic_us
();
tmo
->
timeout
=
(
uint64_t
)
milliseconds
*
1000ULL
;
tmo
->
timeout
=
(
uint64_t
)
milliseconds
*
1000ULL
;
return
0
;
return
0
;
}
}
static
inline
int
tmo_restart
(
timeout_t
*
tmo
)
int
libwr_tmo_restart
(
timeout_t
*
tmo
)
{
{
tmo
->
start_tics
=
get_monotonic_us
();
tmo
->
start_tics
=
get_monotonic_us
();
return
0
;
return
0
;
}
}
static
inline
int
tmo_expired
(
timeout_t
*
tmo
)
int
libwr_tmo_expired
(
timeout_t
*
tmo
)
{
{
int
expired
=
(
get_monotonic_us
()
-
tmo
->
start_tics
>
tmo
->
timeout
);
int
expired
=
(
get_monotonic_us
()
-
tmo
->
start_tics
>
tmo
->
timeout
);
...
@@ -35,5 +25,3 @@ static inline int tmo_expired(timeout_t * tmo)
...
@@ -35,5 +25,3 @@ static inline int tmo_expired(timeout_t * tmo)
return
expired
;
return
expired
;
}
}
#endif
userspace/wrsw_hal/hal_ports.c
View file @
7e4799f3
...
@@ -22,10 +22,10 @@
...
@@ -22,10 +22,10 @@
#include <libwr/sfp_lib.h>
#include <libwr/sfp_lib.h>
#include <libwr/shmem.h>
#include <libwr/shmem.h>
#include <libwr/config.h>
#include <libwr/config.h>
#include <libwr/timeout.h>
#include <ppsi/ppsi.h>
#include <ppsi/ppsi.h>
#include "wrsw_hal.h"
#include "wrsw_hal.h"
#include "timeout.h"
#include <rt_ipc.h>
#include <rt_ipc.h>
#include <hal_exports.h>
#include <hal_exports.h>
#include <libwr/hal_shmem.h>
#include <libwr/hal_shmem.h>
...
@@ -230,8 +230,8 @@ int hal_port_init_shmem(char *logfilename)
...
@@ -230,8 +230,8 @@ int hal_port_init_shmem(char *logfilename)
pr_info
(
"Initializing switch ports...
\n
"
);
pr_info
(
"Initializing switch ports...
\n
"
);
/* default timeouts */
/* default timeouts */
tmo_init
(
&
hal_port_tmo_sfp
,
SFP_POLL_INTERVAL
,
1
);
libwr_
tmo_init
(
&
hal_port_tmo_sfp
,
SFP_POLL_INTERVAL
,
1
);
tmo_init
(
&
hal_port_tmo_rts
,
RTS_POLL_INTERVAL
,
1
);
libwr_
tmo_init
(
&
hal_port_tmo_rts
,
RTS_POLL_INTERVAL
,
1
);
/* Open a single raw socket for accessing the MAC addresses, etc. */
/* Open a single raw socket for accessing the MAC addresses, etc. */
hal_port_fd
=
socket
(
AF_PACKET
,
SOCK_DGRAM
,
0
);
hal_port_fd
=
socket
(
AF_PACKET
,
SOCK_DGRAM
,
0
);
...
@@ -341,7 +341,7 @@ static void poll_rts_state(void)
...
@@ -341,7 +341,7 @@ static void poll_rts_state(void)
{
{
struct
rts_pll_state
*
hs
=
&
hal_port_rts_state
;
struct
rts_pll_state
*
hs
=
&
hal_port_rts_state
;
if
(
tmo_expired
(
&
hal_port_tmo_rts
))
{
if
(
libwr_
tmo_expired
(
&
hal_port_tmo_rts
))
{
hal_port_rts_state_valid
=
rts_get_state
(
hs
)
<
0
?
0
:
1
;
hal_port_rts_state_valid
=
rts_get_state
(
hs
)
<
0
?
0
:
1
;
if
(
!
hal_port_rts_state_valid
)
if
(
!
hal_port_rts_state_valid
)
printf
(
"rts_get_state failure, weird...
\n
"
);
printf
(
"rts_get_state failure, weird...
\n
"
);
...
@@ -618,7 +618,7 @@ static void hal_port_remove_sfp(struct hal_port_state * p)
...
@@ -618,7 +618,7 @@ static void hal_port_remove_sfp(struct hal_port_state * p)
/* detects insertion/removal of SFP transceivers */
/* detects insertion/removal of SFP transceivers */
static
void
hal_port_poll_sfp
(
void
)
static
void
hal_port_poll_sfp
(
void
)
{
{
if
(
tmo_expired
(
&
hal_port_tmo_sfp
))
{
if
(
libwr_
tmo_expired
(
&
hal_port_tmo_sfp
))
{
uint32_t
mask
=
shw_sfp_module_scan
();
uint32_t
mask
=
shw_sfp_module_scan
();
static
int
old_mask
=
0
;
static
int
old_mask
=
0
;
...
...
userspace/wrsw_hal/hal_timing.c
View file @
7e4799f3
...
@@ -9,9 +9,9 @@
...
@@ -9,9 +9,9 @@
#include <libwr/switch_hw.h>
#include <libwr/switch_hw.h>
#include <libwr/config.h>
#include <libwr/config.h>
#include <libwr/wrs-msg.h>
#include <libwr/wrs-msg.h>
#include <libwr/timeout.h>
#include "wrsw_hal.h"
#include "wrsw_hal.h"
#include "timeout.h"
#include <rt_ipc.h>
#include <rt_ipc.h>
#include <hal_exports.h>
#include <hal_exports.h>
...
@@ -57,7 +57,7 @@ int hal_init_timing(char *filename)
...
@@ -57,7 +57,7 @@ int hal_init_timing(char *filename)
switch
(
timing_mode
)
{
switch
(
timing_mode
)
{
case
HAL_TIMING_MODE_GRAND_MASTER
:
case
HAL_TIMING_MODE_GRAND_MASTER
:
rts_set_mode
(
RTS_MODE_GM_EXTERNAL
);
rts_set_mode
(
RTS_MODE_GM_EXTERNAL
);
tmo_init
(
&
lock_tmo
,
LOCK_TIMEOUT_EXT
,
0
);
libwr_
tmo_init
(
&
lock_tmo
,
LOCK_TIMEOUT_EXT
,
0
);
break
;
break
;
default:
/* never hit, but having it here prevents a warning */
default:
/* never hit, but having it here prevents a warning */
...
@@ -66,14 +66,14 @@ int hal_init_timing(char *filename)
...
@@ -66,14 +66,14 @@ int hal_init_timing(char *filename)
case
HAL_TIMING_MODE_FREE_MASTER
:
case
HAL_TIMING_MODE_FREE_MASTER
:
case
HAL_TIMING_MODE_BC
:
case
HAL_TIMING_MODE_BC
:
rts_set_mode
(
RTS_MODE_GM_FREERUNNING
);
rts_set_mode
(
RTS_MODE_GM_FREERUNNING
);
tmo_init
(
&
lock_tmo
,
LOCK_TIMEOUT_INT
,
0
);
libwr_
tmo_init
(
&
lock_tmo
,
LOCK_TIMEOUT_INT
,
0
);
break
;
break
;
}
}
while
(
1
)
{
while
(
1
)
{
struct
rts_pll_state
pstate
;
struct
rts_pll_state
pstate
;
if
(
tmo_expired
(
&
lock_tmo
))
{
if
(
libwr_
tmo_expired
(
&
lock_tmo
))
{
pr_error
(
"Can't lock the PLL. "
pr_error
(
"Can't lock the PLL. "
"If running in the GrandMaster mode, "
"If running in the GrandMaster mode, "
"are you sure the 1-PPS and 10 MHz "
"are you sure the 1-PPS and 10 MHz "
...
@@ -82,7 +82,7 @@ int hal_init_timing(char *filename)
...
@@ -82,7 +82,7 @@ int hal_init_timing(char *filename)
if
(
timing_mode
==
HAL_TIMING_MODE_GRAND_MASTER
)
{
if
(
timing_mode
==
HAL_TIMING_MODE_GRAND_MASTER
)
{
/*ups... something went wrong, try again */
/*ups... something went wrong, try again */
rts_set_mode
(
RTS_MODE_GM_EXTERNAL
);
rts_set_mode
(
RTS_MODE_GM_EXTERNAL
);
tmo_init
(
&
lock_tmo
,
LOCK_TIMEOUT_EXT
,
0
);
libwr_
tmo_init
(
&
lock_tmo
,
LOCK_TIMEOUT_EXT
,
0
);
}
else
{
}
else
{
pr_error
(
"Got timeout
\n
"
);
pr_error
(
"Got timeout
\n
"
);
return
-
1
;
return
-
1
;
...
...
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