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
873d6133
Commit
873d6133
authored
Aug 16, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'config-hot-fix-and-more'
parents
6a547b67
4b2c69d7
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
53 deletions
+99
-53
Kconfig
Kconfig
+9
-0
Makefile
Makefile
+2
-1
unix_debug_defconfig
configs/unix_debug_defconfig
+28
-0
ieee1588_types.h
include/ppsi/ieee1588_types.h
+4
-4
pp-instance.h
include/ppsi/pp-instance.h
+7
-9
msg.c
proto-standard/msg.c
+8
-8
state-slave.c
proto-standard/state-slave.c
+2
-2
timeout.c
timeout.c
+39
-29
No files found.
Kconfig
View file @
873d6133
...
...
@@ -162,9 +162,18 @@ config MAX_VLANS_PER_PORT
microcontroller-class architectures. Hosted builds
feature a bigger default, because they have no size constraints.
# I want a number, to be used without ifdef
config VLAN_ARRAY_SIZE
int
default 0 if !VLAN
default 1 if !HAS_MULTIPLE_VLAN
default MAX_VLANS_PER_PORT
config DISABLE_OPTIMIZATION
bool "Disable -O2, to ease running a debugger"
config OPTIMIZATION
int
default 0 if DISABLE_OPTIMIZATION
default 2
Makefile
View file @
873d6133
...
...
@@ -47,7 +47,8 @@ all: $(TARGET).o
# CFLAGS to use. Both this Makefile (later) and app-makefile may grow CFLAGS
CFLAGS
=
$(USER_CFLAGS)
CFLAGS
+=
-Wall
-Wstrict-prototypes
-Wmissing-prototypes
CFLAGS
+=
-O2
-ggdb
-Iinclude
-fno-common
CFLAGS
+=
-O
$(CONFIG_OPTIMIZATION)
CFLAGS
+=
-ggdb
-Iinclude
-fno-common
CFLAGS
+=
-DPPSI_VERSION
=
\"
$(VERSION)
\"
# to avoid ifdef as much as possible, I use the kernel trick for OBJ variables
...
...
configs/unix_debug_defconfig
0 → 100644
View file @
873d6133
#
# Automatically generated make config: don't edit
#
CONFIG_ARCH_UNIX=y
# CONFIG_ARCH_BARE_I386 is not set
# CONFIG_ARCH_BARE_X86_64 is not set
# CONFIG_ARCH_WRPC is not set
# CONFIG_ARCH_WRS is not set
# CONFIG_ARCH_SIMULATOR is not set
CONFIG_ARCH="unix"
#
# PTP Protocol Options
#
CONFIG_E2E=y
# CONFIG_P2P is not set
CONFIG_EXT_NONE=y
CONFIG_EXTENSION=""
CONFIG_CROSS_COMPILE=""
CONFIG_ARCH_CFLAGS=""
CONFIG_ARCH_LDFLAGS=""
CONFIG_HAS_VLAN=y
CONFIG_HAS_MULTIPLE_VLAN=y
CONFIG_VLAN=y
CONFIG_MAX_VLANS_PER_PORT=32
CONFIG_VLAN_ARRAY_SIZE=32
CONFIG_DISABLE_OPTIMIZATION=y
CONFIG_OPTIMIZATION=0
include/ppsi/ieee1588_types.h
View file @
873d6133
...
...
@@ -101,10 +101,10 @@ typedef struct PortAdress { /* page 13 (33) */
Octet
*
adressField
;
}
PortAdress
;
typedef
struct
ClockQuality
{
/* page 14 (34) */
UInteger8
clockClass
;
Enumeration8
clockAccuracy
;
UInteger16
offsetScaledLogVariance
;
typedef
struct
ClockQuality
{
/* page 14 (34)
-- int because of lib/config.c
*/
int
clockClass
;
int
clockAccuracy
;
int
offsetScaledLogVariance
;
}
ClockQuality
;
struct
TLV
{
/* page 14 (34) -- never used */
...
...
include/ppsi/pp-instance.h
View file @
873d6133
...
...
@@ -24,10 +24,10 @@ struct pp_runtime_opts {
Integer16
ap
,
ai
;
Integer16
s
;
Integer8
announce_intvl
;
Integer8
sync_intvl
;
UInteger8
prio1
;
UInteger8
prio2
;
UInteger8
domain_number
;
int
sync_intvl
;
int
prio1
;
int
prio2
;
int
domain_number
;
void
*
arch_opts
;
};
...
...
@@ -114,7 +114,7 @@ enum { /* The two sockets. They are called "net path" for historical reasons */
struct
pp_instance_cfg
{
char
port_name
[
16
];
char
iface_name
[
16
];
int
ext
;
/* 0: none, 1: whiterabbit */
/* FIXME extension enumeration */
int
ext
;
/* 0: none, 1: whiterabbit */
};
/*
...
...
@@ -126,8 +126,8 @@ struct pp_instance {
void
*
arch_data
;
/* if arch needs it */
void
*
ext_data
;
/* if protocol ext needs it */
unsigned
long
d_flags
;
/* diagnostics, ppi-specific flags */
unsigned
char
flags
,
/* protocol flags (see below) */
role
,
/* same as in config file */
unsigned
char
flags
;
/* protocol flags (see below) */
int
role
,
/* same as in config file */
proto
;
/* same as in config file */
/* Pointer to global instance owning this pp_instance*/
...
...
@@ -170,8 +170,6 @@ struct pp_instance {
unsigned
long
timeouts
[
__PP_TO_ARRAY_SIZE
];
UInteger16
recv_sync_sequence_id
;
Integer8
log_min_delay_req_interval
;
UInteger16
sent_seq
[
__PP_NR_MESSAGES_TYPES
];
/* last sent this type */
MsgHeader
received_ptp_header
;
...
...
proto-standard/msg.c
View file @
873d6133
...
...
@@ -9,7 +9,7 @@
#include <ppsi/ppsi.h>
#include "common-fun.h"
/* Unpack header from in buffer to
msg_tm
p_header field */
/* Unpack header from in buffer to
receieved_pt
p_header field */
int
msg_unpack_header
(
struct
pp_instance
*
ppi
,
void
*
buf
,
int
plen
)
{
MsgHeader
*
hdr
=
&
ppi
->
received_ptp_header
;
...
...
@@ -159,7 +159,7 @@ static int msg_pack_announce(struct pp_instance *ppi)
return
PP_ANNOUNCE_LENGTH
;
}
/* Unpack Announce message from in buffer of ppi to
msgtmp. Announc
e */
/* Unpack Announce message from in buffer of ppi to
internal structur
e */
void
msg_unpack_announce
(
void
*
buf
,
MsgAnnounce
*
ann
)
{
ann
->
originTimestamp
.
secondsField
.
msb
=
...
...
@@ -251,7 +251,7 @@ void msg_pack_pdelay_resp_follow_up(struct pp_instance *ppi,
*
(
UInteger16
*
)
(
buf
+
52
)
=
htons
(
hdr
->
sourcePortIdentity
.
portNumber
);
}
/* Unpack FollowUp message from in buffer of ppi to
msgtmp.follow
*/
/* Unpack FollowUp message from in buffer of ppi to
internal structure
*/
void
msg_unpack_follow_up
(
void
*
buf
,
MsgFollowUp
*
flwup
)
{
flwup
->
preciseOriginTimestamp
.
secondsField
.
msb
=
...
...
@@ -262,7 +262,7 @@ void msg_unpack_follow_up(void *buf, MsgFollowUp *flwup)
htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
}
/* Unpack PDelay
Resp FollowUp message from in buffer of ppi to msgtmp.follow
*/
/* Unpack PDelay
RespFollowUp message from in buffer of ppi to internal struct
*/
void
msg_unpack_pdelay_resp_follow_up
(
void
*
buf
,
MsgPDelayRespFollowUp
*
pdelay_resp_flwup
)
{
...
...
@@ -413,7 +413,7 @@ static void msg_pack_delay_resp(struct pp_instance *ppi,
htons
(
hdr
->
sourcePortIdentity
.
portNumber
);
}
/* Unpack delayReq message from in buffer of ppi to
msgtmp.req
*/
/* Unpack delayReq message from in buffer of ppi to
internal structure
*/
void
msg_unpack_delay_req
(
void
*
buf
,
MsgDelayReq
*
delay_req
)
{
delay_req
->
originTimestamp
.
secondsField
.
msb
=
...
...
@@ -424,7 +424,7 @@ void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req)
htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
}
/* Unpack PDelayReq message from in buffer of ppi to
msgtmp.req
*/
/* Unpack PDelayReq message from in buffer of ppi to
internal structure
*/
void
msg_unpack_pdelay_req
(
void
*
buf
,
MsgPDelayReq
*
pdelay_req
)
{
pdelay_req
->
originTimestamp
.
secondsField
.
msb
=
...
...
@@ -435,7 +435,7 @@ void msg_unpack_pdelay_req(void *buf, MsgPDelayReq * pdelay_req)
htonl
(
*
(
UInteger32
*
)
(
buf
+
40
));
}
/* Unpack delayResp message from IN buffer of ppi to
msgtmp.presp
*/
/* Unpack delayResp message from IN buffer of ppi to
internal structure
*/
void
msg_unpack_delay_resp
(
void
*
buf
,
MsgDelayResp
*
resp
)
{
resp
->
receiveTimestamp
.
secondsField
.
msb
=
...
...
@@ -450,7 +450,7 @@ void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp)
htons
(
*
(
UInteger16
*
)
(
buf
+
52
));
}
/* Unpack PDelayResp message from IN buffer of ppi to
msgtmp.presp
*/
/* Unpack PDelayResp message from IN buffer of ppi to
internal structure
*/
void
msg_unpack_pdelay_resp
(
void
*
buf
,
MsgPDelayResp
*
presp
)
{
presp
->
requestReceiptTimestamp
.
secondsField
.
msb
=
...
...
proto-standard/state-slave.c
View file @
873d6133
...
...
@@ -81,9 +81,9 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if
(
e
)
goto
out
;
ppi
->
log_min_delay_req_i
nterval
=
DSPOR
(
ppi
)
->
logMinDelayReqI
nterval
=
hdr
->
logMessageInterval
;
pp_timeout_init
(
ppi
);
/* new value for logMin */
}
else
{
pp_diag
(
ppi
,
frames
,
2
,
"pp_slave : "
"Delay Resp doesn't match Delay Req
\n
"
);
...
...
timeout.c
View file @
873d6133
...
...
@@ -6,23 +6,29 @@
*/
#include <ppsi/ppsi.h>
enum
rand_type
{
RAND_NONE
,
/* Not randomized */
RAND_70_130
,
/* Should be 70% to 130% of 1 << value */
RAND_0_200
,
/* Should be 0% to 200% of 1 << value */
};
struct
timeout_config
{
char
*
name
;
int
is
rand
;
int
which_
rand
;
int
value
;
};
/* most timeouts have a static configuration. Save it here */
static
struct
timeout_config
to_configs
[
__PP_TO_ARRAY_SIZE
]
=
{
[
PP_TO_REQUEST
]
=
{
"REQUEST"
,
1
,},
[
PP_TO_SYNC_SEND
]
=
{
"SYNC_SEND"
,
1
,},
[
PP_TO_ANN_RECEIPT
]
=
{
"ANN_RECEIPT"
,
0
,},
[
PP_TO_ANN_SEND
]
=
{
"ANN_SEND"
,
1
,},
[
PP_TO_FAULTY
]
=
{
"FAULTY"
,
0
,
4000
},
[
PP_TO_REQUEST
]
=
{
"REQUEST"
,
RAND_0_200
,},
[
PP_TO_SYNC_SEND
]
=
{
"SYNC_SEND"
,
RAND_70_130
,},
[
PP_TO_ANN_RECEIPT
]
=
{
"ANN_RECEIPT"
,
RAND_NONE
,},
[
PP_TO_ANN_SEND
]
=
{
"ANN_SEND"
,
RAND_70_130
,},
[
PP_TO_FAULTY
]
=
{
"FAULTY"
,
RAND_NONE
,
4000
},
/* extension timeouts are explicitly set to a value */
};
/* Init fills the timeout values
; they are not changed after program startup
*/
/* Init fills the timeout values */
void
pp_timeout_init
(
struct
pp_instance
*
ppi
)
{
struct
DSPort
*
port
=
ppi
->
portDS
;
...
...
@@ -36,24 +42,13 @@ void pp_timeout_init(struct pp_instance *ppi)
to_configs
[
PP_TO_ANN_SEND
].
value
=
port
->
logAnnounceInterval
;
}
static
void
pp_timeout_log
(
struct
pp_instance
*
ppi
,
int
index
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired: %s
\n
"
,
to_configs
[
index
].
name
);
}
void
__pp_timeout_set
(
struct
pp_instance
*
ppi
,
int
index
,
int
millisec
)
{
ppi
->
timeouts
[
index
]
=
ppi
->
t_ops
->
calc_timeout
(
ppi
,
millisec
);
pp_diag
(
ppi
,
time
,
3
,
"new timeout for %s: %i
\n
"
,
to_configs
[
index
].
name
,
millisec
);
}
/*
* Randomize a timeout. We are required to fit between 70% and 130%
* of the value for 90% of the time, at least. But making it "almost
* exact" is bad in a big network. So randomize between 80% and 120%:
* constant part is 80% and variable is 40%.
*/
void
pp_timeout_set
(
struct
pp_instance
*
ppi
,
int
index
)
{
...
...
@@ -62,11 +57,6 @@ void pp_timeout_set(struct pp_instance *ppi, int index)
int
millisec
;
int
logval
=
to_configs
[
index
].
value
;
if
(
!
to_configs
[
index
].
isrand
){
__pp_timeout_set
(
ppi
,
index
,
logval
);
/* not a logval */
return
;
}
if
(
!
seed
)
{
uint32_t
*
p
;
/* use the least 32 bits of the mac address as seed */
...
...
@@ -84,9 +74,28 @@ void pp_timeout_set(struct pp_instance *ppi, int index)
rval
<<=
10
;
rval
^=
(
unsigned
int
)
(
seed
/
65536
)
%
1024
;
millisec
=
(
1
<<
logval
)
*
400
;
/* This is 40% of the nominal value */
millisec
=
(
millisec
*
2
)
+
rval
%
millisec
;
/*
* logval is signed. Let's imagine it's no less than -4.
* Here below, 0 gets to 16 * 25 = 400ms, 40% of the nominal value
*/
millisec
=
(
1
<<
(
logval
+
4
))
*
25
;
switch
(
to_configs
[
index
].
which_rand
)
{
case
RAND_70_130
:
/*
* We are required to fit between 70% and 130%
* of the value for 90% of the time, at least.
* So randomize between 80% and 120%: constant
* part is 80% and variable is 40%.
*/
millisec
=
(
millisec
*
2
)
+
rval
%
millisec
;
break
;
case
RAND_0_200
:
millisec
=
rval
%
(
millisec
*
5
);
break
;
case
RAND_NONE
:
millisec
=
logval
;
/* not a log, just a constant */
}
__pp_timeout_set
(
ppi
,
index
,
millisec
);
}
...
...
@@ -109,7 +118,8 @@ int pp_timeout(struct pp_instance *ppi, int index)
ppi
->
timeouts
[
index
]);
if
(
ret
)
pp_timeout_log
(
ppi
,
index
);
pp_diag
(
ppi
,
time
,
1
,
"timeout expired: %s
\n
"
,
to_configs
[
index
].
name
);
return
ret
;
}
...
...
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