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
92ecd033
Commit
92ecd033
authored
May 26, 2023
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify fsm-table
parent
b12dd381
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
43 deletions
+33
-43
fsm.c
fsm.c
+19
-25
ieee1588_types.h
include/ppsi/ieee1588_types.h
+1
-3
ppsi.h
include/ppsi/ppsi.h
+1
-2
fsm-table.c
proto-standard/fsm-table.c
+10
-11
dump_mem_ppsi_wrpc.c
tools/dump_mem_ppsi_wrpc.c
+1
-1
wrs_dump_shmem_ppsi.c
tools/wrs_dump_shmem_ppsi.c
+1
-1
No files found.
fsm.c
View file @
92ecd033
...
...
@@ -68,32 +68,25 @@ static void pp_diag_fsm(struct pp_instance *ppi, const char *name, int sequence,
static
const
struct
pp_state_table_item
*
get_current_state_table_item
(
struct
pp_instance
*
ppi
)
{
const
struct
pp_state_table_item
*
ip
=
ppi
->
current_state_item
;
/* Avoid searching if we already know where we are */
ppi
->
is_new_state
=
0
;
if
(
ip
&&
ip
->
state
==
ppi
->
state
)
return
ip
;
ppi
->
is_new_state
=
1
;
/* a linear search is affordable up to a few dozen items */
for
(
ip
=
pp_state_table
;
ip
->
state
!=
PPS_END_OF_TABLE
;
ip
++
)
if
(
ip
->
state
==
ppi
->
state
)
{
ppi
->
current_state_item
=
ip
;
return
ip
;
}
return
NULL
;
}
const
struct
pp_state_table_item
*
cur_ip
=
ppi
->
current_state_item
;
const
struct
pp_state_table_item
*
nxt_ip
=
&
pp_state_table
[
ppi
->
state
];
const
char
*
get_state_as_string
(
struct
pp_instance
*
ppi
,
int
state
)
{
static
char
*
def
=
"INVALID"
;
const
struct
pp_state_table_item
*
ip
=
ppi
->
current_state_item
;
if
(
cur_ip
==
nxt_ip
)
{
ppi
->
is_new_state
=
0
;
}
else
{
ppi
->
is_new_state
=
1
;
ppi
->
current_state_item
=
nxt_ip
;
}
for
(
ip
=
pp_state_table
;
ip
->
state
!=
PPS_END_OF_TABLE
;
ip
++
)
if
(
ip
->
state
==
state
)
{
return
ip
->
name
;
}
return
def
;
return
nxt_ip
;
}
const
char
*
get_state_as_string
(
struct
pp_instance
*
ppi
,
int
state
)
{
if
(
state
>=
0
&&
state
<
PPS_LAST_STATE
)
return
pp_state_table
[
state
].
name
;
return
"INVALID"
;
}
/*
...
...
@@ -111,7 +104,8 @@ int pp_leave_current_state(struct pp_instance *ppi)
}
/* if the next or old state is non standard PTP reset all timeouts */
if
((
ppi
->
state
>
PPS_LAST_STATE
)
||
(
ppi
->
next_state
>
PPS_LAST_STATE
))
if
((
ppi
->
state
>=
PPS_LAST_STATE
)
||
(
ppi
->
next_state
>=
PPS_LAST_STATE
))
pp_timeout_setall
(
ppi
);
ppi
->
state
=
ppi
->
next_state
;
...
...
include/ppsi/ieee1588_types.h
View file @
92ecd033
...
...
@@ -372,10 +372,8 @@ typedef enum {
PPS_SLAVE
,
#ifdef CONFIG_ABSCAL
PPS_ABSCAL
,
/* not standard */
PPS_LAST_STATE
=
PPS_ABSCAL
#else
PPS_LAST_STATE
=
PPS_SLAVE
#endif
PPS_LAST_STATE
/* unused */
}
pp_std_states
;
typedef
enum
{
...
...
include/ppsi/ppsi.h
View file @
92ecd033
...
...
@@ -425,12 +425,11 @@ int is_timestamp_incorrect_thres(struct pp_instance *ppsi, int *err_count, int t
typedef
int
pp_action
(
struct
pp_instance
*
ppi
,
void
*
buf
,
int
len
);
struct
pp_state_table_item
{
int
state
;
const
char
*
name
;
pp_action
*
f1
;
};
extern
const
struct
pp_state_table_item
pp_state_table
[];
/* 0-terminated */
extern
const
struct
pp_state_table_item
pp_state_table
[];
/* Convert current state as a string value */
const
char
*
get_state_as_string
(
struct
pp_instance
*
ppi
,
int
state
);
...
...
proto-standard/fsm-table.c
View file @
92ecd033
...
...
@@ -11,17 +11,16 @@
* This is the state machine table. */
const
struct
pp_state_table_item
pp_state_table
[]
=
{
{
PPS_INITIALIZING
,
"initializing"
,
pp_initializing
},
{
PPS_FAULTY
,
"faulty"
,
pp_faulty
},
{
PPS_DISABLED
,
"disabled"
,
pp_disabled
},
{
PPS_LISTENING
,
"listening"
,
pp_listening
},
{
PPS_PRE_MASTER
,
"pre-master"
,
pp_master
},
{
PPS_MASTER
,
"master"
,
pp_master
},
{
PPS_PASSIVE
,
"passive"
,
pp_passive
},
{
PPS_UNCALIBRATED
,
"uncalibrated"
,
pp_slave
},
{
PPS_SLAVE
,
"slave"
,
pp_slave
},
[
PPS_INITIALIZING
]
=
{
"initializing"
,
pp_initializing
},
[
PPS_FAULTY
]
=
{
"faulty"
,
pp_faulty
},
[
PPS_DISABLED
]
=
{
"disabled"
,
pp_disabled
},
[
PPS_LISTENING
]
=
{
"listening"
,
pp_listening
},
[
PPS_PRE_MASTER
]
=
{
"pre-master"
,
pp_master
},
[
PPS_MASTER
]
=
{
"master"
,
pp_master
},
[
PPS_PASSIVE
]
=
{
"passive"
,
pp_passive
},
[
PPS_UNCALIBRATED
]
=
{
"uncalibrated"
,
pp_slave
},
[
PPS_SLAVE
]
=
{
"slave"
,
pp_slave
},
#ifdef CONFIG_ABSCAL
{
PPS_ABSCAL
,
"abscal"
,
pp_abscal
},
[
PPS_ABSCAL
]
=
{
"abscal"
,
pp_abscal
},
#endif
{
PPS_END_OF_TABLE
,}
};
tools/dump_mem_ppsi_wrpc.c
View file @
92ecd033
...
...
@@ -751,7 +751,6 @@ void dump_one_field_ppsi_wrpc(int type, int size, void *p, int i)
case
dump_type_ppi_state
:
case
dump_type_ppi_state_Enumeration8
:
switch
(
i
)
{
ENUM_TO_P_IN_CASE
(
PPS_END_OF_TABLE
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_INITIALIZING
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_FAULTY
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_DISABLED
,
char_p
);
...
...
@@ -761,6 +760,7 @@ void dump_one_field_ppsi_wrpc(int type, int size, void *p, int i)
ENUM_TO_P_IN_CASE
(
PPS_PASSIVE
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_UNCALIBRATED
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_SLAVE
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_LAST_STATE
,
char_p
);
default:
char_p
=
"Unknown"
;
}
...
...
tools/wrs_dump_shmem_ppsi.c
View file @
92ecd033
...
...
@@ -571,7 +571,6 @@ void dump_one_field_ppsi_wrs(int type, int size, void *p, int i)
case
dump_type_ppi_state
:
case
dump_type_ppi_state_Enumeration8
:
switch
(
i
)
{
ENUM_TO_P_IN_CASE
(
PPS_END_OF_TABLE
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_INITIALIZING
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_FAULTY
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_DISABLED
,
char_p
);
...
...
@@ -581,6 +580,7 @@ void dump_one_field_ppsi_wrs(int type, int size, void *p, int i)
ENUM_TO_P_IN_CASE
(
PPS_PASSIVE
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_UNCALIBRATED
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_SLAVE
,
char_p
);
ENUM_TO_P_IN_CASE
(
PPS_LAST_STATE
,
char_p
);
default:
char_p
=
"Unknown"
;
}
...
...
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