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
3f4cdb32
Commit
3f4cdb32
authored
Aug 14, 2019
by
Jean-Claude BAU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code refactoring
- Change method names - Change variable location - Change includes - ...
parent
1aa1e384
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
119 additions
and
211 deletions
+119
-211
hal_shmem.h
userspace/libwr/include/libwr/hal_shmem.h
+2
-1
hal_exports.c
userspace/wrsw_hal/hal_exports.c
+13
-15
hal_main.c
userspace/wrsw_hal/hal_main.c
+11
-11
hal_port_fsm.c
userspace/wrsw_hal/hal_port_fsm.c
+6
-6
hal_port_fsm_pll.c
userspace/wrsw_hal/hal_port_fsm_pll.c
+3
-26
hal_port_gen_fsm.h
userspace/wrsw_hal/hal_port_gen_fsm.h
+1
-1
hal_port_leds.c
userspace/wrsw_hal/hal_port_leds.c
+1
-1
hal_port_leds.h
userspace/wrsw_hal/hal_port_leds.h
+1
-1
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+36
-88
hal_ports.h
userspace/wrsw_hal/hal_ports.h
+19
-2
hal_timer.c
userspace/wrsw_hal/hal_timer.c
+2
-2
hal_timer.h
userspace/wrsw_hal/hal_timer.h
+2
-2
hal_timing.c
userspace/wrsw_hal/hal_timing.c
+4
-10
hal_timing.h
userspace/wrsw_hal/hal_timing.h
+17
-0
wrsw_hal.h
userspace/wrsw_hal/wrsw_hal.h
+0
-44
hal.sct
userspace/wrsw_hal/yakindu/hal.sct
+1
-1
No files found.
userspace/libwr/include/libwr/hal_shmem.h
View file @
3f4cdb32
...
...
@@ -59,7 +59,6 @@ typedef struct hal_port_calibration {
struct
shw_sfp_caldata
sfp
;
struct
shw_sfp_header
sfp_header_raw
;
struct
shw_sfp_dom
sfp_dom_raw
;
int
sfpPresent
;
}
hal_port_calibration_t
;
typedef
struct
{
...
...
@@ -114,6 +113,8 @@ struct hal_port_state {
/* whether SFP has diagnostic Monitoring capability */
int
has_sfp_diag
;
/* True if SFP is inserted */
int
sfpPresent
;
/* whether the port shall be monitored by SNMP */
int
monitor
;
...
...
userspace/wrsw_hal/hal_exports.c
View file @
3f4cdb32
...
...
@@ -6,16 +6,16 @@
#include <signal.h>
#include <string.h>
#include <libwr/wrs-msg.h>
#include <libwr/pps_gen.h>
/* for direct access to DMPLL and PPS generator */
#include "wrsw_hal.h"
#include <rt_ipc.h>
#include <minipc.h>
#include <libwr/wrs-msg.h>
#include <libwr/pps_gen.h>
/* for direct access to DMPLL and PPS generator */
#include <libwr/shmem.h>
#include <hal_exports.h>
/* for exported structs/function protos */
#include "hal_exports.h"
/* for exported structs/function protos */
#include "hal_ports.h"
#include "hal_timing.h"
static
struct
minipc_ch
*
hal_ch
;
static
struct
hal_port_state
*
ports
;
...
...
@@ -55,11 +55,11 @@ int halexp_lock_cmd(const char *port_name, int command, int priority)
has already locked to and stabilized the reference
frequency */
case
HEXP_LOCK_CMD_CHECK
:
rval
=
hal_port_check_lock
(
port_name
);
rval
=
hal_port_check_lock
_by_name
(
port_name
);
if
(
rval
>
0
)
return
HEXP_LOCK_STATUS_LOCKED
;
else
if
(
!
rval
)
else
if
(
rval
==
0
)
return
HEXP_LOCK_STATUS_BUSY
;
else
return
HEXP_LOCK_STATUS_NONE
;
...
...
@@ -142,10 +142,10 @@ int halexp_pps_cmd(int cmd, hexp_pps_params_t * params)
return
shw_pps_gen_enable_output
(
params
->
pps_valid
);
case
HEXP_PPSG_CMD_SET_TIMING_MODE
:
return
hal_
set_timing
_mode
(
params
->
timing_mode
);
return
hal_
tmg_set
_mode
(
params
->
timing_mode
);
case
HEXP_PPSG_CMD_GET_TIMING_MODE
:{
ret
=
hal_
get_timing
_mode
();
ret
=
hal_
tmg_get
_mode
();
return
ret
;
}
...
...
@@ -160,12 +160,10 @@ int halexp_port_info_cmd(hexp_port_info_params_t * params)
{
int
i
;
for
(
i
=
0
;
i
<
params
->
numberPortInterfaces
;
i
++
)
hal_
update_port
_info
(
params
->
hIFace
[
i
].
name
,
params
->
hIFace
[
i
].
mode
,
params
->
hIFace
[
i
].
synchronized
);
hal_
port_update
_info
(
params
->
hIFace
[
i
].
name
,
params
->
hIFace
[
i
].
mode
,
params
->
hIFace
[
i
].
synchronized
);
return
1
;
}
extern
int
hal_port_any_locked
(
void
);
static
void
hal_cleanup_wripc
(
void
)
{
minipc_close
(
hal_ch
);
...
...
@@ -210,7 +208,7 @@ static int export_port_info_cmd(const struct minipc_pd *pd,
/* Creates a wripc server and exports all public API functions */
int
hal_
init_wripc
(
struct
hal_port_state
*
hal_ports
,
char
*
logfilename
)
int
hal_
wripc_init
(
struct
hal_port_state
*
hal_ports
,
char
*
logfilename
)
{
static
FILE
*
f
;
...
...
@@ -252,7 +250,7 @@ int hal_init_wripc(struct hal_port_state *hal_ports, char *logfilename)
}
/* wripc update function, must be called in the main program loop */
int
hal_
update_wripc
(
int
ms_timeout
)
int
hal_
wripc_update
(
int
ms_timeout
)
{
minipc_server_action
(
hal_ch
,
ms_timeout
);
return
0
;
...
...
userspace/wrsw_hal/hal_main.c
View file @
3f4cdb32
...
...
@@ -11,6 +11,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <rt_ipc.h>
#include <libwr/wrs-msg.h>
#include <libwr/switch_hw.h>
#include <libwr/shw_io.h>
...
...
@@ -21,9 +23,9 @@
#include <libwr/util.h>
#include <libwr/timeout.h>
#include "
wrsw_hal
.h"
#include "
hal_ports
.h"
#include "hal_timer.h"
#include
<rt_ipc.h>
#include
"hal_timing.h"
#define MAX_CLEANUP_CALLBACKS 16
...
...
@@ -141,16 +143,14 @@ static int hal_init(void)
/* Low-level hw init, init non-kernel drivers */
assert_init
(
shw_init
());
/*
read timing mode from dot-config
*/
assert_init
(
hal_
init_timing_mode
(
));
/*
Init timing part
*/
assert_init
(
hal_
tmg_init
(
logfilename
));
/* Initialize HAL's shmem - see hal_ports.c */
assert_init
(
hal_port_init_shmem
(
logfilename
));
assert_init
(
hal_init_timing
(
logfilename
));
assert_init
(
hal_port_shmem_init
(
logfilename
));
/* Initialize IPC/RPC - see hal_ports.c */
assert_init
(
hal_port_
init_wripc
(
logfilename
));
assert_init
(
hal_port_
wripc_init
(
logfilename
));
//everything is fine up to here, we can blink green LED
shw_io_write
(
shw_io_led_state_o
,
0
);
...
...
@@ -287,7 +287,7 @@ int main(int argc, char *argv[])
if
(
hal_init
())
exit
(
1
);
timer
I
nit
(
_timerParameters
,
MAIN_TIMER_COUNT
);
timer
_i
nit
(
_timerParameters
,
MAIN_TIMER_COUNT
);
/*
* Main loop update - polls for WRIPC requests and rolls the port
...
...
@@ -301,10 +301,10 @@ int main(int argc, char *argv[])
*/
for
(;;)
{
hal_
update_wripc
(
25
/* max ms delay */
);
hal_
wripc_update
(
25
/* max ms delay */
);
// Check main timers and call callback if timeout expires
timer
S
can
(
_timerParameters
,
MAIN_TIMER_COUNT
);
timer
_s
can
(
_timerParameters
,
MAIN_TIMER_COUNT
);
}
hal_shutdown
();
...
...
userspace/wrsw_hal/hal_port_fsm.c
View file @
3f4cdb32
...
...
@@ -14,10 +14,11 @@
#include <linux/if.h>
#include <rt_ipc.h>
#include <hal_exports.h>
#include <libwr/hal_shmem.h>
#include <libwr/switch_hw.h>
#include "hal_exports.h"
#include "hal_ports.h"
#include "hal_port_leds.h"
#include "hal_port_gen_fsm.h"
...
...
@@ -25,8 +26,7 @@
#include "hal_port_fsm_rx.h"
#include "hal_port_fsm_tx.h"
#include "hal_port_fsm_pll.h"
#include "wrsw_hal.h"
#include "hal_timing.h"
/**
...
...
@@ -262,7 +262,7 @@ static int _builPortEvents(void * vpfg) {
portEventMask
|=
HAL_PORT_EVENT_RESET
;
ps
->
evt_reset
=
0
;
}
portEventMask
|=
ps
->
calib
.
sfpPresent
?
portEventMask
|=
ps
->
sfpPresent
?
HAL_PORT_EVENT_SFP_INSERTED
:
HAL_PORT_EVENT_SFP_REMOVED
;
return
portEventMask
;
}
...
...
@@ -357,8 +357,8 @@ static void _init_port(struct hal_port_state * ps)
static
void
_unlock_port
(
struct
hal_port_state
*
ps
)
{
if
(
hal_
get_timing
_mode
()
==
HAL_TIMING_MODE_BC
)
{
hal_
set_timing
_mode
(
HAL_TIMING_MODE_FREE_MASTER
);
if
(
hal_
tmg_get
_mode
()
==
HAL_TIMING_MODE_BC
)
{
hal_
tmg_set
_mode
(
HAL_TIMING_MODE_FREE_MASTER
);
}
// Disable tracker
...
...
userspace/wrsw_hal/hal_port_fsm_pll.c
View file @
3f4cdb32
...
...
@@ -3,6 +3,7 @@
#include <libwr/hal_shmem.h>
#include "hal_ports.h"
#include "hal_timing.h"
#include "hal_port_fsm_pllP.h"
/**
...
...
@@ -27,7 +28,6 @@ static int _hal_port_pll_state_unlocked(void *vpfg, int eventMsk, int isNewState
static
int
_hal_port_pll_state_locked
(
void
*
vpfg
,
int
eventMsk
,
int
isNewState
);
static
int
_hal_port_pll_state_locking
(
void
*
vpfg
,
int
eventMsk
,
int
isNewState
);
static
int
_check_pll_lock
(
struct
hal_port_state
*
ps
);
static
halPortStateTable_t
_fsmStateTable
[]
=
{
...
...
@@ -157,11 +157,11 @@ static int _buildEvents(void * vpfg) {
int
portEventMask
=
HAL_PORT_PLL_EVENT_TIMER
;
int
tm
;
tm
=
hal_
get_timing
_mode
();
tm
=
hal_
tmg_get
_mode
();
ps
->
locked
=
0
;
if
(
tm
==
HAL_TIMING_MODE_BC
)
{
int
locked
=
_check_pll
_lock
(
ps
);
int
locked
=
hal_port_check
_lock
(
ps
);
if
(
locked
>=
0
)
{
ps
->
locked
=
locked
;
portEventMask
|=
locked
?
...
...
@@ -199,26 +199,3 @@ int hal_port_pll_state_fsm( struct hal_port_state * ps ) {
return
hal_port_generic_fsm
(
&
_portFsm
);
}
extern
struct
rts_pll_state
hal_port_rts_state
;
extern
int
hal_port_rts_state_valid
;
/* Returns 1 if the port is locked, 0 if unlocked, -1 in case of error */
static
int
_check_pll_lock
(
struct
hal_port_state
*
ps
)
{
struct
rts_pll_state
*
hs
=
getRtsStatePtr
();
if
(
!
ps
)
return
-
1
;
if
(
!
isRtsStateValid
())
return
-
1
;
if
(
hs
->
delock_count
>
0
)
return
-
1
;
return
(
hs
->
mode
==
RTS_MODE_BC
&&
hs
->
current_ref
==
ps
->
hw_index
&&
(
hs
->
flags
&
RTS_DMTD_LOCKED
)
&&
(
hs
->
flags
&
RTS_REF_LOCKED
));
}
userspace/wrsw_hal/hal_port_gen_fsm.h
View file @
3f4cdb32
...
...
@@ -13,7 +13,7 @@
#include <libwr/wrs-msg.h>
#include <libwr/hal_shmem.h>
#define FSM_GEN_DEBUG
1
#define FSM_GEN_DEBUG
0
#define FSM_SET_FCT_NAME(name) .fct=name, .fctName=#name
...
...
userspace/wrsw_hal/hal_port_leds.c
View file @
3f4cdb32
...
...
@@ -99,7 +99,7 @@ void led_link_update(struct hal_port_state *ps) {
}
void
led_sync_update
(
struct
hal_port_state
*
ps
)
void
led_sync
hed
_update
(
struct
hal_port_state
*
ps
)
{
int
i
;
...
...
userspace/wrsw_hal/hal_port_leds.h
View file @
3f4cdb32
...
...
@@ -16,6 +16,6 @@ extern void led_init_all_ports(struct hal_port_state *ps );
extern
void
led_set_wrmode
(
int
portIndex
,
int
val
);
extern
void
led_link_update
(
struct
hal_port_state
*
port
);
extern
void
led_set_synched
(
int
portIndex
,
int
val
);
extern
void
led_sync_update
(
struct
hal_port_state
*
port
);
extern
void
led_sync
hed
_update
(
struct
hal_port_state
*
port
);
#endif
userspace/wrsw_hal/hal_ports.c
View file @
3f4cdb32
...
...
@@ -16,6 +16,7 @@
#include <linux/if.h>
/* LOTs of hardware includes */
#include <rt_ipc.h>
#include <libwr/switch_hw.h>
#include <libwr/wrs-msg.h>
#include <libwr/pio.h>
...
...
@@ -23,22 +24,16 @@
#include <libwr/shmem.h>
#include <libwr/config.h>
#include <libwr/timeout.h>
#include <libwr/hal_shmem.h>
#include <ppsi/ppsi.h>
#include "wrsw_hal.h"
#include <rt_ipc.h>
#include <hal_exports.h>
#include <libwr/hal_shmem.h>
#include "driver_stuff.h"
#include "hal_exports.h"
#include "hal_timer.h"
#include "hal_port_fsm.h"
#include "hal_port_leds.h"
#include "hal_ports.h"
typedef
struct
{
struct
pp_instance
*
ppi
;
/* pointer to the ppi instance */
struct
pp_servo
servo_snapshot
;
/* image of a the ppsi servo */
}
inst_servo_t
;
#include "hal_timing.h"
extern
struct
hal_shmem_header
*
hal_shmem
;
extern
struct
wrs_shm_head
*
hal_shmem_hdr
;
...
...
@@ -97,19 +92,8 @@ static timer_parameter_t _timerParameters[] = {
.
cb
=
_cb_port_update_link_leds
},
};
#define PORT_TIMER_COUNT (sizeof(_timerParameters)/sizeof(timer_parameter_t))
int
hal_port_check_lock
(
const
char
*
port_name
);
int
hal_port_any_locked
(
void
)
{
if
(
!
isRtsStateValid
())
return
-
1
;
if
(
getRtsState
().
current_ref
==
REF_NONE
)
return
-
1
;
return
getRtsState
().
current_ref
;
}
#define PORT_TIMER_COUNT (sizeof(_timerParameters)/sizeof(timer_parameter_t))
/* checks if the port is supported by the FPGA firmware */
static
int
hal_port_check_presence
(
const
char
*
if_name
,
unsigned
char
*
mac
)
...
...
@@ -215,14 +199,14 @@ static int hal_port_init(struct hal_port_state *ps, int index)
/* Interates via all the ports defined in the config file and
* intializes them one after another. */
int
hal_port_
init_shmem
(
char
*
logfilename
)
int
hal_port_
shmem_init
(
char
*
logfilename
)
{
int
index
;
char
*
ret
;
pr_info
(
"Initializing switch ports...
\n
"
);
/* default timeouts */
timer
I
nit
(
_timerParameters
,
PORT_TIMER_COUNT
);
timer
_i
nit
(
_timerParameters
,
PORT_TIMER_COUNT
);
/* Open a single raw socket for accessing the MAC addresses, etc. */
halPorts
.
hal_port_fd
=
socket
(
AF_PACKET
,
SOCK_DGRAM
,
0
);
...
...
@@ -261,7 +245,7 @@ int hal_port_init_shmem(char *logfilename)
/* We are done, mark things as valid */
hal_shmem
->
nports
=
halPorts
.
numberOfPorts
;
hal_shmem
->
hal_mode
=
hal_
get_timing
_mode
();
hal_shmem
->
hal_mode
=
hal_
tmg_get
_mode
();
ret
=
libwr_cfg_get
(
"READ_SFP_DIAG_ENABLE"
);
if
(
ret
&&
!
strcmp
(
ret
,
"y"
))
{
...
...
@@ -280,10 +264,10 @@ int hal_port_init_shmem(char *logfilename)
return
0
;
}
int
hal_port_
init_wripc
(
char
*
logfilename
)
int
hal_port_
wripc_init
(
char
*
logfilename
)
{
/* Create a WRIPC server for HAL public API */
return
hal_
init_wripc
(
halPorts
.
ports
,
logfilename
);
return
hal_
wripc_init
(
halPorts
.
ports
,
logfilename
);
}
...
...
@@ -299,9 +283,6 @@ int hal_port_pshifter_busy()
hs
->
channels
[
hs
->
current_ref
].
flags
&
CHAN_SHIFTING
?
1
:
0
;
if
(
0
)
pr_info
(
"PSBusy %d, flags %x
\n
"
,
busy
,
hs
->
channels
[
hs
->
current_ref
].
flags
);
return
busy
;
}
...
...
@@ -386,7 +367,7 @@ static void hal_port_insert_sfp(struct hal_port_state * ps)
memset
(
&
ps
->
calib
.
sfp
,
0
,
sizeof
(
ps
->
calib
.
sfp
));
}
ps
->
calib
.
sfpPresent
=
1
;
ps
->
sfpPresent
=
1
;
shw_sfp_set_tx_disable
(
ps
->
hw_index
,
0
);
/* Copy the strings anyways, for informative value in shmem */
strncpy
(
ps
->
calib
.
sfp
.
vendor_name
,
(
void
*
)
shdr
.
vendor_name
,
16
);
...
...
@@ -437,12 +418,11 @@ static void hal_port_insert_sfp(struct hal_port_state * ps)
static
void
hal_port_remove_sfp
(
struct
hal_port_state
*
ps
)
{
// hal_port_link_down(p, 0);
/* clean SFP's details when removing SFP */
memset
(
&
ps
->
calib
.
sfp
,
0
,
sizeof
(
ps
->
calib
.
sfp
));
memset
(
&
ps
->
calib
.
sfp_header_raw
,
0
,
sizeof
(
struct
shw_sfp_header
));
memset
(
&
ps
->
calib
.
sfp_dom_raw
,
0
,
sizeof
(
struct
shw_sfp_dom
));
ps
->
has_sfp_diag
=
ps
->
calib
.
sfpPresent
=
0
;
ps
->
has_sfp_diag
=
ps
->
sfpPresent
=
0
;
}
/* detects insertion/removal of SFP transceivers */
...
...
@@ -483,6 +463,8 @@ static void hal_port_poll_sfp(void)
static
void
_cb_port_poll_rts_state
(
int
timerId
){
/* poll_rts_state does not write to shmem */
hal_port_poll_rts_state
();
// Update timing mode
hal_shmem
->
hal_mode
=
hal_tmg_get_mode
();
}
static
void
_cb_port_poll_sfp
(
int
timerId
){
...
...
@@ -501,7 +483,7 @@ static void _cb_port_poll_sfp_dom(int timerId){
/* read DOM only for plugged ports with DOM
* capabilities */
if
(
ps
->
in_use
&&
ps
->
calib
.
sfpPresent
&&
ps
->
sfpPresent
&&
ps
->
has_sfp_diag
)
{
shw_sfp_update_dom
(
ps
->
hw_index
,
&
sfp_dom_raw
[
i
]);
...
...
@@ -518,7 +500,7 @@ static void _cb_port_poll_sfp_dom(int timerId){
/* update DOM only for plugged ports with DOM
* capabilities */
if
(
ps
->
in_use
&&
ps
->
calib
.
sfpPresent
&&
ps
->
sfpPresent
&&
ps
->
has_sfp_diag
)
{
memcpy
(
&
halPorts
.
ports
[
i
].
calib
.
sfp_dom_raw
,
&
sfp_dom_raw
[
i
],
...
...
@@ -534,7 +516,7 @@ static void _cb_port_poll_sfp_dom(int timerId){
static
void
_cb_port_update_sync_leds
(
int
timerId
){
/* update LEDs of synced ports */
led_sync_update
(
halPorts
.
ports
);
led_sync
hed
_update
(
halPorts
.
ports
);
}
static
void
_cb_port_update_link_leds
(
int
timerId
){
...
...
@@ -545,7 +527,7 @@ static void _cb_port_update_link_leds(int timerId){
/* Executes the port FSM for all ports. Called regularly by the main loop. */
void
hal_port_update_all
()
{
timer
S
can
(
_timerParameters
,
PORT_TIMER_COUNT
);
timer
_s
can
(
_timerParameters
,
PORT_TIMER_COUNT
);
/* lock shmem */
wrs_shm_write
(
hal_shmem_hdr
,
WRS_SHM_WRITE_BEGIN
);
...
...
@@ -577,51 +559,37 @@ int hal_port_start_lock(const char *port_name, int priority)
ps
->
evt_lock
=
1
;
return
0
;
#if 0
int ret=-1;
if (!p && p->state != HAL_PORT_STATE_UP )
return -1; /* can't lock to a disconnected port */
pr_info("Locking to port: %s\n", port_name);
hal_port_poll_rts_state(); // update rts state
if ( (hal_get_timing_mode()==HAL_TIMING_MODE_BC) &&
(ret=rts_lock_channel(p->hw_index, 0))==0 ) {
/* lock shmem */
wrs_shm_write(hal_shmem_hdr, WRS_SHM_WRITE_BEGIN);
/* fixme: check the main FSM state before */
p->state = HAL_PORT_STATE_LOCKING;
wrs_shm_write(hal_shmem_hdr, WRS_SHM_WRITE_END);
}
return ret;
#endif
}
/* Returns 1 if the port is locked */
int
hal_port_check_lock
(
const
char
*
port_name
)
/* Returns 1 if the port is locked
, 0 if unlocked, -1 in case of error
*/
int
hal_port_check_lock
(
const
struct
hal_port_state
*
ps
)
{
const
struct
hal_port_state
*
p
=
hal_lookup_port
(
halPorts
.
ports
,
halPorts
.
numberOfPorts
,
port_name
);
struct
rts_pll_state
*
hs
=
getRtsStatePtr
();
if
(
!
p
)
return
0
;
/* was -1, but it would confuse the caller */
if
(
!
p
s
)
return
-
1
;
if
(
!
isRtsStateValid
()
)
return
0
;
if
(
!
isRtsStateValid
()
)
return
-
1
;
if
(
hs
->
delock_count
>
0
)
return
0
;
return
-
1
;
return
(
hs
->
mode
==
RTS_MODE_BC
&&
hs
->
current_ref
==
p
->
hw_index
&&
hs
->
current_ref
==
p
s
->
hw_index
&&
(
hs
->
flags
&
RTS_DMTD_LOCKED
)
&&
(
hs
->
flags
&
RTS_REF_LOCKED
));
}
/* Returns 1 if the port is locked */
int
hal_port_check_lock_by_name
(
const
char
*
port_name
)
{
const
struct
hal_port_state
*
ps
=
hal_lookup_port
(
halPorts
.
ports
,
halPorts
.
numberOfPorts
,
port_name
);
return
hal_port_check_lock
(
ps
);
}
int
hal_port_reset
(
const
char
*
port_name
)
{
struct
hal_port_state
*
ps
=
hal_lookup_port
(
halPorts
.
ports
,
...
...
@@ -632,29 +600,9 @@ int hal_port_reset(const char *port_name)
ps
->
evt_reset
=
1
;
return
0
;
#if 0
if (p->state != HAL_PORT_STATE_LINK_DOWN
&& p->state != HAL_PORT_STATE_DISABLED) {
/* turn off synced LED */
led_set_sync(p->hw_index, 0);
/* turn off link/wrmode LEDs */
led_set_wrmode(p->hw_index, SFP_LED_WRMODE_OFF);
hal_port_reset_state(p);
p->state = HAL_PORT_STATE_RESET;
rts_enable_ptracker(p->hw_index, 0);
pr_info("%s: link down\n", p->name);
return 1;
}
return 0;
#endif
}
void
hal_
update_port
_info
(
char
*
iface_name
,
int
mode
,
int
synchronized
){
void
hal_
port_update
_info
(
char
*
iface_name
,
int
mode
,
int
synchronized
){
int
i
;
struct
hal_port_state
*
ps
=
halPorts
.
ports
;
...
...
userspace/wrsw_hal/hal_ports.h
View file @
3f4cdb32
...
...
@@ -23,6 +23,8 @@ typedef struct {
}
hal_ports_t
;
typedef
void
(
*
hal_cleanup_callback_t
)(
void
);
#define isRtsStateValid() halPorts.rts_state_valid
#define setRtsStateValidity(value) halPorts.rts_state_valid=(value)
...
...
@@ -33,8 +35,23 @@ typedef struct {
extern
hal_ports_t
halPorts
;
extern
int
hal_port_poll_rts_state
(
void
);
extern
int
hal_port_poll_rts_state
(
void
);
extern
int
hal_get_timing_mode
(
void
);
extern
int
hal_port_start_lock
(
const
char
*
port_name
,
int
priority
);
extern
int
hal_port_enable_tracking
(
const
char
*
port_name
);
extern
int
hal_port_check_lock
(
const
struct
hal_port_state
*
ps
);
extern
int
hal_port_check_lock_by_name
(
const
char
*
port_name
);
extern
int
hal_port_reset
(
const
char
*
port_name
);
extern
int
hal_port_pshifter_busy
(
void
);
extern
void
hal_port_update_info
(
char
*
iface_name
,
int
mode
,
int
synchronized
);
extern
void
hal_port_update_all
(
void
);
extern
int
hal_port_shmem_init
(
char
*
logfilename
);
extern
int
hal_port_wripc_init
(
char
*
logfilename
);
extern
int
rts_lock_channel
(
int
channel
,
int
priority
);
extern
int
hal_wripc_init
(
struct
hal_port_state
*
hal_ports
,
char
*
logfilename
);
extern
int
hal_wripc_update
(
int
ms_timeout
);
extern
int
hal_check_running
(
void
);
extern
int
hal_add_cleanup_callback
(
hal_cleanup_callback_t
cb
);
#endif
userspace/wrsw_hal/hal_timer.c
View file @
3f4cdb32
...
...
@@ -10,7 +10,7 @@
#include "hal_timer.h"
void
timer
I
nit
(
timer_parameter_t
*
p
,
int
nbTimers
)
{
void
timer
_i
nit
(
timer_parameter_t
*
p
,
int
nbTimers
)
{
int
index
;
for
(
index
=
0
;
index
<
nbTimers
;
index
++
)
{
...
...
@@ -20,7 +20,7 @@ void timerInit(timer_parameter_t *p,int nbTimers) {
}
void
timer
S
can
(
timer_parameter_t
*
p
,
int
nbTimers
)
{
void
timer
_s
can
(
timer_parameter_t
*
p
,
int
nbTimers
)
{
int
index
;
for
(
index
=
0
;
index
<
nbTimers
;
index
++
)
{
...
...
userspace/wrsw_hal/hal_timer.h
View file @
3f4cdb32
...
...
@@ -20,7 +20,7 @@ typedef struct {
}
timer_parameter_t
;
extern
void
timer
I
nit
(
timer_parameter_t
*
p
,
int
nbTimers
);
extern
void
timer
S
can
(
timer_parameter_t
*
p
,
int
nbTimers
);
extern
void
timer
_i
nit
(
timer_parameter_t
*
p
,
int
nbTimers
);
extern
void
timer
_s
can
(
timer_parameter_t
*
p
,
int
nbTimers
);
#endif
userspace/wrsw_hal/hal_timing.c
View file @
3f4cdb32
...
...
@@ -11,12 +11,11 @@
#include <libwr/wrs-msg.h>
#include <libwr/timeout.h>
#include <hal_exports.h>
#include "wrsw_hal.h"
#include "hal_exports.h"
#include "hal_ports.h"
int
hal_
init_timing_mode
(
void
)
int
hal_
tmg_init
(
const
char
*
logfilename
)
{
if
(
rts_connect
(
NULL
)
<
0
)
{
pr_error
(
...
...
@@ -26,12 +25,7 @@ int hal_init_timing_mode(void)
return
0
;
}
int
hal_init_timing
(
char
*
filename
)
{
return
0
;
}
int
hal_get_timing_mode
(
void
)
int
hal_tmg_get_mode
(
void
)
{
struct
rts_pll_state
*
hs
=
getRtsStatePtr
();
...
...
@@ -49,7 +43,7 @@ int hal_get_timing_mode(void)
return
-
1
;
}
int
hal_
set_timing
_mode
(
uint32_t
tm
)
{
int
hal_
tmg_set
_mode
(
uint32_t
tm
)
{
int
ret
=
shw_pps_set_timing_mode
(
tm
);
hal_port_poll_rts_state
();
return
ret
;
...
...
userspace/wrsw_hal/hal_timing.h
0 → 100644
View file @
3f4cdb32
/*
* Copyright (C) 2019 CERN (www.cern.ch)
* Author: Jean-Claude BAU - CERN
*
* Released according to the GNU LGPL, version 2.1 or any later version.
*
*
*/
#ifndef HAL_TIMING_H
#define HAL_TIMING_H
extern
int
hal_tmg_set_mode
(
uint32_t
tm
);
extern
int
hal_tmg_get_mode
(
void
);
extern
int
hal_tmg_init
(
const
char
*
logfilename
);
#endif
userspace/wrsw_hal/wrsw_hal.h
deleted
100644 → 0
View file @
1aa1e384
#ifndef __WRSW_HAL_H
#define __WRSW_HAL_H
#include <inttypes.h>
typedef
void
(
*
hal_cleanup_callback_t
)(
void
);
int
hal_check_running
(
void
);
int
hal_parse_config
(
void
);
void
hal_config_set_config_file
(
const
char
*
str
);
int
hal_config_extra_cmdline
(
const
char
*
str
);
int
hal_config_get_int
(
const
char
*
name
,
int
*
value
);
int
hal_config_get_double
(
const
char
*
name
,
double
*
value
);
int
hal_config_get_string
(
const
char
*
name
,
char
*
value
,
int
max_len
);
int
hal_config_iterate
(
const
char
*
section
,
int
index
,
char
*
subsection
,
int
max_len
);
int
hal_port_init_shmem
(
char
*
logfilename
);
int
hal_port_init_wripc
(
char
*
logfilename
);
void
hal_port_update_all
(
void
);
void
hal_update_port_info
(
char
*
iface_name
,
int
mode
,
int
synchronized
);
struct
hexp_port_state
;
struct
hal_port_state
;
int
hal_init_wripc
(
struct
hal_port_state
*
hal_ports
,
char
*
logfilename
);
int
hal_update_wripc
(
int
ms_timeout
);
int
hal_add_cleanup_callback
(
hal_cleanup_callback_t
cb
);
int
hal_port_start_lock
(
const
char
*
port_name
,
int
priority
);
int
hal_port_check_lock
(
const
char
*
port_name
);
int
hal_port_reset
(
const
char
*
port_name
);
int
hal_port_enable_tracking
(
const
char
*
port_name
);
int
hal_port_poll_rts_state
(
void
);
int
hal_init_timing_mode
(
void
);
int
hal_init_timing
(
char
*
filename
);
int
hal_get_timing_mode
(
void
);
int
hal_set_timing_mode
(
uint32_t
tm
);
int
hal_port_pshifter_busy
(
void
);
#endif
userspace/wrsw_hal/yakindu/hal.sct
View file @
3f4cdb32
...
...
@@ -5,7 +5,7 @@
<vertices
xsi:type=
"sgraph:Entry"
xmi:id=
"_uf588LdfEemzI5ZuGbnP4A"
>
<outgoingTransitions
xmi:id=
"_ugB4wLdfEemzI5ZuGbnP4A"
specification=
""
target=
"_uf8ZMLdfEemzI5ZuGbnP4A"
/>
</vertices>
<vertices
xsi:type=
"sgraph:State"
xmi:id=
"_uf8ZMLdfEemzI5ZuGbnP4A"
specification=
"entry / port.lpcSupport=false

"
name=
"HAL_PORT_STATE_INIT"
incomingTransitions=
"_ugB4wLdfEemzI5ZuGbnP4A"
>
<vertices
xsi:type=
"sgraph:State"
xmi:id=
"_uf8ZMLdfEemzI5ZuGbnP4A"
specification=
"entry / port.lp
d
cSupport=false

"
name=
"HAL_PORT_STATE_INIT"
incomingTransitions=
"_ugB4wLdfEemzI5ZuGbnP4A"
>
<regions
xmi:id=
"_gj7iwLeKEemUVuDCbi9APQ"
name=
"TX_SETUP"
>
<vertices
xsi:type=
"sgraph:Entry"
xmi:id=
"_sPl4oLeKEemUVuDCbi9APQ"
>
<outgoingTransitions
xmi:id=
"_TqqU0LeLEemUVuDCbi9APQ"
specification=
""
target=
"_tLh8cLeKEemUVuDCbi9APQ"
/>
...
...
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