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
7
Merge Requests
7
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
e3886432
Commit
e3886432
authored
May 10, 2021
by
Adam Wujek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dump-info: add wrc_global_link
Dump link_up and vlan Signed-off-by:
Adam Wujek
<
adam.wujek@creotech.pl
>
parent
cccb8990
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
77 additions
and
24 deletions
+77
-24
ep_pfilter.c
dev/ep_pfilter.c
+3
-3
dump-info.c
dump-info.c
+8
-0
dump-info.h
include/dump-info.h
+2
-0
ptpd_netif.h
include/ptpd_netif.h
+1
-1
wrc.h
include/wrc.h
+1
-1
wrc_global.h
include/wrc_global.h
+9
-0
ipv4.c
lib/ipv4.c
+1
-1
net.c
lib/net.c
+5
-5
syslog.c
lib/syslog.c
+2
-2
monitor_ppsi.c
monitor/monitor_ppsi.c
+1
-1
cmd_vlan.c
shell/cmd_vlan.c
+3
-3
wrpc-dump.c
tools/wrpc-dump.c
+27
-0
wrc_main.c
wrc_main.c
+14
-7
No files found.
dev/ep_pfilter.c
View file @
e3886432
...
...
@@ -67,7 +67,7 @@ void ep_pfilter_init_default(struct wr_endpoint_device *dev)
uint32_t
latency_ethtype
=
CONFIG_LATENCY_ETHTYPE
;
/* If vlan, use rule-set 1, else rule-set 0 */
s
=
rule_sets
+
(
wrc_vlan_number
!=
0
);
s
=
rule_sets
+
(
*
wrc_vlan_number
!=
0
);
if
(
!
s
->
ini
)
{
mac_dbg
(
"no pfilter rule-set!
\n
"
);
return
;
...
...
@@ -140,10 +140,10 @@ void ep_pfilter_init_default(struct wr_endpoint_device *dev)
if
(((
*
v
>>
13
)
&
0xffff
)
==
0x0aaa
&&
((
*
v
>>
7
)
&
0x1f
)
==
7
)
{
mac_dbg
(
"fixing VLAN number in rule: use %i
\n
"
,
wrc_vlan_number
);
*
wrc_vlan_number
);
v_vlan
=
v
;
*
v
&=
~
(
0xffff
<<
13
);
*
v
|=
wrc_vlan_number
<<
13
;
*
v
|=
*
wrc_vlan_number
<<
13
;
}
}
...
...
dump-info.c
View file @
e3886432
...
...
@@ -13,6 +13,14 @@ struct dump_info dump_wrpc_info[] = {
DUMP_HEADER
(
"wrc_global"
),
DUMP_FIELD
(
uint32_t
,
magic
),
DUMP_FIELD
(
uint32_t
,
version
),
DUMP_FIELD
(
pointer
,
link_status
),
#undef DUMP_STRUCT
#define DUMP_STRUCT struct wrc_global_link
DUMP_HEADER
(
"wrc_global_link"
),
DUMP_FIELD
(
uint32_t
,
version
),
DUMP_FIELD
(
link_up_status
,
link_up
),
DUMP_FIELD
(
int
,
vlan
),
#undef DUMP_STRUCT
#define DUMP_STRUCT struct softpll_state
...
...
include/dump-info.h
View file @
e3886432
...
...
@@ -28,6 +28,7 @@ enum dump_type {
dump_type_pointer
,
dump_type_dummy
,
/* and this is ours */
dump_type_link_up_status
,
dump_type_yes_no
,
dump_type_spll_mode
,
dump_type_ip_address
,
...
...
@@ -44,6 +45,7 @@ typedef uint8_t dummy; /* use the smallest */
typedef
struct
{
unsigned
char
addr
[
4
];}
ip_address
;
typedef
uint8_t
yes_no
;
typedef
int
spll_mode
;
typedef
int
link_up_status
;
/*
* This is generated with the target compiler, and then linked
...
...
include/ptpd_netif.h
View file @
e3886432
...
...
@@ -18,7 +18,7 @@
#define PTPD_SOCK_UDP 0
/* wrong name, it should be "WRPC" */
#define PTPD_SOCK_RAW_ETHERNET 1
/* but used in ppsi, which I won't change */
extern
int
link_status
;
extern
int
*
link_status
;
// GCC-specific
#ifndef PACKED
...
...
include/wrc.h
View file @
e3886432
...
...
@@ -85,7 +85,7 @@
#define HAS_VLANS 0
#endif
extern
int
wrc_vlan_number
;
extern
int
*
wrc_vlan_number
;
int
wrc_mon_gui
(
void
);
void
redraw_gui
(
void
);
...
...
include/wrc_global.h
View file @
e3886432
...
...
@@ -4,9 +4,18 @@
#define WRC_G_MAGIC 0xADA5301E
#define WRC_G_VERSION 1
#define WRC_G_LINK_VERSION 1
struct
wrc_global_link
{
uint32_t
version
;
int
link_up
;
int
vlan
;
};
struct
wrc_global
{
uint32_t
magic
;
uint32_t
version
;
struct
wrc_global_link
*
link_status
;
};
...
...
lib/ipv4.c
View file @
e3886432
...
...
@@ -173,7 +173,7 @@ int ipv4_poll(void)
{
int
ret
=
0
;
if
(
link_status
==
NETIF_LINK_WENT_UP
&&
ip_status
==
IP_OK_BOOTP
)
if
(
*
link_status
==
NETIF_LINK_WENT_UP
&&
ip_status
==
IP_OK_BOOTP
)
ip_status
=
IP_TRAINING
;
ret
=
bootp_poll
();
...
...
lib/net.c
View file @
e3886432
...
...
@@ -239,7 +239,7 @@ int ptpd_netif_recvfrom(struct wrpc_socket *s, struct wr_sockaddr *from, void *d
q
->
avail
+=
wrap_copy_in
(
data
,
q
,
size
,
data_length
);
from
->
ethertype
=
ntohs
(
hdr
.
ethtype
);
from
->
vlan
=
wrc_vlan_number
;
/* has been checked in rcvd frame */
from
->
vlan
=
*
wrc_vlan_number
;
/* has been checked in rcvd frame */
memcpy
(
from
->
mac
,
hdr
.
srcmac
,
6
);
memcpy
(
from
->
mac_dest
,
hdr
.
dstmac
,
6
);
...
...
@@ -280,9 +280,9 @@ int ptpd_netif_sendto(struct wrpc_socket * sock, struct wr_sockaddr *to, void *d
memcpy
(
hdr
.
dstmac
,
to
->
mac
,
6
);
memcpy
(
hdr
.
srcmac
,
s
->
local_mac
,
6
);
if
(
wrc_vlan_number
)
{
if
(
*
wrc_vlan_number
)
{
hdr
.
ethtype
=
htons
(
0x8100
);
hdr
.
tag
=
htons
(
wrc_vlan_number
|
(
sock
->
prio
<<
13
));
hdr
.
tag
=
htons
(
*
wrc_vlan_number
|
(
sock
->
prio
<<
13
));
hdr
.
ethtype_2
=
sock
->
bind_addr
.
ethertype
;
/* net order */
}
else
{
hdr
.
ethtype
=
sock
->
bind_addr
.
ethertype
;
...
...
@@ -334,9 +334,9 @@ int net_bh_poll(void)
payload
+=
4
;
recvd
-=
4
;
}
if
((
ntohs
(
tag
)
&
0xfff
)
!=
wrc_vlan_number
)
{
if
((
ntohs
(
tag
)
&
0xfff
)
!=
*
wrc_vlan_number
)
{
net_verbose
(
"%s: want vlan %i, got %i: discard
\n
"
,
__func__
,
wrc_vlan_number
,
__func__
,
*
wrc_vlan_number
,
ntohs
(
tag
)
&
0xfff
);
return
0
;
}
...
...
lib/syslog.c
View file @
e3886432
...
...
@@ -139,9 +139,9 @@ int syslog_poll(void)
goto send;
}
if (link_status == NETIF_LINK_WENT_DOWN)
if (
*
link_status == NETIF_LINK_WENT_DOWN)
down_tics = now;
if (link_status == NETIF_LINK_UP && down_tics) {
if (
*
link_status == NETIF_LINK_UP && down_tics) {
down_tics = now - down_tics;
len = syslog_header(buf, SYSLOG_DEFAULT_LEVEL, ip);
len += pp_sprintf(buf + len, "Link up after %i.%03i s",
...
...
monitor/monitor_ppsi.c
View file @
e3886432
...
...
@@ -431,7 +431,7 @@ void print_main_data(void)
minic_get_stats
(
&
tx
,
&
rx
);
pcprintf
(
9
,
55
,
C_MAGENTA
,
"%7d"
,
rx
);
pprintf
(
9
,
65
,
"%7d"
,
tx
);
pprintf
(
9
,
75
,
"%4d"
,
wrc_vlan_number
);
pprintf
(
9
,
75
,
"%4d"
,
*
wrc_vlan_number
);
}
}
...
...
shell/cmd_vlan.c
View file @
e3886432
...
...
@@ -24,17 +24,17 @@ static int cmd_vlan(const char *args[])
pp_printf
(
"%i (
\"
%s
\"
) out of range
\n
"
,
i
,
args
[
1
]);
return
-
EINVAL
;
}
wrc_vlan_number
=
i
;
*
wrc_vlan_number
=
i
;
ep_pfilter_init_default
(
&
wrc_endpoint_dev
);
}
else
if
(
!
strcasecmp
(
args
[
0
],
"off"
))
{
wrc_vlan_number
=
0
;
*
wrc_vlan_number
=
0
;
ep_pfilter_init_default
(
&
wrc_endpoint_dev
);
}
else
{
return
-
EINVAL
;
}
pp_printf
(
"current vlan: %i (0x%x)
\n
"
,
wrc_vlan_number
,
wrc_vlan_number
);
*
wrc_vlan_number
,
*
wrc_vlan_number
);
return
0
;
}
...
...
tools/wrpc-dump.c
View file @
e3886432
...
...
@@ -14,6 +14,7 @@
#include <softpll_ng.h>
#include <revision.h>
#include <arch/lm32/crt0.h>
#include <dev/netif.h>
#include <dump-info.h>
#include "time_lib.h"
...
...
@@ -226,6 +227,22 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
i
==
3
?
'\n'
:
':'
);
break
;
case
dump_type_link_up_status
:
i
=
wrpc_get_l32
(
p
);
switch
(
i
)
{
ENUM_TO_P_IN_CASE
(
NETIF_LINK_DOWN
,
char_p
);
ENUM_TO_P_IN_CASE
(
NETIF_LINK_WENT_UP
,
char_p
);
ENUM_TO_P_IN_CASE
(
NETIF_LINK_WENT_DOWN
,
char_p
);
ENUM_TO_P_IN_CASE
(
NETIF_LINK_UP
,
char_p
);
default:
char_p
=
"Unknown"
;
}
printf
(
"%d"
,
i
);
print_str
(
char_p
);
printf
(
"
\n
"
);
break
;
default:
dump_one_field_ppsi_wrpc
(
type
,
size
,
p
,
i
);
break
;
...
...
@@ -333,9 +350,19 @@ void print_version(void)
void
dump_mem_wrpc_global
(
void
*
mapaddr
,
unsigned
long
wrc_global_off
)
{
unsigned
long
tmp_off
;
char
*
prefix
;
printf
(
"wrc_global at 0x%lx
\n
"
,
wrc_global_off
);
dump_many_fields
(
mapaddr
+
wrc_global_off
,
"wrc_global"
,
"wrc_global"
);
tmp_off
=
wrpc_get_pointer
(
mapaddr
+
wrc_global_off
,
"wrc_global"
,
"link_status"
);
if
(
tmp_off
)
{
prefix
=
"wrc_global.link_status"
;
printf
(
"%s at 0x%lx
\n
"
,
prefix
,
tmp_off
);
dump_many_fields
(
mapaddr
+
tmp_off
,
"wrc_global_link"
,
prefix
);
}
}
/* all of these are 0 by default */
...
...
wrc_main.c
View file @
e3886432
...
...
@@ -59,17 +59,26 @@ char wrc_hw_name[HW_NAME_LENGTH];
uint32_t
cal_phase_transition
=
2389
;
int
wrc_vlan_number
=
CONFIG_VLAN_NR
;
struct
wr_endpoint_device
wrc_endpoint_dev
;
int
wrc_wr_diags
(
void
);
// fixme: move the header
struct
wrc_global_link
wrc_global_link
=
{
.
version
=
WRC_G_LINK_VERSION
,
.
vlan
=
CONFIG_VLAN_NR
,
};
struct
wrc_global
wrc_global
=
{
.
magic
=
WRC_G_MAGIC
,
.
version
=
WRC_G_VERSION
,
.
link_status
=
&
wrc_global_link
,
};
int
*
link_status
=
&
wrc_global_link
.
link_up
;
int
*
wrc_vlan_number
=
&
wrc_global_link
.
vlan
;
static
void
wrc_initialize
(
void
)
{
#ifdef CONFIG_USE_SDB
...
...
@@ -118,11 +127,9 @@ static void wrc_initialize(void)
wrc_tasks_accounting_init
();
}
int
link_status
;
static
int
is_link_up
(
void
)
{
return
link_status
==
NETIF_LINK_UP
;
return
*
link_status
==
NETIF_LINK_UP
;
}
static
int
wrc_check_link
(
void
)
...
...
@@ -137,19 +144,19 @@ static int wrc_check_link(void)
gen_gpio_out
(
&
pin_sysc_led_link
,
1
);
sfp_match
(
0
);
wrc_ptp_start
();
link_status
=
NETIF_LINK_WENT_UP
;
*
link_status
=
NETIF_LINK_WENT_UP
;
rv
=
1
;
}
else
if
(
prev_state
&&
!
state
)
{
wrc_verbose
(
"Link down.
\n
"
);
wrc_events_ptp_link_down
();
event_post
(
WRC_EVENT_LINK_DOWN
);
gen_gpio_out
(
&
pin_sysc_led_link
,
0
);
link_status
=
NETIF_LINK_WENT_DOWN
;
*
link_status
=
NETIF_LINK_WENT_DOWN
;
wrc_ptp_stop
();
wrc_ptp_link_down
();
rv
=
1
;
}
else
link_status
=
(
state
?
NETIF_LINK_UP
:
NETIF_LINK_DOWN
);
*
link_status
=
(
state
?
NETIF_LINK_UP
:
NETIF_LINK_DOWN
);
prev_state
=
state
;
...
...
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