Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
PPSi
Commits
de2bb43c
Commit
de2bb43c
authored
Mar 05, 2021
by
Adam Wujek
Browse files
Options
Browse Files
Download
Plain Diff
Changes to reduce the code size of WRPC
Signed-off-by:
Adam Wujek
<
adam.wujek@creotech.pl
>
parents
3d815ee0
ef5f92f0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
322 additions
and
210 deletions
+322
-210
Kconfig
Kconfig
+64
-6
Makefile
Makefile
+4
-0
faults.c
arch-wrpc/faults.c
+3
-3
wrc_ptp_ppsi.c
arch-wrpc/wrc_ptp_ppsi.c
+3
-18
wrpc-calibration.c
arch-wrpc/wrpc-calibration.c
+3
-17
wrpc.h
arch-wrpc/wrpc.h
+14
-3
util.c
arch-wrs/util.c
+24
-0
wrpc_defconfig
configs/wrpc_defconfig
+4
-3
lib.h
include/ppsi/lib.h
+3
-0
ppsi.h
include/ppsi/ppsi.h
+14
-3
time-arith.c
lib/time-arith.c
+38
-28
hooks.c
proto-ext-whiterabbit/hooks.c
+1
-1
state-wr-calibrated.c
proto-ext-whiterabbit/state-wr-calibrated.c
+2
-2
state-wr-calibration.c
proto-ext-whiterabbit/state-wr-calibration.c
+2
-2
state-wr-locked.c
proto-ext-whiterabbit/state-wr-locked.c
+2
-2
state-wr-m-lock.c
proto-ext-whiterabbit/state-wr-m-lock.c
+2
-2
state-wr-present.c
proto-ext-whiterabbit/state-wr-present.c
+2
-2
state-wr-resp-calib-req.c
proto-ext-whiterabbit/state-wr-resp-calib-req.c
+2
-2
state-wr-s-lock.c
proto-ext-whiterabbit/state-wr-s-lock.c
+1
-1
wr-msg.c
proto-ext-whiterabbit/wr-msg.c
+12
-8
bmc.c
proto-standard/bmc.c
+72
-92
bmc_clock_quality.c
proto-standard/bmc_clock_quality.c
+8
-0
fsm-lib.c
proto-standard/fsm-lib.c
+2
-1
open-close.c
proto-standard/open-close.c
+2
-2
servo.c
proto-standard/servo.c
+2
-2
state-listening.c
proto-standard/state-listening.c
+1
-1
state-master.c
proto-standard/state-master.c
+1
-1
state-passive.c
proto-standard/state-passive.c
+1
-1
state-slave.c
proto-standard/state-slave.c
+3
-3
dump-funcs.c
tools/dump-funcs.c
+6
-4
dump-main.c
tools/dump-main.c
+24
-0
No files found.
Kconfig
View file @
de2bb43c
...
...
@@ -327,8 +327,42 @@ config CODEOPT_SINGLE_INSTANCE_PER_PORT
depends on CODEOPT_ENABLED && SINGLE_INSTANCE_PER_PORT
default n
help
Only one foreign master per port instance.
Only one instance per port.
config CODEOPT_WRPC_SIZE
boolean "Size optimizations specific for WRPC"
depends on CODEOPT_ENABLED && ARCH_WRPC
default y
help
Use optimizations specific to WRPC to reduce the footprint.
config CODEOPT_EXT_PORT_CONF_FORCE_DISABLED
boolean "Remove external port configuration"
depends on CODEOPT_ENABLED
default y if ARCH_WRPC
default n
help
externalPortConfiguration set to false to reduce the footprint.
Saves ~1500B on WRPC
config CODEOPT_SO_FORCE_DISABLED
boolean "Force disabled slaveOnly"
depends on CODEOPT_ENABLED
default y if ARCH_WRPC
default n
help
Force slaveOnly to false to reduce the footprint.
Saves ~650B.
config CODEOPT_MO_FORCE_DISABLED
boolean "Force disabled masterOnly"
depends on CODEOPT_ENABLED
default y if ARCH_WRPC
default n
help
Force masterOnly to false to reduce the footprint.
Saves ~100B.
choice
prompt "Exclusive options"
...
...
@@ -340,13 +374,13 @@ choice
config CODEOPT_EPC_ENABLED
boolean "Force externalPortConfiguration.enable to true"
depends on CODEOPT_ENABLED
depends on CODEOPT_ENABLED
&& !CODEOPT_EXT_PORT_CONF_FORCE_DISABLED
help
externalPortConfiguration.enable is set to true and cannot be changed
config CODEOPT_SO_ENABLED
boolean "Force slaveOnly mode to true"
depends on CODEOPT_ENABLED && SINGLE_PORT
depends on CODEOPT_ENABLED && SINGLE_PORT
&& !CODEOPT_SO_FORCE_DISABLED
help
slaveOnly is set to true and cannot be changed.
It implies that the number of port instances must be set to 1.
...
...
@@ -384,9 +418,9 @@ endchoice
config OPTIMIZATION
string
default "-Os" if OPTIMIZATION_SIZE_SPEED && ARCH_WRPC
default "-Os
-ggdb
" if OPTIMIZATION_SIZE_SPEED && ARCH_WRPC
default "-Os -ggdb" if OPTIMIZATION_SIZE_SPEED
default "-O2" if OPTIMIZATION_SPEED && ARCH_WRPC
default "-O2
-ggdb
" if OPTIMIZATION_SPEED && ARCH_WRPC
default "-O2 -ggdb" if OPTIMIZATION_SPEED
default "-Og -ggdb" if OPTIMIZATION_DEBUGGING
default "-ggdb" if OPTIMIZATION_NONE_DEBUGGING
...
...
@@ -432,6 +466,30 @@ config HAS_CODEOPT_SINGLE_INSTANCE_PER_PORT
default 1 if CODEOPT_SINGLE_INSTANCE_PER_PORT
default 0
config HAS_CODEOPT_CODEOPT_WRPC_SIZE
int
range 0 1
default 1 if CODEOPT_WRPC_SIZE
default 0
config HAS_CODEOPT_EXT_PORT_CONF_FORCE_DISABLED
int
range 0 1
default 1 if CODEOPT_EXT_PORT_CONF_FORCE_DISABLED
default 0
config HAS_CODEOPT_SO_FORCE_DISABLED
int
range 0 1
default 1 if CODEOPT_SO_FORCE_DISABLED
default 0
config HAS_CODEOPT_MO_FORCE_DISABLED
int
range 0 1
default 1 if CODEOPT_MO_FORCE_DISABLED
default 0
config HAS_CODEOPT_EPC_ENABLED
int
range 0 1
...
...
Makefile
View file @
de2bb43c
...
...
@@ -109,6 +109,10 @@ $(TARGET).o: $(OBJ-y)
$(LD)
--gc-sections
-Map
$(TARGET)
.map1
-r
-o
$@
$(PPSI_O_LDFLAGS)
\
--start-group
$
(
OBJ-y
)
--end-group
$(TARGET).a
:
$(OBJ-y)
$(AR)
rc
$@
$
(
OBJ-y
)
$(OBJ-y)
:
.config $(wildcard include/ppsi/*.h)
# Finally, "make clean" is expected to work
...
...
arch-wrpc/faults.c
View file @
de2bb43c
...
...
@@ -20,9 +20,9 @@ static int cmd_fault(const char *args[])
if
(
args
[
0
]
&&
!
strcmp
(
args
[
0
],
"drop"
))
{
if
(
args
[
1
])
fromdec
(
args
[
1
],
&
ppg
->
rxdrop
);
ppg
->
rxdrop
=
atoi
(
args
[
1
]
);
if
(
args
[
2
])
fromdec
(
args
[
2
],
&
ppg
->
txdrop
);
ppg
->
txdrop
=
atoi
(
args
[
2
]
);
ppsi_drop_init
(
ppg
,
timer_get_tics
());
pp_printf
(
"dropping %i/1000 rx, %i/1000 tx
\n
"
,
ppg
->
rxdrop
,
ppg
->
txdrop
);
...
...
@@ -30,7 +30,7 @@ static int cmd_fault(const char *args[])
}
if
(
args
[
0
]
&&
!
strcmp
(
args
[
0
],
"delay"
))
{
if
(
args
[
1
])
fr
omdec
(
args
[
1
],
&
frame_rx_delay_us
);
fr
ame_rx_delay_us
=
atoi
(
args
[
1
]
);
pp_printf
(
"delaying %i us on rx frame
\n
"
,
frame_rx_delay_us
);
return
0
;
}
...
...
arch-wrpc/wrc_ptp_ppsi.c
View file @
de2bb43c
...
...
@@ -135,7 +135,6 @@ int wrc_ptp_init(void)
/* egressLatency and ingressLatency are overwritten on ptp_start */
ppi
->
timestampCorrectionPortDS
.
messageTimestampPointLatency
=
0
;
ppi
->
portDS
->
masterOnly
=
ppi
->
cfg
.
masterOnly
;
/* can be overridden in pp_init_globals() */
pp_init_globals
(
&
ppg_static
,
&
__pp_default_rt_opts
);
...
...
@@ -250,13 +249,12 @@ int wrc_ptp_start(void)
/* sfp match was done before so read calibration data */
if
(
wrpc_read_calibration_data
(
ppi
,
NULL
,
wrpc_read_calibration_data
(
ppi
,
NULL
,
&
scaledBitSlide
,
&
scaledDelayCoefficient
,
&
scaledSfpDeltaTx
,
&
scaledSfpDeltaRx
)
!=
WRH_HW_CALIB_OK
)
{
pp_diag
(
ppi
,
fsm
,
1
,
"Cannot get calibration values (bitslide, alpha, TX/Rx delays
\n
"
);
}
&
scaledSfpDeltaRx
);
ppi
->
timestampCorrectionPortDS
.
semistaticLatency
=
scaledBitSlide
;
if
(
scaledDelayCoefficient
>=
PP_MIN_DELAY_COEFFICIENT_AS_RELDIFF
&&
scaledDelayCoefficient
<=
PP_MAX_DELAY_COEFFICIENT_AS_RELDIFF
)
{
...
...
@@ -407,19 +405,6 @@ int wrc_pps_force(wrpc_pps_force_t action)
return
action
&
1
;
}
void
wrc_ptp_set_leapsec
(
int
leapsec
)
{
TOPS
(
INST
(
ppg
,
0
))
->
set_utc_offset
(
NULL
,
leapsec
,
0
,
0
);
}
void
wrc_ptp_get_leapsec
(
int
*
ptp
,
int
*
system
)
{
int
tmp
;
*
ptp
=
ppg
->
timePropertiesDS
->
currentUtcOffset
;
TOPS
(
INST
(
ppg
,
0
))
->
get_utc_offset
(
NULL
,
system
,
&
tmp
,
&
tmp
);
return
;
}
int
wrc_ptp_is_abscal
(
void
)
{
return
ptp_mode
==
WRC_MODE_ABSCAL
;
...
...
arch-wrpc/wrpc-calibration.c
View file @
de2bb43c
...
...
@@ -23,7 +23,7 @@ int wrpc_read_calibration_data(
TimeInterval
*
scaledSfpDeltaTx
,
TimeInterval
*
scaledSfpDeltaRx
)
{
struct
hal
_port_state
state
;
struct
wrc
_port_state
state
;
if
(
wrpc_get_port_state
(
&
state
,
ppi
->
iface_name
))
return
WRH_HW_CALIB_NOT_FOUND
;
...
...
@@ -40,27 +40,13 @@ int wrpc_read_calibration_data(
/* check if tx is calibrated,
* if so read data */
if
(
scaledSfpDeltaTx
)
{
if
(
state
.
calib
.
tx_calibrated
)
{
*
scaledSfpDeltaTx
=
picos_to_interval
(
state
.
calib
.
delta_tx_phy
+
state
.
calib
.
sfp
.
delta_tx_ps
+
state
.
calib
.
delta_tx_board
);
}
else
return
WRH_HW_CALIB_NOT_FOUND
;
*
scaledSfpDeltaTx
=
picos_to_interval
(
state
.
calib
.
delta_tx_ps
);
}
/* check if rx is calibrated,
* if so read data */
if
(
scaledSfpDeltaRx
)
{
if
(
state
.
calib
.
rx_calibrated
)
{
*
scaledSfpDeltaRx
=
picos_to_interval
(
state
.
calib
.
delta_rx_phy
+
state
.
calib
.
sfp
.
delta_rx_ps
+
state
.
calib
.
delta_rx_board
);
}
else
return
WRH_HW_CALIB_NOT_FOUND
;
*
scaledSfpDeltaRx
=
picos_to_interval
(
state
.
calib
.
delta_rx_ps
);
}
return
WRH_HW_CALIB_OK
;
...
...
arch-wrpc/wrpc.h
View file @
de2bb43c
...
...
@@ -57,6 +57,7 @@ typedef enum {
pps_force_check
}
wrpc_pps_force_t
;
extern
struct
pp_globals
*
ppg
;
/* wrpc-spll.c (some should move to time-wrpc/) */
int
wrpc_spll_locking_enable
(
struct
pp_instance
*
ppi
);
int
wrpc_spll_locking_poll
(
struct
pp_instance
*
ppi
);
...
...
@@ -72,8 +73,6 @@ int wrc_ptp_bmc_update(void);
int
wrc_ptp_link_down
(
void
);
int
wrc_pps_force
(
wrpc_pps_force_t
action
);
int
wrpc_get_GM_lock_state
(
struct
pp_globals
*
ppg
,
pp_timing_mode_state_t
*
state
);
void
wrc_ptp_set_leapsec
(
int
leapsec
);
void
wrc_ptp_get_leapsec
(
int
*
ptp
,
int
*
system
);
...
...
@@ -86,7 +85,7 @@ int wrpc_read_calibration_data(
RelativeDifference
*
scaledDelayCoefficient
,
TimeInterval
*
scaledSfpDeltaTx
,
TimeInterval
*
scaledSfpDeltaRx
);
int
wrpc_get_port_state
(
struct
hal
_port_state
*
port
,
const
char
*
port_name
);
int
wrpc_get_port_state
(
struct
wrc
_port_state
*
port
,
const
char
*
port_name
);
static
inline
wrpc_arch_data_t
*
WRPC_ARCH_I
(
struct
pp_instance
*
ppi
)
...
...
@@ -99,4 +98,16 @@ static inline wrpc_arch_data_t *WRPC_ARCH_G(struct pp_globals *ppg)
return
(
wrpc_arch_data_t
*
)
ppg
->
arch_data
;
}
static
inline
void
wrc_ptp_get_leapsec
(
int
*
ptp
,
int
*
system
)
{
int
tmp
;
*
ptp
=
ppg
->
timePropertiesDS
->
currentUtcOffset
;
TOPS
(
INST
(
ppg
,
0
))
->
get_utc_offset
(
NULL
,
system
,
&
tmp
,
&
tmp
);
return
;
}
static
inline
void
wrc_ptp_set_leapsec
(
int
leapsec
)
{
TOPS
(
INST
(
ppg
,
0
))
->
set_utc_offset
(
NULL
,
leapsec
,
0
,
0
);
}
#endif
/* __WRPC_H */
arch-wrs/util.c
View file @
de2bb43c
...
...
@@ -133,3 +133,27 @@ void *create_map(unsigned long address, unsigned long size)
return
NULL
;
return
mapaddr
+
fragment
;
}
char
*
format_hex
(
char
*
s
,
const
unsigned
char
*
mac
,
int
cnt
)
{
int
i
;
*
s
=
'\0'
;
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
pp_sprintf
(
s
,
"%s%02x:"
,
s
,
mac
[
i
]);
}
/* remove last colon */
s
[
cnt
*
3
-
1
]
=
'\0'
;
/* cnt * strlen("FF:") - 1 */
return
s
;
}
char
*
format_hex8
(
char
*
s
,
const
unsigned
char
*
mac
)
{
return
format_hex
(
s
,
mac
,
8
);
}
char
*
format_mac
(
char
*
s
,
const
unsigned
char
*
mac
)
{
format_hex
(
s
,
mac
,
6
);
return
s
;
}
configs/wrpc_defconfig
View file @
de2bb43c
...
...
@@ -64,14 +64,15 @@ CONFIG_SINGLE_PORT=y
# CONFIG_CODEOPT_SINGLE_PORT is not set
# CONFIG_CODEOPT_SINGLE_FMASTER is not set
# CONFIG_CODEOPT_SINGLE_INSTANCE_PER_PORT is not set
CONFIG_CODEOPT_WRPC_SIZE=y
CONFIG_CODEOPT_EPC_SO_DISABLED=y
# CONFIG_CODEOPT_EPC_ENABLED is not set
# CONFIG_CODEOPT_SO_ENABLED is not set
CONFIG_OPTIMIZATION_SPEED=y
# CONFIG_OPTIMIZATION_SIZE_SPEED is not set
# CONFIG_OPTIMIZATION_SPEED is not set
CONFIG_OPTIMIZATION_SIZE_SPEED=y
# CONFIG_OPTIMIZATION_DEBUGGING is not set
# CONFIG_OPTIMIZATION_NONE_DEBUGGING is not set
CONFIG_OPTIMIZATION="-O
2
"
CONFIG_OPTIMIZATION="-O
s -ggdb
"
# CONFIG_FAULT_INJECTION_MECHANISM is not set
CONFIG_HAS_FAULT_INJECTION_MECHANISM=0
CONFIG_HAS_WRPC_FAULTS=0
...
...
include/ppsi/lib.h
View file @
de2bb43c
...
...
@@ -15,4 +15,7 @@ extern int atoi(const char *s);
extern
uint32_t
__div64_32
(
uint64_t
*
n
,
uint32_t
base
);
extern
char
*
format_hex8
(
char
*
s
,
const
unsigned
char
*
mac
);
extern
char
*
format_mac
(
char
*
s
,
const
unsigned
char
*
mac
);
#endif
/* __PPSI_LIB_H__ */
include/ppsi/ppsi.h
View file @
de2bb43c
...
...
@@ -174,7 +174,9 @@ static inline struct pp_servo *SRV(struct pp_instance *ppi)
}
static
inline
int
is_externalPortConfigurationEnabled
(
defaultDS_t
*
def
)
{
return
CONFIG_HAS_CODEOPT_EPC_ENABLED
||
def
->
externalPortConfigurationEnabled
;
return
CONFIG_HAS_CODEOPT_EXT_PORT_CONF_FORCE_DISABLED
==
0
&&
(
CONFIG_HAS_CODEOPT_EPC_ENABLED
||
def
->
externalPortConfigurationEnabled
);
}
static
inline
int
is_delayMechanismP2P
(
struct
pp_instance
*
ppi
)
{
...
...
@@ -186,9 +188,18 @@ static inline int is_delayMechanismE2E(struct pp_instance *ppi) {
}
static
inline
int
is_slaveOnly
(
defaultDS_t
*
def
)
{
return
CONFIG_HAS_CODEOPT_EPC_ENABLED
==
0
&&
def
->
slaveOnly
;
return
CONFIG_HAS_CODEOPT_
SO_FORCE_DISABLED
==
0
&&
CONFIG_HAS_CODEOPT_
EPC_ENABLED
==
0
&&
def
->
slaveOnly
;
}
static
inline
int
is_masterOnly
(
portDS_t
*
portDS
)
{
#if CONFIG_HAS_CODEOPT_MO_FORCE_DISABLED
return
0
;
#else
return
portDS
->
masterOnly
;
#endif
}
static
inline
int
get_numberPorts
(
defaultDS_t
*
def
)
{
return
CONFIG_HAS_CODEOPT_SINGLE_PORT
?
1
:
def
->
numberPorts
;
}
...
...
@@ -411,7 +422,7 @@ extern int64_t interval_to_picos(TimeInterval interval);
extern
int
is_timestamps_incorrect
(
struct
pp_instance
*
ppsi
,
int
*
err_count
,
int
ts_mask
);
extern
char
*
time_to_string
(
struct
pp_time
*
t
);
extern
char
*
interval_to_string
(
TimeInterval
time
);
extern
char
*
relative_interval_to_string
(
TimeInterval
time
);
extern
char
*
relative_interval_to_string
(
RelativeDifference
time
);
/*
* The state machine itself is an array of these structures.
...
...
lib/time-arith.c
View file @
de2bb43c
...
...
@@ -124,16 +124,17 @@ void fixedDelta_to_pp_time(struct FixedDelta fd, struct pp_time *t) {
void
picos_to_pp_time
(
int64_t
picos
,
struct
pp_time
*
ts
)
{
uint64_t
sec
,
nsec
;
uint64_t
picos_u
;
int
sign
=
(
picos
<
0
?
-
1
:
1
);
picos
*=
sign
;
sec
=
picos
/
PP_PSEC_PER_SEC
;
picos
-=
sec
*
PP_PSEC_PER_SEC
;
nsec
=
picos
/
1000
;
picos
%=
1000
;
picos
_u
=
picos
*
sign
;
sec
=
picos_u
/
PP_PSEC_PER_SEC
;
picos
_u
-=
sec
*
PP_PSEC_PER_SEC
;
nsec
=
picos
_u
/
1000
;
picos
_u
%=
1000
;
ts
->
scaled_nsecs
=
nsec
<<
TIME_FRACBITS
;
ts
->
scaled_nsecs
+=
((
picos
<<
TIME_FRACBITS
)
+
TIME_ROUNDING_VALUE
)
/
1000
;
ts
->
scaled_nsecs
+=
((
picos
_u
<<
TIME_FRACBITS
)
+
TIME_ROUNDING_VALUE
)
/
1000
;
ts
->
scaled_nsecs
*=
sign
;
ts
->
secs
=
sec
*
sign
;
}
...
...
@@ -143,9 +144,9 @@ void picos_to_pp_time(int64_t picos, struct pp_time *ts)
void
pp_time_hardwarize
(
struct
pp_time
*
time
,
int
clock_period_ps
,
int32_t
*
ticks
,
int32_t
*
picos
)
{
int64_t
ps
,
adj_ps
;
u
int64_t
ps
,
adj_ps
;
int32_t
sign
=
(
time
->
scaled_nsecs
<
0
)
?
-
1
:
1
;
int64_t
scaled_nsecs
=
time
->
scaled_nsecs
*
sign
;
uint64_t
scaled_nsecs
=
time
->
scaled_nsecs
*
sign
;
if
(
clock_period_ps
<=
0
)
{
pp_error
(
"%s : Invalid clock period %d
\n
"
,
__func__
,
clock_period_ps
);
...
...
@@ -178,11 +179,12 @@ TimeInterval picos_to_interval(int64_t picos)
}
else
{
int64_t
scaled_ns
;
uint64_t
picos_u
;
int
sign
=
(
picos
<
0
?
-
1
:
1
);
picos
*=
sign
;
scaled_ns
=
(
picos
/
1000
)
<<
TIME_INTERVAL_FRACBITS
;
/* Calculate nanos */
scaled_ns
+=
((
picos
%
1000
)
<<
TIME_INTERVAL_FRACBITS
)
/
1000
;
/* Add picos */
picos
_u
=
picos
*
sign
;
scaled_ns
=
(
picos_u
/
1000
)
<<
TIME_INTERVAL_FRACBITS
;
/* Calculate nanos */
scaled_ns
+=
((
picos_u
%
1000
)
<<
TIME_INTERVAL_FRACBITS
)
/
1000
;
/* Add picos */
return
scaled_ns
*
sign
;
}
...
...
@@ -271,35 +273,43 @@ char *time_to_string(struct pp_time *t)
/* Convert TimeInterval to string */
char
*
interval_to_string
(
TimeInterval
time
)
{
int64_t
sign
,
nanos
,
picos
;
int64_t
nanos
;
uint32_t
picos
;
char
sign
=
' '
;
if
(
time
<
0
&&
time
!=
INT64_MIN
)
{
sign
=
-
1
;
sign
=
'-'
;
time
=-
time
;
}
else
{
sign
=
1
;
}
nanos
=
time
>>
TIME_INTERVAL_FRACBITS
;
picos
=
(((
time
&
TIME_INTERVAL_FRACMASK
)
*
1000
)
+
TIME_INTERVAL_ROUNDING_VALUE
)
>>
TIME_INTERVAL_FRACBITS
;
pp_sprintf
(
time_as_string
,
"%
"
PRId64
".%03"
PRId64
,
sign
*
nanos
,
picos
);
pp_sprintf
(
time_as_string
,
"%
c%"
PRId64
".%03d"
,
sign
,
nanos
,
picos
);
return
time_as_string
;
}
/* Convert RelativeInterval to string */
char
*
relative_interval_to_string
(
TimeInterval
time
)
{
int32_t
nsecs
=
time
>>
REL_DIFF_FRACBITS
;
uint64_t
sub_yocto
=
0
;
int64_t
fraction
;
uint64_t
bitWeight
=
500000000000000000
;
char
*
relative_interval_to_string
(
RelativeDifference
time
)
{
char
sign
;
int32_t
nsecs
;
uint64_t
sub_yocto
=
0
;
int64_t
fraction
;
uint64_t
bitWeight
=
500000000000000000
;
uint64_t
mask
;
if
(
time
<
0
)
{
time
=-
time
;
sign
=
'-'
;
}
else
{
sign
=
'+'
;
}
fraction
=
time
&
REL_DIFF_FRACMASK
;
for
(
mask
=
(
uint64_t
)
1
<<
(
REL_DIFF_FRACBITS
-
1
);
mask
!=
0
;
mask
>>=
1
)
{
if
(
mask
&
fraction
)
sub_yocto
+=
bitWeight
;
bitWeight
/=
2
;
nsecs
=
time
>>
REL_DIFF_FRACBITS
;
fraction
=
time
&
REL_DIFF_FRACMASK
;
for
(
mask
=
(
uint64_t
)
1
<<
(
REL_DIFF_FRACBITS
-
1
);
mask
!=
0
;
mask
>>=
1
)
{
if
(
mask
&
fraction
)
sub_yocto
+=
bitWeight
;
bitWeight
/=
2
;
}
pp_sprintf
(
time_as_string
,
"%
"
PRId32
".%018"
PRIu64
,
nsecs
,
sub_yocto
);
pp_sprintf
(
time_as_string
,
"%
c%"
PRId32
".%018Ld"
,
sign
,
nsecs
,
sub_yocto
);
return
time_as_string
;
}
proto-ext-whiterabbit/hooks.c
View file @
de2bb43c
...
...
@@ -57,7 +57,7 @@ static int wr_open(struct pp_instance *ppi, struct pp_runtime_opts *rt_opts)
){
WR_DSPOR
(
ppi
)
->
wrConfig
=
WR_S_ONLY
;
}
else
{
WR_DSPOR
(
ppi
)
->
wrConfig
=
(
ppi
->
portDS
->
masterOnly
||
WR_DSPOR
(
ppi
)
->
wrConfig
=
(
is_masterOnly
(
ppi
->
portDS
)
||
(
is_externalPortConfigurationEnabled
(
DSDEF
(
ppi
))
&&
ppi
->
externalPortConfigurationPortDS
.
desiredState
==
PPS_MASTER
))
?
WR_M_ONLY
:
...
...
proto-ext-whiterabbit/state-wr-calibrated.c
View file @
de2bb43c
...
...
@@ -40,7 +40,7 @@ int wr_calibrated(struct pp_instance *ppi, void *buf, int len, int new_state)
(
wrp
->
wrMode
==
WR_SLAVE
))
{
wrp
->
next_state
=
WRS_WR_LINK_ON
;
}
else
{
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
CALIBRATE/WR_MODE_ON was expected
\n
"
,
wrMsgId
);
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
%s was expected
\n
"
,
wrMsgId
,
"CALIBRATE/WR_MODE_ON"
);
wr_handshake_fail
(
ppi
);
}
return
0
;
...
...
@@ -52,7 +52,7 @@ int wr_calibrated(struct pp_instance *ppi, void *buf, int len, int new_state)
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
"
WR_TMO_NAME
"
\n
"
);
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
%s
\n
"
,
WR_TMO_NAME
);
wr_handshake_fail
(
ppi
);
return
0
;
/* non-wr already */
}
...
...
proto-ext-whiterabbit/state-wr-calibration.c
View file @
de2bb43c
...
...
@@ -27,7 +27,7 @@ int wr_calibration(struct pp_instance *ppi, void *buf, int len, int new_state)
ti
=
ppi
->
timestampCorrectionPortDS
.
egressLatency
*
1000
;
delta
->
scaledPicoseconds
.
msb
=
ti
>>
32
;
delta
->
scaledPicoseconds
.
lsb
=
ti
&
0xFFFFFFFF
;
pp_diag
(
ppi
,
ext
,
1
,
"
deltaTx: msb=0x%x lsb=0x%x
\n
"
,
pp_diag
(
ppi
,
ext
,
1
,
"
%s: msb=0x%x lsb=0x%x
\n
"
,
"deltaTx
"
,
wrp
->
deltaTx
.
scaledPicoseconds
.
msb
,
wrp
->
deltaTx
.
scaledPicoseconds
.
lsb
);
fixedDelta_to_pp_time
(
*
delta
,
&
se
->
delta_txs
);
/* Update servo specific data */
...
...
@@ -38,7 +38,7 @@ int wr_calibration(struct pp_instance *ppi, void *buf, int len, int new_state)
ppi
->
timestampCorrectionPortDS
.
semistaticLatency
)
*
1000
);
delta
->
scaledPicoseconds
.
msb
=
ti
>>
32
;
delta
->
scaledPicoseconds
.
lsb
=
ti
&
0xFFFFFFFF
;
pp_diag
(
ppi
,
ext
,
1
,
"
deltaRx: msb=0x%x lsb=0x%x
\n
"
,
pp_diag
(
ppi
,
ext
,
1
,
"
%s: msb=0x%x lsb=0x%x
\n
"
,
"deltaRx
"
,
wrp
->
deltaRx
.
scaledPicoseconds
.
msb
,
wrp
->
deltaRx
.
scaledPicoseconds
.
lsb
);
fixedDelta_to_pp_time
(
*
delta
,
&
se
->
delta_rxs
);
/* Update servo specific data */
...
...
proto-ext-whiterabbit/state-wr-locked.c
View file @
de2bb43c
...
...
@@ -34,7 +34,7 @@ int wr_locked(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
wrMsgId
==
CALIBRATE
)
{
wrp
->
next_state
=
WRS_RESP_CALIB_REQ
;
}
else
{
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
CALIBRATE was expected
\n
"
,
wrMsgId
);
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
%s was expected
\n
"
,
wrMsgId
,
"CALIBRATE"
);
wr_handshake_fail
(
ppi
);
}
return
0
;
...
...
@@ -45,7 +45,7 @@ int wr_locked(struct pp_instance *ppi, void *buf, int len, int new_state)
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
"
WR_TMO_NAME
"
\n
"
);
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
%s
\n
"
,
WR_TMO_NAME
);
wr_handshake_fail
(
ppi
);
return
0
;
/* non-wr already */
}
...
...
proto-ext-whiterabbit/state-wr-m-lock.c
View file @
de2bb43c
...
...
@@ -34,7 +34,7 @@ int wr_m_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
wrMsgId
==
LOCKED
)
{
wrp
->
next_state
=
WRS_CALIBRATION
;
}
else
{
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
LOCKED was expected
\n
"
,
wrMsgId
);
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
%s was expected
\n
"
,
wrMsgId
,
"LOCKED"
);
wr_handshake_fail
(
ppi
);
}
return
0
;
...
...
@@ -45,7 +45,7 @@ int wr_m_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
"
WR_TMO_NAME
"
\n
"
);
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
%s
\n
"
,
WR_TMO_NAME
);
wr_handshake_fail
(
ppi
);
return
0
;
/* non-wr already */
}
...
...
proto-ext-whiterabbit/state-wr-present.c
View file @
de2bb43c
...
...
@@ -36,7 +36,7 @@ int wr_present(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
wrMsgId
==
LOCK
)
{
wrp
->
next_state
=
WRS_S_LOCK
;
}
else
{
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
LOCK was expected
\n
"
,
wrMsgId
);
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
%s was expected
\n
"
,
wrMsgId
,
"LOCK"
);
wr_handshake_fail
(
ppi
);
}
return
0
;
...
...
@@ -47,7 +47,7 @@ int wr_present(struct pp_instance *ppi, void *buf, int len, int new_state)
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
"
WR_TMO_NAME
"
\n
"
);
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
%s
\n
"
,
WR_TMO_NAME
);
wr_handshake_fail
(
ppi
);
return
0
;
/* non-wr already */
}
...
...
proto-ext-whiterabbit/state-wr-resp-calib-req.c
View file @
de2bb43c
...
...
@@ -36,7 +36,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len, int new_state
WRS_WR_LINK_ON
:
WRS_CALIBRATION
;
}
else
{
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
CALIBRATED was expected
\n
"
,
wrMsgId
);
pp_diag
(
ppi
,
ext
,
1
,
"WR: Invalid msgId(x%04x) received.
%s was expected
\n
"
,
wrMsgId
,
"CALIBRATED"
);
wr_handshake_fail
(
ppi
);
}
return
0
;
...
...
@@ -47,7 +47,7 @@ int wr_resp_calib_req(struct pp_instance *ppi, void *buf, int len, int new_state
int
rms
=
pp_next_delay_1
(
ppi
,
wrTmoIdx
);
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
if
(
!
rms
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
"
WR_TMO_NAME
"
\n
"
);
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
%s
\n
"
,
WR_TMO_NAME
);
wr_handshake_fail
(
ppi
);
return
0
;
/* non-wr already */
}
...
...
proto-ext-whiterabbit/state-wr-s-lock.c
View file @
de2bb43c
...
...
@@ -33,7 +33,7 @@ int wr_s_lock(struct pp_instance *ppi, void *buf, int len, int new_state)
if
(
rms
<=
(
wrp
->
wrStateRetry
*
WR_TMO_MS
))
{
WRH_OPER
()
->
locking_disable
(
ppi
);
if
(
rms
==
0
)
{
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
"
WR_TMO_NAME
"
\n
"
);
pp_diag
(
ppi
,
time
,
1
,
"timeout expired:
%s
\n
"
,
WR_TMO_NAME
);
wr_handshake_fail
(
ppi
);
return
0
;
/* non-wr already */
}
...
...
proto-ext-whiterabbit/wr-msg.c
View file @
de2bb43c
...
...
@@ -208,26 +208,30 @@ int msg_unpack_wrsig(struct pp_instance *ppi, void *buf,
tlv_versionNumber
=
0xFF
&
ntohs
(
*
(
UInteger16
*
)(
buf
+
52
));
if
(
tlv_type
!=
TLV_TYPE_ORG_EXTENSION
)
{
pp_diag
(
ppi
,
frames
,
1
,
"handle Signaling msg, failed, This is not "
"organization extension TLV = 0x%x
\n
"
,
tlv_type
);
/* "handle Signaling msg, failed, not organization extension TLV = 0x%x\n" */
pp_diag
(
ppi
,
frames
,
1
,
"%sorganization extension TLV = 0x%x
\n
"
,
"handle Signaling msg, failed, not "
,
tlv_type
);
return
0
;
}
if
(
tlv_organizationID
!=
WR_TLV_ORGANIZATION_ID
)
{
pp_diag
(
ppi
,
frames
,
1
,
"handle Signaling msg, failed, not CERN's "
"OUI = 0x%x
\n
"
,
tlv_organizationID
);
/* "handle Signaling msg, failed, not CERN's OUI = 0x%x\n" */
pp_diag
(
ppi
,
frames
,
1
,
"%sCERN's OUI = 0x%x
\n
"
,
"handle Signaling msg, failed, not "
,
tlv_organizationID
);
return
0
;
}
if
(
tlv_magicNumber
!=
WR_TLV_MAGIC_NUMBER
)
{
pp_diag
(
ppi
,
frames
,
1
,
"handle Signaling msg, failed, "
"not White Rabbit magic number = 0x%x
\n
"
,
tlv_magicNumber
);
/* "handle Signaling msg, failed, not White Rabbit magic number = 0x%x\n" */
pp_diag
(
ppi
,
frames
,
1
,
"%sWhite Rabbit magic number = 0x%x
\n
"
,
"handle Signaling msg, failed, not "
,
tlv_magicNumber
);
return
0
;
}
if
(
tlv_versionNumber
!=
WR_TLV_WR_VERSION_NUMBER
)
{
pp_diag
(
ppi
,
frames
,
1
,
"handle Signaling msg, failed, not supported "
"version number = 0x%x
\n
"
,
tlv_versionNumber
);
/* "handle Signaling msg, failed, not supported version number = 0x%x\n" */
pp_diag
(
ppi
,
frames
,
1
,
"%ssupported version number = 0x%x
\n
"
,
"handle Signaling msg, failed, not "
,
tlv_versionNumber
);
return
0
;
}
...
...
proto-standard/bmc.c
View file @
de2bb43c
This diff is collapsed.
Click to expand it.
proto-standard/bmc_clock_quality.c
View file @
de2bb43c
...
...
@@ -60,6 +60,7 @@ clockDegradation_t clockDegradation[]= {
.
msg
=
"unlocked"
,
},
},
#ifndef CONFIG_CODEOPT_WRPC_SIZE
// PP_ARB_CLASS_GM_LOCKED
{
.
clockClass
=
PP_ARB_CLASS_GM_LOCKED
,
...
...
@@ -122,6 +123,7 @@ clockDegradation_t clockDegradation[]= {
.
msg
=
"unlocked"
,
}
},
#endif
// PP_ARB_CLASS_GM_UNLOCKED_B
{
.
clockClass
=
PP_ARB_CLASS_GM_UNLOCKED_B
,
...
...
@@ -190,6 +192,7 @@ defaultDeviceAttributes_t defaultDeviceAttributes[] = {
.
frequencyTraceable
=
TRUE
,
.
timeTraceable
=
TRUE
,
},
#ifndef CONFIG_CODEOPT_WRPC_SIZE
{
.
clockClass
=
PP_PTP_CLASS_GM_UNLOCKED_A
,
.
clock_quality_clockAccuracy
=
PP_PTP_ACCURACY_GM_UNLOCKED_A
,
.
clock_quality_offsetScaledLogVariance
=
PP_PTP_VARIANCE_GM_UNLOCKED_A
,
...
...
@@ -198,6 +201,7 @@ defaultDeviceAttributes_t defaultDeviceAttributes[] = {
.
frequencyTraceable
=
FALSE
,
.
timeTraceable
=
FALSE
,
},
#endif
{
.
clockClass
=
PP_PTP_CLASS_GM_UNLOCKED_B
,
.
clock_quality_clockAccuracy
=
PP_PTP_ACCURACY_GM_UNLOCKED_B
,
.
clock_quality_offsetScaledLogVariance
=
PP_PTP_VARIANCE_GM_UNLOCKED_B
,
...
...
@@ -206,6 +210,7 @@ defaultDeviceAttributes_t defaultDeviceAttributes[] = {
.
frequencyTraceable
=
FALSE
,
.
timeTraceable
=
FALSE
,
},
#ifndef CONFIG_CODEOPT_WRPC_SIZE
{
.
clockClass
=
PP_ARB_CLASS_GM_LOCKED
,
.
clock_quality_clockAccuracy
=
PP_ARB_ACCURACY_GM_LOCKED
,
.
clock_quality_offsetScaledLogVariance
=
PP_ARB_VARIANCE_GM_LOCKED
,
...
...
@@ -230,6 +235,7 @@ defaultDeviceAttributes_t defaultDeviceAttributes[] = {
.
frequencyTraceable
=
FALSE
,
.
timeTraceable
=
FALSE
,
},
#endif
{
.
clockClass
=
PP_ARB_CLASS_GM_UNLOCKED_B
,
.
clock_quality_clockAccuracy
=
PP_ARB_ACCURACY_GM_UNLOCKED_B
,
.
clock_quality_offsetScaledLogVariance
=
PP_ARB_VARIANCE_GM_UNLOCKED_B
,
...
...
@@ -342,6 +348,8 @@ void bmc_set_default_device_attributes (struct pp_globals *ppg) {
while
(
pDef
->
clockClass
!=
clockClass
&&
pDef
->
clockClass
!=-
1
)
pDef
++
;
/* if (pDef->clockClass == -1)
pp_printf("%s clockClass %d not found\n", __func__, pDef->clockClass);*/
if
(
rt_opts
->
clock_quality_clockAccuracy
==-
1
)
rt_opts
->
clock_quality_clockAccuracy
=
(
unsigned
)
pDef
->
clock_quality_clockAccuracy
;
if
(
rt_opts
->
clock_quality_offsetScaledLogVariance
==-
1
)
...
...
proto-standard/fsm-lib.c
View file @
de2bb43c
...
...
@@ -96,8 +96,9 @@ int pp_lib_may_issue_announce(struct pp_instance *ppi)
if
(
prop
->
ptpTimescale
)
{
ret
=
TOPS
(
ppi
)
->
get_utc_time
(
ppi
,
&
hours
,
&
minutes
,
&
seconds
);
if
(
ret
)
{
/* "Could not get UTC time from system, taking received flags\n" */
pp_diag
(
ppi
,
frames
,
1
,
"Could not get UTC
time from system, taking received flags
\n
"
);
"Could not get UTC
%s from system, taking received flags
\n
"
,
"time
"
);
}
else
{
/* for 2 announce intervals after midnight, get the offset from the system */
if
((
hours
==
00
)
&&
(
minutes
==
00
)
&&
...
...
proto-standard/open-close.c
View file @
de2bb43c
...
...
@@ -103,7 +103,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts)
def
->
externalPortConfigurationEnabled
=
pp_rt_opts
->
externalPortConfigurationEnabled
;
def
->
slaveOnly
=
rt_opts
->
slaveOnly
;
if
(
is_externalPortConfigurationEnabled
(
def
)
)
{
if
(
def
->
slaveOnly
)
{
if
(
is_slaveOnly
(
def
)
)
{
pp_printf
(
"ppsi: Incompatible configuration: SlaveOnly and externalPortConfigurationEnabled
\n
"
);
def
->
slaveOnly
=
FALSE
;
}
...
...
@@ -162,7 +162,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts)
Enumeration8
desiradedState
=
ppi
->
cfg
.
desiredState
;
/* Clause 17.6.5.3 : - Clause 9.2.2 shall not be in effect */
if
(
ppi
->
portDS
->
masterOnly
)
{
if
(
is_masterOnly
(
ppi
->
portDS
)
)
{
/* priority given to externalPortConfigurationEnabled */
ppi
->
portDS
->
masterOnly
=
FALSE
;
pp_printf
(
"ppsi: Wrong configuration: externalPortConfigurationEnabled=materOnly=TRUE. materOnly set to FALSE
\n
"
);
...
...
proto-standard/servo.c
View file @
de2bb43c
...
...
@@ -288,8 +288,8 @@ int pp_servo_calculate_delays(struct pp_instance *ppi) {
if
(
__PP_DIAG_ALLOW
(
ppi
,
pp_dt_servo
,
2
))
{
pp_diag
(
ppi
,
servo
,
2
,
"delayMM : %s s
\n
"
,
time_to_string
(
&
servo
->
delayMM
));
pp_diag
(
ppi
,
servo
,
2
,
"delayMS : %s s
\n
"
,
time_to_string
(
&
servo
->
delayMS
));
pp_diag
(
ppi
,
servo
,
2
,
"delayAsym : %s ns
\n
"
,
relative_interval_to_string
(
ppi
->
portDS
->
delayAsymCoeff
));
pp_diag
(
ppi
,
servo
,
2
,
"delayAsymCoeff : %s ns
\n
"
,
interval_to_string
(
ppi
->
portDS
->
delayAsymmetry
));
pp_diag
(
ppi
,
servo
,
2
,
"delayAsym : %s ns
\n
"
,
interval_to_string
(
ppi
->
portDS
->
delayAsymmetry
));
pp_diag
(
ppi
,
servo
,
2
,
"delayAsymCoeff : %s ns
\n
"
,
relative_interval_to_string
(
ppi
->
portDS
->
delayAsymCoeff
));
pp_diag
(
ppi
,
servo
,
2
,
"meanDelay : %s s
\n
"
,
time_to_string
(
&
servo
->
meanDelay
));
pp_diag
(
ppi
,
servo
,
2
,
"offsetFromMaster: %s s
\n
"
,
time_to_string
(
&
servo
->
offsetFromMaster
));
}
...
...
proto-standard/state-listening.c
View file @
de2bb43c
...
...
@@ -37,7 +37,7 @@ static int listening_handle_announce(struct pp_instance *ppi, void *buf, int len
* Announce messages received on a masterOnly PTP Port shall not be considered
* in the operation of the best master clock algorithm or in the update of data sets.
*/
if
(
!
DSPOR
(
ppi
)
->
masterOnly
)
{
if
(
!
is_masterOnly
(
DSPOR
(
ppi
))
)
{
struct
pp_frgn_master
frgn_master
;
bmc_store_frgn_master
(
ppi
,
&
frgn_master
,
buf
,
len
);
...
...
proto-standard/state-master.c
View file @
de2bb43c
...
...
@@ -40,7 +40,7 @@ static int master_handle_announce(struct pp_instance *ppi, void *buf, int len)
* Announce messages received on a masterOnly PTP Port shall not be considered
* in the operation of the best master clock algorithm or in the update of data sets.
*/
if
(
!
DSPOR
(
ppi
)
->
masterOnly
)
{
if
(
!
is_masterOnly
(
DSPOR
(
ppi
))
)
{
struct
pp_frgn_master
frgn_master
;
bmc_store_frgn_master
(
ppi
,
&
frgn_master
,
buf
,
len
);
...
...
proto-standard/state-passive.c
View file @
de2bb43c
...
...
@@ -39,7 +39,7 @@ static int passive_handle_announce(struct pp_instance *ppi, void *buf, int len)
* Announce messages received on a masterOnly PTP Port shall not be considered
* in the operation of the best master clock algorithm or in the update of data sets.
*/
if
(
!
DSPOR
(
ppi
)
->
masterOnly
)
{
if
(
!
is_masterOnly
(
DSPOR
(
ppi
))
)
{
struct
pp_frgn_master
frgn_master
;
bmc_store_frgn_master
(
ppi
,
&
frgn_master
,
buf
,
len
);
...
...
proto-standard/state-slave.c
View file @
de2bb43c
...
...
@@ -215,7 +215,7 @@ static int slave_handle_announce(struct pp_instance *ppi, void *buf, int len)
* Announce messages received on a masterOnly PTP Port shall not be considered
* in the operation of the best master clock algorithm or in the update of data sets.
*/
if
(
!
DSPOR
(
ppi
)
->
masterOnly
)
{
if
(
!
is_masterOnly
(
DSPOR
(
ppi
))
)
{
bmc_add_frgn_master
(
ppi
,
&
frgn_master
);
}
...
...
@@ -260,6 +260,7 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
/* Check if the foreign master has changed */
if
(
DSPAR
(
ppi
)
->
newGrandmaster
)
{
char
gm_str
[
26
];
// New grandmaster detected
DSPAR
(
ppi
)
->
newGrandmaster
=
FALSE
;
// Clear it
...
...
@@ -268,8 +269,7 @@ int pp_slave(struct pp_instance *ppi, void *buf, int len)
ppi
->
next_state
=
PPS_UNCALIBRATED
;
Octet
*
id
=
DSPAR
(
ppi
)
->
parentPortIdentity
.
clockIdentity
.
id
;
pp_info
(
"New grandmaster detected: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x
\n
"
,
id
[
0
],
id
[
1
],
id
[
2
],
id
[
3
],
id
[
4
],
id
[
5
],
id
[
6
],
id
[
7
]);
pp_info
(
"New grandmaster detected: %s
\n
"
,
format_hex8
(
gm_str
,
id
));
}
}
...
...
tools/dump-funcs.c
View file @
de2bb43c
...
...
@@ -9,6 +9,7 @@
#include <ppsi/ieee1588_types.h>
/* from ../include */
#include "decent_types.h"
#include "ptpdump.h"
#include <ppsi/lib.h>
#define WR_MODE_ON_MASK 0x8
#define CALIBRATED_MASK 0x4
...
...
@@ -65,6 +66,8 @@ static int dump_eth(char *prefix, struct ethhdr *eth)
unsigned
char
*
s
=
eth
->
h_source
;
int
proto
=
ntohs
(
eth
->
h_proto
);
int
ret
;
char
mac_s
[
20
];
char
mac_d
[
20
];
/* Between eth header and payload may be a VLAN tag;
* NOTE: We cannot distinguish between both cases looking at
...
...
@@ -77,10 +80,9 @@ static int dump_eth(char *prefix, struct ethhdr *eth)
}
else
ret
=
sizeof
(
struct
ethhdr
);
printf
(
"%sETH: %04x (%02x:%02x:%02x:%02x:%02x:%02x -> "
"%02x:%02x:%02x:%02x:%02x:%02x)
\n
"
,
prefix
,
proto
,
s
[
0
],
s
[
1
],
s
[
2
],
s
[
3
],
s
[
4
],
s
[
5
],
d
[
0
],
d
[
1
],
d
[
2
],
d
[
3
],
d
[
4
],
d
[
5
]);
printf
(
"%sETH: %04x (%s -> %s)
\n
"
,
prefix
,
proto
,
format_mac
(
mac_s
,
s
),
format_mac
(
mac_d
,
d
));
return
ret
;
}
...
...
tools/dump-main.c
View file @
de2bb43c
...
...
@@ -222,3 +222,27 @@ int main(int argc, char **argv)
return
0
;
}
char
*
format_hex
(
char
*
s
,
const
unsigned
char
*
mac
,
int
cnt
)
{
int
i
;
*
s
=
'\0'
;
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
sprintf
(
s
,
"%s%02x:"
,
s
,
mac
[
i
]);
}
/* remove last colon */
s
[
cnt
*
3
-
1
]
=
'\0'
;
/* cnt * strlen("FF:") - 1 */
return
s
;
}
char
*
format_hex8
(
char
*
s
,
const
unsigned
char
*
mac
)
{
return
format_hex
(
s
,
mac
,
8
);
}
char
*
format_mac
(
char
*
s
,
const
unsigned
char
*
mac
)
{
format_hex
(
s
,
mac
,
6
);
return
s
;
}
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