Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
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
Software for White Rabbit PTP Core
Commits
e3c75e5d
Commit
e3c75e5d
authored
Oct 29, 2018
by
li hongming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Solve several bugs introduced by missing dualport configuration.
parent
456a64e2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
69 deletions
+85
-69
endpoint.c
dev/endpoint.c
+3
-3
ep_pfilter.c
dev/ep_pfilter.c
+3
-3
minic.c
dev/minic.c
+6
-6
rxts_calibrator.c
dev/rxts_calibrator.c
+1
-1
arp.c
lib/arp.c
+4
-4
wrc_main.c
wrc_main.c
+68
-52
No files found.
dev/endpoint.c
View file @
e3c75e5d
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
The bigger, the better precision, but slower rate */
The bigger, the better precision, but slower rate */
#define DMTD_AVG_SAMPLES 256
#define DMTD_AVG_SAMPLES 256
static
int
autoneg_enabled
;
static
int
autoneg_enabled
[
wr_num_ports
]
;
volatile
struct
EP_WB
*
EP
[
wr_num_ports
];
volatile
struct
EP_WB
*
EP
[
wr_num_ports
];
/* functions for accessing PCS (MDIO) registers */
/* functions for accessing PCS (MDIO) registers */
...
@@ -112,7 +112,7 @@ int ep_enable(int enabled, int autoneg, int port)
...
@@ -112,7 +112,7 @@ int ep_enable(int enabled, int autoneg, int port)
/* Enable TX/RX paths, reset RMON counters */
/* Enable TX/RX paths, reset RMON counters */
EP
[
port
]
->
ECR
=
EP_ECR_TX_EN
|
EP_ECR_RX_EN
|
EP_ECR_RST_CNT
;
EP
[
port
]
->
ECR
=
EP_ECR_TX_EN
|
EP_ECR_RX_EN
|
EP_ECR_RST_CNT
;
autoneg_enabled
=
autoneg
;
autoneg_enabled
[
port
]
=
autoneg
;
/* Reset the GTP Transceiver - it's important to do the GTP phase alignment every time
/* Reset the GTP Transceiver - it's important to do the GTP phase alignment every time
we start up the software, otherwise the calibration RX/TX deltas may not be correct */
we start up the software, otherwise the calibration RX/TX deltas may not be correct */
...
@@ -140,7 +140,7 @@ int ep_link_up(uint16_t * lpa,int port)
...
@@ -140,7 +140,7 @@ int ep_link_up(uint16_t * lpa,int port)
uint16_t
flags
=
MDIO_MSR_LSTATUS
;
uint16_t
flags
=
MDIO_MSR_LSTATUS
;
volatile
uint16_t
msr
;
volatile
uint16_t
msr
;
if
(
autoneg_enabled
)
if
(
autoneg_enabled
[
port
]
)
flags
|=
MDIO_MSR_ANEGCOMPLETE
;
flags
|=
MDIO_MSR_ANEGCOMPLETE
;
msr
=
pcs_read
(
MDIO_REG_MSR
,
port
);
msr
=
pcs_read
(
MDIO_REG_MSR
,
port
);
...
...
dev/ep_pfilter.c
View file @
e3c75e5d
...
@@ -60,7 +60,7 @@ void pfilter_init_default(int port)
...
@@ -60,7 +60,7 @@ void pfilter_init_default(int port)
uint32_t
m
,
*
vini
,
*
vend
,
*
v
,
*
v_vlan
=
NULL
;
uint32_t
m
,
*
vini
,
*
vend
,
*
v
,
*
v_vlan
=
NULL
;
uint64_t
cmd_word
;
uint64_t
cmd_word
;
int
i
;
int
i
;
static
int
inited
[
2
]
;
static
int
inited
;
uint32_t
latency_ethtype
=
CONFIG_LATENCY_ETHTYPE
;
uint32_t
latency_ethtype
=
CONFIG_LATENCY_ETHTYPE
;
/* If vlan, use rule-set 1, else rule-set 0 */
/* If vlan, use rule-set 1, else rule-set 0 */
...
@@ -92,14 +92,14 @@ void pfilter_init_default(int port)
...
@@ -92,14 +92,14 @@ void pfilter_init_default(int port)
* First time: be extra-careful that the rule-set is ok. But if
* First time: be extra-careful that the rule-set is ok. But if
* we change MAC address, this is re-called, and v[] is already changed
* we change MAC address, this is re-called, and v[] is already changed
*/
*/
if
(
!
inited
[
port
]
)
{
if
(
!
inited
)
{
if
(
(((
v
[
2
]
>>
13
)
&
0xffff
)
!=
0x1234
)
if
(
(((
v
[
2
]
>>
13
)
&
0xffff
)
!=
0x1234
)
||
(((
v
[
4
]
>>
13
)
&
0xffff
)
!=
0x5678
)
||
(((
v
[
4
]
>>
13
)
&
0xffff
)
!=
0x5678
)
||
(((
v
[
6
]
>>
13
)
&
0xffff
)
!=
0x9abc
))
{
||
(((
v
[
6
]
>>
13
)
&
0xffff
)
!=
0x9abc
))
{
pp_printf
(
"pfilter: wrong rule-set, can't apply
\n
"
);
pp_printf
(
"pfilter: wrong rule-set, can't apply
\n
"
);
return
;
return
;
}
}
inited
[
port
]
++
;
inited
++
;
}
}
/*
/*
* Patch the local MAC address in place,
* Patch the local MAC address in place,
...
...
dev/minic.c
View file @
e3c75e5d
...
@@ -40,7 +40,7 @@
...
@@ -40,7 +40,7 @@
fc = (raw >> 28) & 0xf;
fc = (raw >> 28) & 0xf;
struct
wr_minic
minic
[
wr_num_ports
];
struct
wr_minic
minic
[
wr_num_ports
];
int
ver_supported
;
int
ver_supported
[
wr_num_ports
]
;
static
inline
void
minic_writel
(
uint32_t
reg
,
uint32_t
data
,
int
port
)
static
inline
void
minic_writel
(
uint32_t
reg
,
uint32_t
data
,
int
port
)
{
{
...
@@ -81,10 +81,10 @@ void minic_init(int port)
...
@@ -81,10 +81,10 @@ void minic_init(int port)
if
(
MINIC_MCR_VER_R
(
mcr
)
!=
MINIC_HDL_VERSION
)
{
if
(
MINIC_MCR_VER_R
(
mcr
)
!=
MINIC_HDL_VERSION
)
{
pp_printf
(
"Error: Minic HDL version %d not supported by sw
\n
"
,
pp_printf
(
"Error: Minic HDL version %d not supported by sw
\n
"
,
MINIC_MCR_VER_R
(
mcr
));
MINIC_MCR_VER_R
(
mcr
));
ver_supported
=
0
;
ver_supported
[
port
]
=
0
;
return
;
return
;
}
}
ver_supported
=
1
;
ver_supported
[
port
]
=
1
;
/* disable interrupts, driver does polling */
/* disable interrupts, driver does polling */
minic_writel
(
MINIC_REG_EIC_IDR
,
MINIC_EIC_IDR_TX
|
minic_writel
(
MINIC_REG_EIC_IDR
,
MINIC_EIC_IDR_TX
|
...
@@ -103,7 +103,7 @@ int minic_poll_rx(port)
...
@@ -103,7 +103,7 @@ int minic_poll_rx(port)
{
{
uint32_t
mcr
;
uint32_t
mcr
;
if
(
!
ver_supported
)
if
(
!
ver_supported
[
port
]
)
return
0
;
return
0
;
mcr
=
minic_readl
(
MINIC_REG_MCR
,
port
);
mcr
=
minic_readl
(
MINIC_REG_MCR
,
port
);
...
@@ -127,7 +127,7 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
...
@@ -127,7 +127,7 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
/* check if there is something in the Rx FIFO to be retrieved */
/* check if there is something in the Rx FIFO to be retrieved */
if
((
minic_readl
(
MINIC_REG_MCR
,
port
)
&
MINIC_MCR_RX_EMPTY
)
||
!
ver_supported
)
if
((
minic_readl
(
MINIC_REG_MCR
,
port
)
&
MINIC_MCR_RX_EMPTY
)
||
!
ver_supported
[
port
]
)
return
0
;
return
0
;
hdr_size
=
0
;
hdr_size
=
0
;
...
@@ -230,7 +230,7 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
...
@@ -230,7 +230,7 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t *payload, uint32_t size,
int
i
,
hsize
;
int
i
,
hsize
;
uint16_t
*
ptr
;
uint16_t
*
ptr
;
if
(
!
ver_supported
)
if
(
!
ver_supported
[
port
]
)
return
0
;
return
0
;
if
(
hdr
->
ethtype
==
htons
(
0x8100
))
if
(
hdr
->
ethtype
==
htons
(
0x8100
))
...
...
dev/rxts_calibrator.c
View file @
e3c75e5d
...
@@ -261,7 +261,7 @@ int calib_t24p(int mode, uint32_t *value, int port)
...
@@ -261,7 +261,7 @@ int calib_t24p(int mode, uint32_t *value, int port)
{
{
int
ret
;
int
ret
;
if
(
(
mode
==
WRC_MODE_SLAVE
)
&&
(
port
==
0
)
)
if
(
mode
==
WRC_MODE_SLAVE
)
ret
=
calib_t24p_slave
(
value
,
port
);
ret
=
calib_t24p_slave
(
value
,
port
);
else
else
ret
=
calib_t24p_master
(
value
,
port
);
ret
=
calib_t24p_master
(
value
,
port
);
...
...
lib/arp.c
View file @
e3c75e5d
...
@@ -19,9 +19,9 @@
...
@@ -19,9 +19,9 @@
static
uint8_t
__arp_queue
[
2
][
128
];
static
uint8_t
__arp_queue
[
2
][
128
];
static
struct
wrpc_socket
__static_arp_socket
[
2
]
=
{
static
struct
wrpc_socket
__static_arp_socket
[
2
]
=
{
{.
queue
.
buff
=
__arp_queue
[
0
],
{.
queue
.
buff
=
__arp_queue
[
0
],
.
queue
.
size
=
sizeof
(
__arp_queue
),},
.
queue
.
size
=
sizeof
(
__arp_queue
[
0
]
),},
{.
queue
.
buff
=
__arp_queue
[
1
],
{.
queue
.
buff
=
__arp_queue
[
1
],
.
queue
.
size
=
sizeof
(
__arp_queue
),},
.
queue
.
size
=
sizeof
(
__arp_queue
[
1
]
),},
};
};
static
struct
wrpc_socket
*
arp_socket
[
2
];
static
struct
wrpc_socket
*
arp_socket
[
2
];
...
@@ -108,7 +108,7 @@ static int arp_poll(void)
...
@@ -108,7 +108,7 @@ static int arp_poll(void)
&
addr
,
buf
,
sizeof
(
buf
),
0
,
port
))
>
0
)
&
addr
,
buf
,
sizeof
(
buf
),
0
,
port
))
>
0
)
{
{
if
((
len
=
process_arp
(
buf
,
len
,
0
))
>
0
)
if
((
len
=
process_arp
(
buf
,
len
,
0
))
>
0
)
ptpd_netif_sendto
(
arp_socket
,
&
addr
,
buf
,
len
,
0
,
port
);
ptpd_netif_sendto
(
arp_socket
[
port
]
,
&
addr
,
buf
,
len
,
0
,
port
);
ret
=
1
;
ret
=
1
;
}
}
}
}
...
@@ -140,7 +140,7 @@ int send_arp(uint8_t * hisIP, int port)
...
@@ -140,7 +140,7 @@ int send_arp(uint8_t * hisIP, int port)
getIP
(
buf
+
ARP_SPA
,
port
);
getIP
(
buf
+
ARP_SPA
,
port
);
memset
(
buf
+
ARP_THA
,
0x00
,
6
);
/* Broadcast */
memset
(
buf
+
ARP_THA
,
0x00
,
6
);
/* Broadcast */
memcpy
(
buf
+
ARP_TPA
,
hisIP
,
4
);
memcpy
(
buf
+
ARP_TPA
,
hisIP
,
4
);
return
(
ptpd_netif_sendto
(
arp_socket
,
&
addr
,
buf
,
ARP_END
+
10
,
0
,
port
));
return
(
ptpd_netif_sendto
(
arp_socket
[
port
]
,
&
addr
,
buf
,
ARP_END
+
10
,
0
,
port
));
}
}
DEFINE_WRC_TASK
(
arp
)
=
{
DEFINE_WRC_TASK
(
arp
)
=
{
...
...
wrc_main.c
View file @
e3c75e5d
...
@@ -43,7 +43,7 @@ int wrc_ui_refperiod = TICS_PER_SECOND; /* 1 sec */
...
@@ -43,7 +43,7 @@ int wrc_ui_refperiod = TICS_PER_SECOND; /* 1 sec */
int
wrc_phase_tracking
=
1
;
int
wrc_phase_tracking
=
1
;
char
wrc_hw_name
[
HW_NAME_LENGTH
];
char
wrc_hw_name
[
HW_NAME_LENGTH
];
uint32_t
cal_phase_transition
[
wr_num_ports
]
=
{
2389
,
2389
}
;
uint32_t
cal_phase_transition
[
wr_num_ports
];
int
wrc_vlan_number
=
CONFIG_VLAN_NR
;
int
wrc_vlan_number
=
CONFIG_VLAN_NR
;
...
@@ -78,25 +78,23 @@ static void wrc_initialize(void)
...
@@ -78,25 +78,23 @@ static void wrc_initialize(void)
if
(
get_persistent_mac
(
ONEWIRE_PORT
,
mac_addr
[
0
])
==
-
1
)
{
if
(
get_persistent_mac
(
ONEWIRE_PORT
,
mac_addr
[
0
])
==
-
1
)
{
pp_printf
(
"Unable to determine MAC address
\n
"
);
pp_printf
(
"Unable to determine MAC address
\n
"
);
mac_addr
[
0
][
0
]
=
0x22
;
/*
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
{
mac_addr[0][1] = 0x33; *
mac_addr
[
0
][
0
]
=
0x22
+
port
;
//fallback MAC if get_persistent_mac fails
mac_addr[0][2] = 0x44; * fallback MAC if get_persistent_mac fails
mac_addr
[
0
][
1
]
=
0x33
;
mac_addr[0][3] = 0x55; *
mac_addr
[
0
][
2
]
=
0x44
;
mac_addr[0][4] = 0x66; *
mac_addr
[
0
][
3
]
=
0x55
;
mac_addr[0][5] = 0x77; */
mac_addr
[
0
][
4
]
=
0x66
;
mac_addr
[
1
][
0
]
=
0x23
;
/*
mac_addr
[
0
][
5
]
=
0x77
;
mac_addr[1][1] = 0x33; *
}
mac_addr[1][2] = 0x44; * fallback MAC if get_persistent_mac fails
mac_addr[1][3] = 0x55; *
mac_addr[1][4] = 0x66; *
mac_addr[1][5] = 0x77; */
}
else
{
}
else
{
mac_addr
[
1
][
0
]
=
mac_addr
[
0
][
0
]
+
1
;
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
{
mac_addr
[
1
][
1
]
=
mac_addr
[
0
][
1
];
mac_addr
[
port
][
0
]
=
mac_addr
[
0
][
0
]
+
port
;
mac_addr
[
1
][
2
]
=
mac_addr
[
0
][
2
];
mac_addr
[
port
][
1
]
=
mac_addr
[
0
][
1
];
mac_addr
[
1
][
3
]
=
mac_addr
[
0
][
3
];
mac_addr
[
port
][
2
]
=
mac_addr
[
0
][
2
];
mac_addr
[
1
][
4
]
=
mac_addr
[
0
][
4
];
mac_addr
[
port
][
3
]
=
mac_addr
[
0
][
3
];
mac_addr
[
1
][
5
]
=
mac_addr
[
0
][
5
];
mac_addr
[
port
][
4
]
=
mac_addr
[
0
][
4
];
mac_addr
[
port
][
5
]
=
mac_addr
[
0
][
5
];
}
}
}
net_rst
();
net_rst
();
...
@@ -119,8 +117,10 @@ static void wrc_initialize(void)
...
@@ -119,8 +117,10 @@ static void wrc_initialize(void)
shw_pps_gen_init
();
shw_pps_gen_init
();
wrc_ptp_init
();
wrc_ptp_init
();
/* try reading t24 phase transition from EEPROM */
/* try reading t24 phase transition from EEPROM */
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
){
cal_phase_transition
[
port
]
=
2389
;
// default
calib_t24p
(
WRC_MODE_MASTER
,
&
cal_phase_transition
[
port
],
port
);
calib_t24p
(
WRC_MODE_MASTER
,
&
cal_phase_transition
[
port
],
port
);
}
spll_very_init
();
spll_very_init
();
usleep_init
();
usleep_init
();
...
@@ -129,8 +129,11 @@ static void wrc_initialize(void)
...
@@ -129,8 +129,11 @@ static void wrc_initialize(void)
wrc_ui_mode
=
UI_SHELL_MODE
;
wrc_ui_mode
=
UI_SHELL_MODE
;
_endram
=
ENDRAM_MAGIC
;
_endram
=
ENDRAM_MAGIC
;
wrc_ptp_set_mode
(
WRC_MODE_MASTER
,
1
);
for
(
port
=
1
;
port
<
wr_num_ports
;
port
++
)
wrc_ptp_set_mode
(
WRC_MODE_MASTER
,
port
);
wrc_ptp_set_mode
(
WRC_MODE_SLAVE
,
0
);
wrc_ptp_set_mode
(
WRC_MODE_SLAVE
,
0
);
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
{
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
{
wrc_ptp_start
(
port
);
wrc_ptp_start
(
port
);
}
}
...
@@ -148,42 +151,55 @@ uint8_t link_status[wr_num_ports];
...
@@ -148,42 +151,55 @@ uint8_t link_status[wr_num_ports];
static
int
wrc_check_link
(
void
)
static
int
wrc_check_link
(
void
)
{
{
static
int
prev_state
[]
=
{
-
1
,
-
1
};
static
int
prev_state
[
wr_num_ports
];
static
uint8_t
first_run
=
0
;
int
state
[
wr_num_ports
];
int
state
[
wr_num_ports
];
int
rv
=
0
;
int
rv
=
0
;
int
port
;
int
port
;
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
{
state
[
port
]
=
ep_link_up
(
NULL
,
port
);
if
(
first_run
==
0
)
{
if
(
!
prev_state
[
port
]
&&
state
[
port
])
{
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
{
wrc_verbose
(
"Port 0 Link up.
\n
"
);
prev_state
[
port
]
=
0
;
if
(
port
==
0
)
}
gpio_out
(
GPIO_LED_LINK
,
1
);
first_run
++
;
else
}
else
{
gpio_out
(
GPIO_DP_LED_LINK
,
1
);
for
(
port
=
0
;
port
<
wr_num_ports
;
port
++
)
{
sfp_match
(
port
);
state
[
port
]
=
ep_link_up
(
NULL
,
port
);
wrc_ptp_start
(
port
);
link_status
[
port
]
=
LINK_WENT_UP
;
if
(
!
prev_state
[
port
]
&&
state
[
port
])
{
rv
=
1
;
wrc_verbose
(
"Port 0 Link up.
\n
"
);
}
else
if
(
prev_state
[
port
]
&&
!
state
[
port
])
{
if
(
port
==
0
)
gpio_out
(
GPIO_LED_LINK
,
1
);
wrc_verbose
(
"Port %d Link down.
\n
"
,
port
);
else
gpio_out
(
GPIO_DP_LED_LINK
,
1
);
if
(
port
==
0
)
sfp_match
(
port
);
gpio_out
(
GPIO_LED_LINK
,
0
);
wrc_ptp_start
(
port
);
else
link_status
[
port
]
=
LINK_WENT_UP
;
gpio_out
(
GPIO_DP_LED_LINK
,
0
);
/* special case */
link_status
[
port
]
=
LINK_WENT_DOWN
;
if
(
port
==
0
)
wrc_ptp_stop
(
port
);
{
rv
=
1
;
spll_init
(
SPLL_MODE_SLAVE
,
0
,
1
);
/* special case */
shw_pps_gen_unmask_output
(
0
);
if
(
port
==
0
)
{
}
spll_init
(
SPLL_MODE_FREE_RUNNING_MASTER
,
0
,
1
);
rv
=
1
;
shw_pps_gen_enable_output
(
0
);
}
else
if
(
prev_state
[
port
]
&&
!
state
[
port
])
{
wrc_verbose
(
"Port %d Link down.
\n
"
,
port
);
if
(
port
==
0
)
gpio_out
(
GPIO_LED_LINK
,
0
);
else
gpio_out
(
GPIO_DP_LED_LINK
,
0
);
link_status
[
port
]
=
LINK_WENT_DOWN
;
wrc_ptp_stop
(
port
);
rv
=
1
;
/* special case */
if
(
port
==
0
)
{
spll_init
(
SPLL_MODE_FREE_RUNNING_MASTER
,
0
,
1
);
shw_pps_gen_enable_output
(
0
);
}
}
else
{
link_status
[
port
]
=
(
state
[
port
]
?
LINK_UP
:
LINK_DOWN
);
}
}
}
else
link_status
[
port
]
=
(
state
[
port
]
?
LINK_UP
:
LINK_DOWN
);
prev_state
[
port
]
=
state
[
port
];
}
prev_state
[
port
]
=
state
[
port
];
}
}
return
rv
;
return
rv
;
}
}
DEFINE_WRC_TASK
(
link
)
=
{
DEFINE_WRC_TASK
(
link
)
=
{
...
...
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