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
e1245831
Commit
e1245831
authored
Dec 09, 2019
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrsw_hal: cleanup of the previous commit
parent
bac5bbd9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
78 deletions
+10
-78
hal_port_fsm_rx.c
userspace/wrsw_hal/hal_port_fsm_rx.c
+9
-77
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+1
-1
No files found.
userspace/wrsw_hal/hal_port_fsm_rx.c
View file @
e1245831
...
...
@@ -14,7 +14,6 @@
#include <net/if.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <libwr/wrs-msg.h>
#include <libwr/hal_shmem.h>
...
...
@@ -110,15 +109,6 @@ static fsm_event_table_entry_t port_rx_setup_fsm_events[] = {
// hal_port_rts_state
static
struct
rts_pll_state
_pll_state
;
static
void
my_log
(
const
char
*
fmt
,
...)
{
char
str
[
1024
];
va_list
ap
;
va_start
(
ap
,
fmt
);
vsprintf
(
str
,
fmt
,
ap
);
printf
(
"[%lld] %s"
,
get_monotonic_us
(),
str
);
va_end
(
ap
);
}
static
inline
void
updatePllState
(
struct
hal_port_state
*
ps
)
{
// update PLL state once for all ports
...
...
@@ -275,10 +265,6 @@ static int _hal_port_rx_setup_state_wait_lock(fsm_t *fsm, int eventMsk, int isNe
return
0
;
// call me again 1ms later...
if
(
_isHalRxSetupEventRxAligned
(
eventMsk
))
{
uint32_t
stat
;
pcs_readl
(
ps
,
MDIO_LPC_STAT
,
&
stat
);
printf
(
"[port %d] RX aligned, LPC_STAT 0x%04x
\n
"
,
ps
->
hw_index
+
1
,
stat
);
rts_enable_ptracker
(
ps
->
hw_index
,
0
);
rts_enable_ptracker
(
ps
->
hw_index
,
1
);
...
...
@@ -318,7 +304,7 @@ static int _hal_port_rx_setup_state_validate(fsm_t *fsm, int eventMsk, int isNew
MDIO_LPC_CTRL
);
pcs_writel
(
ps
,
BMCR_ANENABLE
|
BMCR_ANRESTART
,
MII_BMCR
);
my_log
(
"wri%d: RX calibration complete at phase %d "
pr_info
(
"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
);
...
...
@@ -354,34 +340,6 @@ static int _hal_port_rx_setup_state_restart(fsm_t *fsm, int eventMsk, int isNewS
return
0
;
}
void
dump_rx_pattern
(
struct
hal_port_state
*
ps
)
{
uint32_t
rw
=
MDIO_LPC_CTRL_TX_ENABLE
|
MDIO_LPC_CTRL_RX_ENABLE
|
MDIO_LPC_CTRL_DMTD_SOURCE_RXRECCLK
;
uint32_t
rr
;
int
nbits
=
40
;
int
i
;
char
rval
[
41
];
pcs_writel
(
ps
,
rw
|
MDIO_LPC_CTRL_DBG_TRIG
,
MDIO_LPC_CTRL
);
pcs_writel
(
ps
,
rw
,
MDIO_LPC_CTRL
);
for
(
i
=
0
;
i
<
nbits
;
i
++
)
{
pcs_readl
(
ps
,
MDIO_LPC_STAT
,
&
rr
);
if
(
rr
&
MDIO_LPC_STAT_DBG_DATA
)
rval
[
nbits
-
1
-
i
]
=
'1'
;
else
rval
[
nbits
-
1
-
i
]
=
'0'
;
pcs_writel
(
ps
,
rw
|
MDIO_LPC_CTRL_DBG_SHIFT_EN
,
MDIO_LPC_CTRL
);
pcs_writel
(
ps
,
rw
,
MDIO_LPC_CTRL
);
}
rval
[
nbits
]
=
0
;
printf
(
"Port %d rxPattern='%s' ELKUP=%d RXALGN=%d
\n
"
,
ps
->
hw_index
+
1
,
rval
,
(
rr
&
MDIO_LPC_STAT_LINK_UP
?
1
:
0
),
(
rr
&
MDIO_LPC_STAT_LINK_ALIGNED
?
1
:
0
));
}
/*
* DONE state - wait for link_up
*
...
...
@@ -404,55 +362,29 @@ static int _hal_port_rx_setup_state_done(fsm_t *fsm, int eventMsk, int isNewStat
}
if
(
!
early_up
)
{
// Port went done
my_log
(
"rxcal: early link flag lost on port wri%d
\n
"
,
pr_info
(
"rxcal: early link flag lost on port wri%d
\n
"
,
ps
->
hw_index
+
1
);
fsm_fire_state
(
fsm
,
HAL_PORT_RX_SETUP_STATE_INIT
);
return
0
;
}
}
if
(
!
link_aligned
)
{
// Port went do
ne
my_log
(
"rxcal: aligned flag lost on port wri%d
\n
"
,
// Port went do
wn
pr_info
(
"rxcal: aligned flag lost on port wri%d
\n
"
,
ps
->
hw_index
+
1
);
fsm_fire_state
(
fsm
,
HAL_PORT_RX_SETUP_STATE_INIT
);
return
0
;
}
if
(
libwr_tmo_expired
(
&
ps
->
lpdc
.
rxSetup
->
align_to_link_timeout
)
&&
!
link_up
)
{
uint32_t
stat
,
msr
;
pcs_readl
(
ps
,
MDIO_LPC_STAT
,
&
stat
);
pcs_readl
(
ps
,
MII_BMSR
,
&
msr
);
// we are aligned but no Autoneg link up? restart the autonegotiation...
if
(
!
(
stat
&
MDIO_LPC_STAT_LINK_ALIGNED
))
{
my_log
(
"rxcal: link is fucked up and UNALIGNED. Retrying calibration on port %d
\n
"
,
ps
->
hw_index
+
1
);
fsm_fire_state
(
fsm
,
HAL_PORT_RX_SETUP_STATE_INIT
);
}
else
{
my_log
(
"rxcal: link is fucked up (AUTONEG), retrying it on port %d
\n
"
,
ps
->
hw_index
+
1
);
printf
(
"[port fup %d] LPC_STAT 0x%04x MSR 0x%04x
\n
"
,
ps
->
hw_index
+
1
,
stat
,
msr
);
dump_rx_pattern
(
ps
);
//pcs_writel(ps, BMCR_PDOWN, MII_BMCR);
shw_udelay
(
1000000
);
my_log
(
"Bring port back up...
\n
"
);
dump_rx_pattern
(
ps
);
pcs_writel
(
ps
,
BMCR_ANENABLE
|
BMCR_ANRESTART
,
MII_BMCR
);
dump_rx_pattern
(
ps
);
libwr_tmo_restart
(
&
ps
->
lpdc
.
rxSetup
->
align_to_link_timeout
);
}
// EARLY_UP + ALIGNED but autonegotiation fails? try restarting autoneg...
if
(
libwr_tmo_expired
(
&
ps
->
lpdc
.
rxSetup
->
align_to_link_timeout
)
&&
!
link_up
)
{
pcs_writel
(
ps
,
BMCR_ANENABLE
|
BMCR_ANRESTART
,
MII_BMCR
);
libwr_tmo_restart
(
&
ps
->
lpdc
.
rxSetup
->
align_to_link_timeout
);
return
0
;
}
}
if
(
ps
->
lpdc
.
globalLpdc
->
numberOfLpdcPorts
)
return
link_up
&&
libwr_tmo_expired
(
&
ps
->
lpdc
.
minCalibRx_timeout
)
?
1
:
0
;
else
...
...
userspace/wrsw_hal/hal_ports.c
View file @
e1245831
...
...
@@ -39,7 +39,7 @@
extern
struct
hal_shmem_header
*
hal_shmem
;
extern
struct
wrs_shm_head
*
hal_shmem_hdr
;
#define FSM_DEBUG
1
#define FSM_DEBUG
0
hal_ports_t
halPorts
;
...
...
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