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
d6f76abe
Commit
d6f76abe
authored
Apr 20, 2018
by
Jean-Claude BAU
Committed by
Adam Wujek
Nov 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bmc_update_clock_quality(): Diag msgs and code optimization
parent
62d64511
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
69 deletions
+64
-69
diag-macros.h
include/ppsi/diag-macros.h
+20
-0
bmc.c
proto-standard/bmc.c
+44
-69
No files found.
include/ppsi/diag-macros.h
View file @
d6f76abe
...
...
@@ -80,6 +80,26 @@ extern void __pp_diag(struct pp_instance *ppi, enum pp_diag_things th,
#define pp_diag_allow(ppi_, th_, level_) \
(PP_HAS_DIAG && __PP_DIAG_ALLOW(ppi_, pp_dt_ ## th_, level_))
/*
* Set of useful macros to store temporary diag messages
* 'buff' parameter can be a global or local char pointer.
* Local variables use less code to access them (measure done with lm32 compiler)
*/
#define pp_diag_set_msg(buff,msg) \
({ \
if (PP_HAS_DIAG) \
buff=msg; \
PP_HAS_DIAG;
/* return 1 if done, 0 if not done */
\
})
#define pp_diag_clear_msg(buff) pp_diag_set_msg(buff,0)
#define pp_diag_get_msg(buff) buff
#define pp_diag_is_msg_set(buff) \
(PP_HAS_DIAG && (buff!=0))
/*
* And this is the parser of the string. Internally it obeys VERB_LOG_MESGS
* to set the value to 0xfffffff0 to be compatible with previous usage.
...
...
proto-standard/bmc.c
View file @
d6f76abe
...
...
@@ -8,8 +8,6 @@
#include <ppsi/ppsi.h>
#ifndef CONFIG_ARCH_WRPC
/* Flag Field bits symbolic names (table 57, pag. 151) */
#define FFB_LI61 0x01
#define FFB_LI59 0x02
...
...
@@ -1246,125 +1244,91 @@ static void bmc_update_ebest(struct pp_globals *ppg)
static
void
bmc_update_clock_quality
(
struct
pp_instance
*
ppi
)
{
char
*
pp_diag_msg
;
struct
pp_globals
*
ppg
=
GLBS
(
ppi
);
struct
pp_runtime_opts
*
rt_opts
=
ppi
->
glbs
->
rt_opts
;
int
ret
=
0
;
int
rt_opts_clock_quality_clockClass
=
rt_opts
->
clock_quality
.
clockClass
;
int
defaultDS_clock_quality_clockClass
=
ppg
->
defaultDS
->
clockQuality
.
clockClass
;
int
state
;
if
(
rt_opts
->
clock_quality
.
clockClass
<
128
)
{
if
(
rt_opts
_clock_quality_
clockClass
<
128
)
{
if
((
rt_opts
->
clock_quality
.
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
||
(
rt_opts
->
clock_quality
.
clockClass
==
PP_ARB_CLASS_GM_LOCKED
))
{
if
((
rt_opts
_clock_quality_
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
||
(
rt_opts
_clock_quality_
clockClass
==
PP_ARB_CLASS_GM_LOCKED
))
{
pp_diag
(
ppi
,
bmc
,
2
,
"GM locked class configured, checking servo state
\n
"
);
}
else
if
((
rt_opts
->
clock_quality
.
clockClass
==
PP_PTP_CLASS_GM_UNLOCKED
)
||
(
rt_opts
->
clock_quality
.
clockClass
==
PP_ARB_CLASS_GM_UNLOCKED
))
{
}
else
if
((
rt_opts
_clock_quality_
clockClass
==
PP_PTP_CLASS_GM_UNLOCKED
)
||
(
rt_opts_clock_quality_
clockClass
==
PP_ARB_CLASS_GM_UNLOCKED
))
{
pp_diag
(
ppi
,
bmc
,
2
,
"GM unlocked class configured, skipping checking servo state
\n
"
);
return
;
}
else
{
pp_diag
(
ppi
,
bmc
,
2
,
"
GM unknown clock class configured, skipping checking servo state
\n
"
);
"GM unknown clock class configured, skipping checking servo state
\n
"
);
return
;
}
ret
=
ppi
->
t_ops
->
get_servo_state
(
ppi
,
&
state
);
if
(
ret
)
{
if
(
ppi
->
t_ops
->
get_servo_state
(
ppi
,
&
state
))
{
pp_diag
(
ppi
,
bmc
,
1
,
"Could not get servo state, taking old clock class: %i
\n
"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
);
return
;
}
pp_diag_clear_msg
(
pp_diag_msg
);
switch
(
state
)
{
case
PP_SERVO_LOCKED
:
if
(
rt_opts
->
clock_quality
.
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
{
if
(
ppg
->
defaultDS
->
clockQuality
.
clockClass
!=
PP_PTP_CLASS_GM_LOCKED
)
{
if
(
rt_opts
_clock_quality_
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
{
if
(
defaultDS_clock_quality_
clockClass
!=
PP_PTP_CLASS_GM_LOCKED
)
{
ppg
->
defaultDS
->
clockQuality
.
clockClass
=
PP_PTP_CLASS_GM_LOCKED
;
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
=
PP_PTP_ACCURACY_GM_LOCKED
;
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
=
PP_PTP_VARIANCE_GM_LOCKED
;
pp_diag
(
ppi
,
bmc
,
1
,
"Servo locked, new clock class: %i,"
"new clock accuracy: %i,"
"new clock variance: %04x,"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
,
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
,
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
);
pp_diag_set_msg
(
pp_diag_msg
,
"locked"
);
}
}
else
if
(
rt_opts
->
clock_quality
.
clockClass
==
PP_ARB_CLASS_GM_LOCKED
)
{
if
(
ppg
->
defaultDS
->
clockQuality
.
clockClass
!=
PP_ARB_CLASS_GM_LOCKED
)
{
}
else
if
(
rt_opts
_clock_quality_
clockClass
==
PP_ARB_CLASS_GM_LOCKED
)
{
if
(
defaultDS_clock_quality_
clockClass
!=
PP_ARB_CLASS_GM_LOCKED
)
{
ppg
->
defaultDS
->
clockQuality
.
clockClass
=
PP_ARB_CLASS_GM_LOCKED
;
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
=
PP_ARB_ACCURACY_GM_LOCKED
;
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
=
PP_ARB_VARIANCE_GM_LOCKED
;
pp_diag
(
ppi
,
bmc
,
1
,
"Servo locked, new clock class: %i,"
"new clock accuracy: %i,"
"new clock variance: %04x,"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
,
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
,
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
);
pp_diag_set_msg
(
pp_diag_msg
,
"locked"
);
}
}
break
;
case
PP_SERVO_HOLDOVER
:
if
(
rt_opts
->
clock_quality
.
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
{
if
(
ppg
->
defaultDS
->
clockQuality
.
clockClass
!=
PP_PTP_CLASS_GM_HOLDOVER
)
{
if
(
rt_opts
_clock_quality_
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
{
if
(
defaultDS_clock_quality_
clockClass
!=
PP_PTP_CLASS_GM_HOLDOVER
)
{
ppg
->
defaultDS
->
clockQuality
.
clockClass
=
PP_PTP_CLASS_GM_HOLDOVER
;
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
=
PP_PTP_ACCURACY_GM_HOLDOVER
;
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
=
PP_PTP_VARIANCE_GM_HOLDOVER
;
pp_diag
(
ppi
,
bmc
,
1
,
"Servo in holdover, new clock class: %i,"
"new clock accuracy: %i,"
"new clock variance: %04x,"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
,
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
,
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
);
pp_diag_set_msg
(
pp_diag_msg
,
"in holdover"
);
}
}
else
if
(
rt_opts
->
clock_quality
.
clockClass
==
PP_ARB_CLASS_GM_LOCKED
)
{
if
(
ppg
->
defaultDS
->
clockQuality
.
clockClass
!=
PP_ARB_CLASS_GM_HOLDOVER
)
{
}
else
if
(
rt_opts
_clock_quality_clockClass
==
PP_ARB_CLASS_GM_LOCKED
)
{
if
(
defaultDS_clock_quality_
clockClass
!=
PP_ARB_CLASS_GM_HOLDOVER
)
{
ppg
->
defaultDS
->
clockQuality
.
clockClass
=
PP_ARB_CLASS_GM_HOLDOVER
;
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
=
PP_ARB_ACCURACY_GM_HOLDOVER
;
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
=
PP_ARB_VARIANCE_GM_HOLDOVER
;
pp_diag
(
ppi
,
bmc
,
1
,
"Servo in holdover, new clock class: %i,"
"new clock accuracy: %i,"
"new clock variance: %04x,"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
,
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
,
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
);
pp_diag_set_msg
(
pp_diag_msg
,
"in holdover"
);
}
}
break
;
case
PP_SERVO_UNLOCKED
:
if
(
rt_opts
->
clock_quality
.
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
{
if
(
ppg
->
defaultDS
->
clockQuality
.
clockClass
!=
PP_PTP_CLASS_GM_UNLOCKED
)
{
if
(
rt_opts
_clock_quality_
clockClass
==
PP_PTP_CLASS_GM_LOCKED
)
{
if
(
defaultDS_clock_quality_
clockClass
!=
PP_PTP_CLASS_GM_UNLOCKED
)
{
ppg
->
defaultDS
->
clockQuality
.
clockClass
=
PP_PTP_CLASS_GM_UNLOCKED
;
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
=
PP_PTP_ACCURACY_GM_UNLOCKED
;
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
=
PP_PTP_VARIANCE_GM_UNLOCKED
;
pp_diag
(
ppi
,
bmc
,
1
,
"Servo unlocked, new clock class: %i,"
"new clock accuracy: %i,"
"new clock variance: %04x,"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
,
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
,
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
);
pp_diag_set_msg
(
pp_diag_msg
,
"unlocked"
);
}
}
else
if
(
rt_opts
->
clock_quality
.
clockClass
==
PP_ARB_CLASS_GM_LOCKED
)
{
if
(
ppg
->
defaultDS
->
clockQuality
.
clockClass
!=
PP_ARB_CLASS_GM_UNLOCKED
)
{
}
else
if
(
rt_opts
_clock_quality_
clockClass
==
PP_ARB_CLASS_GM_LOCKED
)
{
if
(
defaultDS_clock_quality_
clockClass
!=
PP_ARB_CLASS_GM_UNLOCKED
)
{
ppg
->
defaultDS
->
clockQuality
.
clockClass
=
PP_ARB_CLASS_GM_UNLOCKED
;
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
=
PP_ARB_ACCURACY_GM_UNLOCKED
;
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
=
PP_ARB_VARIANCE_GM_UNLOCKED
;
pp_diag
(
ppi
,
bmc
,
1
,
"Servo unlocked, new clock class: %i,"
"new clock accuracy: %i,"
"new clock variance: %04x,"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
,
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
,
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
);
pp_diag_set_msg
(
pp_diag_msg
,
"unlocked"
);
}
}
break
;
...
...
@@ -1373,11 +1337,23 @@ static void bmc_update_clock_quality(struct pp_instance *ppi)
default:
pp_diag
(
ppi
,
bmc
,
2
,
"Unknown servo state, taking old clock class: %i
\n
"
,
ppg
->
defaultDS
->
clockQuality
.
clockClass
);
defaultDS_clock_quality_clockClass
);
break
;
}
if
(
pp_diag_is_msg_set
(
pp_diag_msg
)
)
{
pp_diag
(
ppi
,
bmc
,
1
,
"Servo %s, "
"new clock class: %i,"
"new clock accuracy: %i,"
"new clock variance: %04x,"
,
pp_diag_get_msg
(
pp_diag_msg
),
ppg
->
defaultDS
->
clockQuality
.
clockClass
,
ppg
->
defaultDS
->
clockQuality
.
clockAccuracy
,
ppg
->
defaultDS
->
clockQuality
.
offsetScaledLogVariance
);
}
}
}
...
...
@@ -1435,4 +1411,3 @@ int bmc(struct pp_instance *ppi)
return
next_state
;
}
#endif
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