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
923912fe
Commit
923912fe
authored
Sep 04, 2019
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
589d3c1f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
10 deletions
+89
-10
hal_shmem.h
userspace/libwr/include/libwr/hal_shmem.h
+1
-0
hal_port_fsm.c
userspace/wrsw_hal/hal_port_fsm.c
+11
-0
hal_port_fsm_rx.c
userspace/wrsw_hal/hal_port_fsm_rx.c
+65
-3
hal_port_fsm_tx.c
userspace/wrsw_hal/hal_port_fsm_tx.c
+6
-6
hal_port_gen_fsm.c
userspace/wrsw_hal/hal_port_gen_fsm.c
+5
-0
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+1
-1
No files found.
userspace/libwr/include/libwr/hal_shmem.h
View file @
923912fe
...
...
@@ -85,6 +85,7 @@ typedef struct {
/* Low Phase Drift Calibration for rx */
typedef
struct
{
timeout_t
link_timeout
;
timeout_t
align_timeout
;
int
attempts
;
}
halPortLpdcRx_t
;
...
...
userspace/wrsw_hal/hal_port_fsm.c
View file @
923912fe
...
...
@@ -130,10 +130,13 @@ static halPortFsmGen_t _portFsm = {
static
int
_hal_port_state_init
(
void
*
vpfg
,
int
eventMsk
,
int
isNewState
)
{
struct
hal_port_state
*
ps
=
((
halPortFsmGen_t
*
)
vpfg
)
->
ps
;
// printf("HalPortStateIni ps %p hwi %d\n", ps, ps->hw_index );
//
if
(
isNewState
)
{
_init_port
(
ps
);
/* Init the tx state machine */
hal_port_tx_setup_init_fsm
(
ps
);
hal_port_rx_setup_init_fsm
(
ps
);
}
/* if final state reached for tx setup state machine
* then we can go to DISABLED state
...
...
@@ -179,6 +182,8 @@ static int _hal_port_state_link_down(void *vpfg, int eventMsk, int isNewState) {
return
0
;
}
// printf("port %d link down state\n", ps->hw_index);
//
if
(
isNewState
)
{
_reset_port
(
ps
);
// clears ps->tx_cal_pending & ps->calib*, except ps->calib.bitslide_ps
/* Init the rx state machine */
...
...
@@ -310,10 +315,12 @@ void hal_port_state_fsm_init( struct hal_port_state * ps ) {
for
(
portIndex
=
0
;
portIndex
<
HAL_MAX_PORTS
;
portIndex
++
)
{
if
(
ps
->
in_use
)
{
_portFsm
.
ps
=
ps
;
_portFsm
.
st
=&
ps
->
portStates
;
ps
->
portStates
.
state
=-
1
;
_fireState
(
&
_portFsm
,
HAL_PORT_STATE_INIT
);
}
ps
++
;
/* Next port */
}
...
...
@@ -325,12 +332,16 @@ void hal_port_state_fsm( struct hal_port_state * ps ) {
hal_port_poll_rts_state
();
// Update rts state on all ports
// printf("hal_port_state_fsm ENTRY\n");
/* Call state machine for all ports */
for
(
portIndex
=
0
;
portIndex
<
HAL_MAX_PORTS
;
portIndex
++
)
{
if
(
ps
->
in_use
)
{
_portFsm
.
ps
=
ps
;
_portFsm
.
st
=&
ps
->
portStates
;
// printf("port %d %p in_use %d\n", ps->hw_index, ps, ps->in_use);
/* Update evt_linkUp */
if
(
_get_port_link_state
(
ps
,
&
ps
->
evt_linkUp
)
==-
1
)
{
// IOTCL error : We put -1 in the link state. It will be considered as invalid
...
...
userspace/wrsw_hal/hal_port_fsm_rx.c
View file @
923912fe
...
...
@@ -23,6 +23,7 @@
#include "hal_port_leds.h"
#include "hal_port_fsm_rxP.h"
#include "hal_port_fsm_txP.h"
/**
* State machine
...
...
@@ -122,15 +123,25 @@ static __inline__ void updatePllState(struct hal_port_state * ps) {
* nothing to do, go to DONE and wait for link up
* fi
*/
static
int
_hal_port_rx_setup_state_start
(
void
*
vpfg
,
int
eventMsk
,
int
isNewState
)
{
struct
hal_port_state
*
ps
=
((
halPortFsmGen_t
*
)
vpfg
)
->
ps
;
if
(
ps
->
lpdc
.
txSetupStates
.
state
!=
HAL_PORT_TX_SETUP_STATE_DONE
)
{
// printf("***** too early to fire rx fsm\n");
return
0
;
}
if
(
ps
->
lpdc
.
isSupported
)
{
// LPDC support
pcs_writel
(
ps
,
MDIO_LPC_CTRL_TX_ENABLE
|
MDIO_LPC_CTRL_DMTD_SOURCE_RXRECCLK
,
MDIO_LPC_CTRL
);
// printf("p %d early: %d\n", ps->hw_index, _isHalRxSetupEventEarlyLinkUp(eventMsk) ? 1: 0);
if
(
_isHalRxSetupEventEarlyLinkUp
(
eventMsk
))
{
halPortLpdcRx_t
*
rxSetup
=
ps
->
lpdc
.
rxSetup
;
...
...
@@ -157,6 +168,7 @@ static int _hal_port_rx_setup_state_reset_pcs(void *vpfg, int eventMsk, int isNe
halPortLpdcRx_t
*
rxSetup
=
ps
->
lpdc
.
rxSetup
;
libwr_tmo_init
(
&
rxSetup
->
link_timeout
,
100
,
1
);
libwr_tmo_init
(
&
rxSetup
->
align_timeout
,
1
,
1
);
pcs_writel
(
ps
,
MDIO_LPC_CTRL_RESET_RX
|
MDIO_LPC_CTRL_TX_ENABLE
|
...
...
@@ -169,7 +181,6 @@ static int _hal_port_rx_setup_state_reset_pcs(void *vpfg, int eventMsk, int isNe
rxSetup
->
attempts
++
;
_fireState
(
vpfg
,
HAL_PORT_RX_SETUP_STATE_WAIT_LOCK
);
}
return
0
;
}
...
...
@@ -182,12 +193,39 @@ static int _hal_port_rx_setup_state_wait_lock(void *vpfg, int eventMsk, int isNe
struct
hal_port_state
*
ps
=
((
halPortFsmGen_t
*
)
vpfg
)
->
ps
;
halPortLpdcRx_t
*
rxSetup
=
ps
->
lpdc
.
rxSetup
;
// printf("**** port %p lup %d alined %d\n", ps->hw_index, _isHalRxSetupEventEarlyLinkUp(eventMsk)?1:0, _isHalRxSetupEventRxAligned(eventMsk)?1:0);
if
(
_isHalRxSetupEventEarlyLinkUp
(
eventMsk
))
{
if
(
!
libwr_tmo_expired
(
&
rxSetup
->
align_timeout
)
)
{
return
0
;
// call me again 1ms later...
}
if
(
_isHalRxSetupEventRxAligned
(
eventMsk
))
{
// int i;
rts_enable_ptracker
(
ps
->
hw_index
,
0
);
rts_enable_ptracker
(
ps
->
hw_index
,
1
);
_pll_state
.
channels
[
ps
->
hw_index
].
flags
=
0
;
/* uint32_t val;
pcs_readl( ps, MDIO_LPC_STAT, &val );
printf("*** PRE lpc_stat %x\n", val );
printf("****************** %d go to f****ing validate state [%d %d]\n", ps->hw_index, _isHalRxSetupEventEarlyLinkUp(eventMsk), _isHalRxSetupEventRxAligned(eventMsk) );
for(i = 0; i < 1; i++)
{
uint32_t val;
pcs_readl( ps, MDIO_LPC_STAT, &val );
printf("*** lpc_stat %x\n", val );
usleep(100000);
}
dupa = ps->hw_index;*/
_fireState
(
vpfg
,
HAL_PORT_RX_SETUP_STATE_VALIDATE
);
}
else
{
_fireState
(
vpfg
,
HAL_PORT_RX_SETUP_STATE_RESET_PCS
);
...
...
@@ -209,18 +247,25 @@ static int _hal_port_rx_setup_state_validate(void *vpfg, int eventMsk, int isNew
updatePllState
(
ps
);
if
(
_pll_state
.
channels
[
ps
->
hw_index
].
flags
&
CHAN_PMEAS_READY
)
{
if
(
_pll_state
.
channels
[
ps
->
hw_index
].
flags
&
CHAN_PMEAS_READY
)
{
int
phase
=
_pll_state
.
channels
[
ps
->
hw_index
].
phase_loopback
;
halPortLpdcRx_t
*
rxSetup
=
ps
->
lpdc
.
rxSetup
;
uint32_t
value
;
// printf("******************validate state callied [%d %d]\n", _isHalRxSetupEventEarlyLinkUp(eventMsk), _isHalRxSetupEventRxAligned(eventMsk) );
//
pcs_writel
(
ps
,
MDIO_LPC_CTRL_RX_ENABLE
|
MDIO_LPC_CTRL_TX_ENABLE
|
MDIO_LPC_CTRL_DMTD_SOURCE_RXRECCLK
,
MDIO_LPC_CTRL
);
//*(volatile int *)(0xdeadeef) = 0;
// exit(-1);
pcs_writel
(
ps
,
BMCR_ANENABLE
|
BMCR_ANRESTART
,
MII_BMCR
);
//TODO-ML: change to port name
pr
_info
(
"wri%d: RX calibration complete at phase %d "
pr
intf
(
"wri%d: RX calibration complete at phase %d "
"ps (after %d attempts).
\n
"
,
ps
->
hw_index
+
1
,
phase
,
rxSetup
->
attempts
);
rts_enable_ptracker
(
ps
->
hw_index
,
0
);
...
...
@@ -244,6 +289,8 @@ static int _hal_port_rx_setup_state_done(void *vpfg, int eventMsk, int isNewStat
/* earlyLinkUp detection only if LPDC support */
if
(
ps
->
lpdc
.
isSupported
)
{
// printf("******************done state callied [%d %d]\n", _isHalRxSetupEventEarlyLinkUp(eventMsk), _isHalRxSetupEventRxAligned(eventMsk) );
//
if
(
!
_isHalRxSetupEventEarlyLinkUp
(
eventMsk
))
{
// Port went done
pr_info
(
"rxcal: early link flag lost on port wri%d
\n
"
,
...
...
@@ -273,6 +320,20 @@ static int _buildEvents(void *vpfg) {
uint32_t
mioLpcStat
;
if
(
pcs_readl
(
ps
,
MDIO_LPC_STAT
,
&
mioLpcStat
)
>=
0
)
{
/* if( (ps->hw_index == 9) && (mioLpcStat & MDIO_LPC_STAT_LINK_ALIGNED ) && (ps->lpdc.rxSetupStates.state != HAL_PORT_RX_SETUP_STATE_START) )
{
printf("*************MioLpcStat 1ST %x\n", mioLpcStat & MDIO_LPC_STAT_LINK_ALIGNED);
int i;
for(i=0;i<2;i++)
{
pcs_readl(ps, MDIO_LPC_STAT,&mioLpcStat);
printf("*************MioLpcStat %x\n", mioLpcStat & MDIO_LPC_STAT_LINK_ALIGNED);
usleep(100000);
}
}
printf("********************** vpfg %p port %d lpcstat %x\n", vpfg, ps->hw_index, mioLpcStat ); */
if
(
mioLpcStat
&
MDIO_LPC_STAT_LINK_UP
)
portEventMask
|=
HAL_PORT_RX_SETUP_EVENT_EARLY_LINK_UP
;
if
(
mioLpcStat
&
MDIO_LPC_STAT_LINK_ALIGNED
)
...
...
@@ -287,6 +348,7 @@ static int _buildEvents(void *vpfg) {
* Init RX SETUP FSM
*/
void
hal_port_rx_setup_init_fsm
(
struct
hal_port_state
*
ps
)
{
// printf("initRxFsm: ps %p (idx %d)\n", ps, ps->hw_index);
_portFsm
.
ps
=
ps
;
_portFsm
.
st
=&
ps
->
lpdc
.
rxSetupStates
;
ps
->
lpdc
.
rxSetupStates
.
state
=-
1
;
...
...
userspace/wrsw_hal/hal_port_fsm_tx.c
View file @
923912fe
...
...
@@ -243,13 +243,13 @@ static int _hal_port_tx_setup_state_measure_phase(void *vpfg, int eventMsk, int
int
phase_max
=
txSetup
->
expected_phase
+
txSetup
->
tollerance
;
//TODO-ML: change to name of interface, remove two phases
pr_info
(
"TX Calibration: upd port %d phase %d %d after %d "
"attempts target %d tollerance %d (temp = %.3f degC)
\n
"
,
ps
->
hw_index
,
txSetup
->
measured_phase
,
txSetup
->
measured_phase
,
txSetup
->
attempts
,
txSetup
->
expected_phase
,
txSetup
->
tollerance
,
hal_get_fpga_temperature
()
/
256
.
0
);
//
pr_info("TX Calibration: upd port %d phase %d %d after %d "
//
"attempts target %d tollerance %d (temp = %.3f degC)\n",
//
ps->hw_index, txSetup->measured_phase, txSetup->measured_phase,
//
txSetup->attempts, txSetup->expected_phase, txSetup->tollerance,
//
hal_get_fpga_temperature() / 256.0);
if
(
_within_range
(
phase
,
phase_min
,
phase_max
,
16000
))
{
if
(
_within_range
(
phase
,
phase_min
,
phase_max
,
16000
))
{
int
i
;
pr_info
(
"FIX port %d phase %d after %d attempts "
...
...
userspace/wrsw_hal/hal_port_gen_fsm.c
View file @
923912fe
...
...
@@ -18,12 +18,15 @@ int hal_port_generic_fsm( halPortFsmGen_t *pfg) {
if
(
pfg
->
ps
->
in_use
)
{
int
portEventMask
,
isNewState
;
char
*
evtStr
=
_generic_build_events
(
pfg
,
&
portEventMask
);
/* Check if state has changed */
if
(
(
isNewState
=
_isPendingState
(
pfg
))
==
1
)
{
_consumeState
(
pfg
);
}
// printf("ps i %d newstate %d pmask %x state_idx %d gs %d\n", pfg->ps->hw_index, isNewState, portEventMask, pfg->pt->state, _getState(pfg));
/* Call state entry */
if
(
portEventMask
||
isNewState
)
{
halPortStateTable_t
*
pt
=
pfg
->
pt
;
...
...
@@ -51,6 +54,8 @@ static char * _generic_build_events( halPortFsmGen_t *pfg, int *portEventMask) {
*
portEventMask
=
0
;
// printf("************call genbuildedvents\n");
if
(
pfg
->
fctBuilEvents
)
*
portEventMask
=
(
*
pfg
->
fctBuilEvents
)(
pfg
);
if
(
FSM_GEN_DEBUG
)
{
...
...
userspace/wrsw_hal/hal_ports.c
View file @
923912fe
...
...
@@ -282,7 +282,7 @@ int pcs_writel(struct hal_port_state *ps, uint16_t value, int reg)
uint32_t
rv
;
strncpy
(
ifr
.
ifr_name
,
ps
->
name
,
sizeof
(
ifr
.
ifr_name
));
// printf("***** pcs_wrtel %d %d %x\n", ps->hw_index, reg, value );
rv
=
NIC_WRITE_PHY_CMD
(
reg
,
value
);
ifr
.
ifr_data
=
(
void
*
)
&
rv
;
if
(
ioctl
(
halPorts
.
hal_port_fd
,
PRIV_IOCPHYREG
,
&
ifr
)
<
0
)
...
...
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