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
83
Issues
83
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
ad02993e
Commit
ad02993e
authored
Jul 19, 2019
by
Maciej Lipinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] first versio with detection of LPC and non-LPC ports
parent
fcbe242b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
65 additions
and
11 deletions
+65
-11
hal_shmem.h
userspace/libwr/include/libwr/hal_shmem.h
+6
-1
ppsi
userspace/ppsi
+1
-1
driver_stuff.h
userspace/wrsw_hal/driver_stuff.h
+6
-1
hal_ports.c
userspace/wrsw_hal/hal_ports.c
+52
-8
No files found.
userspace/libwr/include/libwr/hal_shmem.h
View file @
ad02993e
...
...
@@ -143,9 +143,13 @@ struct hal_port_state {
int
synchronized
;
// <>0 if port is synchronized
int
portInfoUpdated
;
// Set to 1 when updated
/* Indicate support for Low Phase Drift Calibration (read from GW)*/
int
lpc_supported
;
/* needed for the Low Phase Drift Calibration */
struct
hal_port_tx_setup_state
*
tx_setup_fsm
;
struct
hal_port_rx_setup_state
*
rx_setup_fsm
;
};
struct
hal_temp_sensors
{
...
...
@@ -156,7 +160,8 @@ struct hal_temp_sensors {
};
/* This is the overall structure stored in shared memory */
#define HAL_SHMEM_VERSION 13
/* Version 13, added Low Phase Drift Calib */
#define HAL_SHMEM_VERSION 14
/* Version 14, added flag for
Low Phase Drift Calib */
struct
hal_shmem_header
{
int
nports
;
...
...
ppsi
@
12e21844
Subproject commit
e72b21c976f6d25d9e1cc1ba592bb737ac3b4eed
Subproject commit
12e21844c12ef377ad0b953e62fce0867aa5b333
userspace/wrsw_hal/driver_stuff.h
View file @
ad02993e
...
...
@@ -33,4 +33,9 @@
#define MDIO_LPC_CTRL_DMTD_SOURCE_TXOUTCLK (1 << 14)
#define MDIO_LPC_CTRL_DMTD_SOURCE_RXRECCLK (0 << 14)
/*
* Address and mask to discover support for Low Phase Drift
* Calibration, taken from endpoint-regs.h
*/
#define EP_ECR_FEAT_LPC (1 << 28)
#define EP_ECR_ADDR 0x0
userspace/wrsw_hal/hal_ports.c
View file @
ad02993e
...
...
@@ -162,6 +162,43 @@ static int hal_port_check_presence(const char *if_name, unsigned char *mac)
memcpy
(
mac
,
ifr
.
ifr_hwaddr
.
sa_data
,
ETH_ALEN
);
return
1
;
}
static
uint32_t
ep_read
(
struct
hal_port_state
*
p
,
int
reg_addr
)
{
struct
ifreq
ifr
;
uint32_t
rv
;
strncpy
(
ifr
.
ifr_name
,
p
->
name
,
sizeof
(
ifr
.
ifr_name
));
rv
=
reg_addr
;
ifr
.
ifr_data
=
(
void
*
)
&
rv
;
pr_info
(
"raw fd %d name %s
\n
"
,
hal_port_fd
,
ifr
.
ifr_name
);
if
(
ioctl
(
hal_port_fd
,
PRIV_IOCREADREG
,
&
ifr
)
<
0
)
{
pr_error
(
"ioctl failed
\n
"
);
};
pr_info
(
"ep_read: reg %d data %x
\n
"
,
reg_addr
,
rv
);
return
rv
;
}
/* checks if the port supports Low Phase Drift Calibration*/
static
int
hal_port_check_lpc_support
(
struct
hal_port_state
*
p
)
{
uint32_t
rv
=
ep_read
(
p
,
EP_ECR_ADDR
);
if
(
rv
&
EP_ECR_FEAT_LPC
)
{
pr_info
(
"Supports for Low Phase Drift Calibration detected"
"at port %s
\n
"
,
p
->
name
);
return
1
;
}
else
{
pr_info
(
"NO supports for Low Phase Drift Calibration detected"
"at port %s
\n
"
,
p
->
name
);
return
0
;
}
}
/* Port initialization, from dot-config values */
static
int
hal_port_init
(
int
index
)
...
...
@@ -190,6 +227,7 @@ static int hal_port_init(int index)
p
->
state
=
HAL_PORT_STATE_INIT
;
p
->
in_use
=
1
;
p
->
lpc_supported
=
hal_port_check_lpc_support
(
p
);
p
->
tx_setup_fsm
=
malloc
(
sizeof
(
struct
hal_port_tx_setup_state
));
p
->
rx_setup_fsm
=
malloc
(
sizeof
(
struct
hal_port_rx_setup_state
));
...
...
@@ -484,11 +522,15 @@ static void hal_port_fsm(struct hal_port_state * p)
hal_port_link_down
(
p
,
link_up
);
//TODO-ML: this needs to be moved... it is done for each port
if
(
tx_fsm_done_for_all_ports
()
)
update_tx_calibration_file
();
tx_init_complete
=
tx_fsm_update
(
p
);
rx_fsm_update
(
p
);
if
(
p
->
lpc_supported
)
{
tx_init_complete
=
tx_fsm_update
(
p
);
rx_fsm_update
(
p
);
}
//TODO-ML: add here link_down check removed by Tom with additional check
// if (hal_port_link_down(p, link_up))
...
...
@@ -947,7 +989,7 @@ static void update_link_leds(void) {
for
(
i
=
0
;
i
<
HAL_MAX_PORTS
;
i
++
)
{
//TODO-ML: modify to use pointers
if
(
port
->
in_use
&&
if
(
port
->
in_use
&&
port
->
lpc_supported
&&
((
ports
[
i
].
rx_setup_fsm
->
state
!=
RX_SETUP_DONE
&&
ports
[
i
].
rx_setup_fsm
->
state
!=
RX_SETUP_STATE_INIT
)
||
ports
[
i
].
tx_setup_fsm
->
state
!=
TX_SETUP_DONE
))
...
...
@@ -1124,7 +1166,8 @@ static void update_tx_calibration_file(void)
int
i
;
for
(
i
=
0
;
i
<
HAL_MAX_PORTS
;
i
++
)
if
(
ports
[
i
].
in_use
&&
ports
[
i
].
tx_setup_fsm
->
cal_file_updated
)
if
(
ports
[
i
].
in_use
&&
ports
[
i
].
lpc_supported
&&
ports
[
i
].
tx_setup_fsm
->
cal_file_updated
)
return
;
if
(
file_exists
(
calibration_file_name
))
...
...
@@ -1136,7 +1179,7 @@ static void update_tx_calibration_file(void)
struct
config_file
*
cfg
=
cfg_load
(
calibration_file_name
,
1
);
for
(
i
=
0
;
i
<
HAL_MAX_PORTS
;
i
++
)
if
(
ports
[
i
].
in_use
)
if
(
ports
[
i
].
in_use
&&
ports
[
i
].
lpc_supported
)
{
char
key_name
[
80
];
snprintf
(
key_name
,
sizeof
(
key_name
),
"TX_PHASE_PORT%d"
,
ports
[
i
].
hw_index
);
...
...
@@ -1148,7 +1191,7 @@ static void update_tx_calibration_file(void)
cfg_close
(
cfg
);
for
(
i
=
0
;
i
<
HAL_MAX_PORTS
;
i
++
)
if
(
ports
[
i
].
in_use
)
if
(
ports
[
i
].
in_use
&&
ports
[
i
].
lpc_supported
)
ports
[
i
].
tx_setup_fsm
->
cal_file_updated
=
1
;
}
...
...
@@ -1166,7 +1209,7 @@ static void load_tx_calibration_file(void)
}
for
(
i
=
0
;
i
<
HAL_MAX_PORTS
;
i
++
)
if
(
ports
[
i
].
in_use
)
if
(
ports
[
i
].
in_use
&&
ports
[
i
].
lpc_supported
)
{
char
key_name
[
80
];
int
value
;
...
...
@@ -1188,7 +1231,8 @@ static int tx_fsm_done_for_all_ports(void)
{
int
i
;
for
(
i
=
0
;
i
<
HAL_MAX_PORTS
;
i
++
)
if
(
ports
[
i
].
in_use
&&
ports
[
i
].
tx_setup_fsm
->
state
!=
TX_SETUP_DONE
)
if
(
ports
[
i
].
in_use
&&
ports
[
i
].
lpc_supported
&&
ports
[
i
].
tx_setup_fsm
->
state
!=
TX_SETUP_DONE
)
return
0
;
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