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
c66e9950
Commit
c66e9950
authored
Apr 08, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'davide-fixes'
parents
8cead1c6
49c599ea
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
175 additions
and
222 deletions
+175
-222
sim-conf.c
arch-sim/sim-conf.c
+29
-29
unix-conf.c
arch-unix/unix-conf.c
+2
-14
ppsi-manual.in
doc/ppsi-manual.in
+0
-6
ppsi.h
include/ppsi/ppsi.h
+49
-2
cmdline.c
lib/cmdline.c
+0
-125
conf.c
lib/conf.c
+91
-46
unix-socket.c
time-unix/unix-socket.c
+4
-0
No files found.
arch-sim/sim-conf.c
View file @
c66e9950
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include <ppsi/ppsi.h>
#include <ppsi/ppsi.h>
#include "ppsi-sim.h"
#include "ppsi-sim.h"
static
int
f_ppm_real
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_ppm_real
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
struct
pp_instance
*
ppi_slave
;
struct
pp_instance
*
ppi_slave
;
...
@@ -20,7 +20,7 @@ static int f_ppm_real(int lineno, struct pp_globals *ppg,
...
@@ -20,7 +20,7 @@ static int f_ppm_real(int lineno, struct pp_globals *ppg,
return
0
;
return
0
;
}
}
static
int
f_ppm_servo
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_ppm_servo
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
struct
pp_instance
*
ppi_slave
;
struct
pp_instance
*
ppi_slave
;
...
@@ -32,7 +32,7 @@ static int f_ppm_servo(int lineno, struct pp_globals *ppg,
...
@@ -32,7 +32,7 @@ static int f_ppm_servo(int lineno, struct pp_globals *ppg,
return
0
;
return
0
;
}
}
static
int
f_ofm
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_ofm
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
struct
pp_sim_time_instance
*
t_master
,
*
t_slave
;
struct
pp_sim_time_instance
*
t_master
,
*
t_slave
;
...
@@ -45,7 +45,7 @@ static int f_ofm(int lineno, struct pp_globals *ppg,
...
@@ -45,7 +45,7 @@ static int f_ofm(int lineno, struct pp_globals *ppg,
return
0
;
return
0
;
}
}
static
int
f_init_time
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_init_time
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
struct
pp_sim_time_instance
*
t_inst
;
struct
pp_sim_time_instance
*
t_inst
;
...
@@ -57,8 +57,8 @@ static int f_init_time(int lineno, struct pp_globals *ppg,
...
@@ -57,8 +57,8 @@ static int f_init_time(int lineno, struct pp_globals *ppg,
return
0
;
return
0
;
}
}
static
int
f_fwd_t_prop
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_fwd_t_prop
(
struct
pp_argline
*
l
,
int
lineno
,
union
pp_cfg_arg
*
arg
)
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
{
struct
sim_ppi_arch_data
*
data
;
struct
sim_ppi_arch_data
*
data
;
data
=
SIM_PPI_ARCH
(
pp_sim_get_master
(
ppg
));
data
=
SIM_PPI_ARCH
(
pp_sim_get_master
(
ppg
));
...
@@ -66,8 +66,8 @@ static int f_fwd_t_prop(int lineno, struct pp_globals *ppg,
...
@@ -66,8 +66,8 @@ static int f_fwd_t_prop(int lineno, struct pp_globals *ppg,
return
0
;
return
0
;
}
}
static
int
f_bckwd_t_prop
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_bckwd_t_prop
(
struct
pp_argline
*
l
,
int
lineno
,
union
pp_cfg_arg
*
arg
)
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
{
struct
sim_ppi_arch_data
*
data
;
struct
sim_ppi_arch_data
*
data
;
data
=
SIM_PPI_ARCH
(
pp_sim_get_slave
(
ppg
));
data
=
SIM_PPI_ARCH
(
pp_sim_get_slave
(
ppg
));
...
@@ -75,15 +75,15 @@ static int f_bckwd_t_prop(int lineno, struct pp_globals *ppg,
...
@@ -75,15 +75,15 @@ static int f_bckwd_t_prop(int lineno, struct pp_globals *ppg,
return
0
;
return
0
;
}
}
static
int
f_t_prop
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_t_prop
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
f_fwd_t_prop
(
lineno
,
ppg
,
arg
);
f_fwd_t_prop
(
l
,
l
ineno
,
ppg
,
arg
);
f_bckwd_t_prop
(
lineno
,
ppg
,
arg
);
f_bckwd_t_prop
(
l
,
l
ineno
,
ppg
,
arg
);
return
0
;
return
0
;
}
}
static
int
f_fwd_jit
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_fwd_jit
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
struct
sim_ppi_arch_data
*
data
;
struct
sim_ppi_arch_data
*
data
;
...
@@ -93,7 +93,7 @@ static int f_fwd_jit(int lineno, struct pp_globals *ppg,
...
@@ -93,7 +93,7 @@ static int f_fwd_jit(int lineno, struct pp_globals *ppg,
}
}
static
int
f_bckwd_jit
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_bckwd_jit
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
struct
sim_ppi_arch_data
*
data
;
struct
sim_ppi_arch_data
*
data
;
...
@@ -102,15 +102,15 @@ static int f_bckwd_jit(int lineno, struct pp_globals *ppg,
...
@@ -102,15 +102,15 @@ static int f_bckwd_jit(int lineno, struct pp_globals *ppg,
return
0
;
return
0
;
}
}
static
int
f_jit
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_jit
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
f_fwd_jit
(
lineno
,
ppg
,
arg
);
f_fwd_jit
(
l
,
l
ineno
,
ppg
,
arg
);
f_bckwd_jit
(
lineno
,
ppg
,
arg
);
f_bckwd_jit
(
l
,
l
ineno
,
ppg
,
arg
);
return
0
;
return
0
;
}
}
static
int
f_iter
(
int
lineno
,
struct
pp_globals
*
ppg
,
static
int
f_iter
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
union
pp_cfg_arg
*
arg
)
{
{
SIM_PPG_ARCH
(
ppg
)
->
sim_iter_max
=
arg
->
i
;
SIM_PPG_ARCH
(
ppg
)
->
sim_iter_max
=
arg
->
i
;
...
@@ -118,17 +118,17 @@ static int f_iter(int lineno, struct pp_globals *ppg,
...
@@ -118,17 +118,17 @@ static int f_iter(int lineno, struct pp_globals *ppg,
}
}
struct
pp_argline
pp_arch_arglines
[]
=
{
struct
pp_argline
pp_arch_arglines
[]
=
{
{
f_ppm_real
,
"sim_ppm_real"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_ppm_real
,
"sim_ppm_real"
,
ARG_INT
)
,
{
f_ppm_servo
,
"sim_init_ppm_servo"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_ppm_servo
,
"sim_init_ppm_servo"
,
ARG_INT
)
,
{
f_ofm
,
"sim_init_ofm"
,
ARG_TIME
}
,
LEGACY_OPTION
(
f_ofm
,
"sim_init_ofm"
,
ARG_TIME
)
,
{
f_init_time
,
"sim_init_master_time"
,
ARG_TIME
}
,
LEGACY_OPTION
(
f_init_time
,
"sim_init_master_time"
,
ARG_TIME
)
,
{
f_t_prop
,
"sim_t_prop_ns"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_t_prop
,
"sim_t_prop_ns"
,
ARG_INT
)
,
{
f_fwd_t_prop
,
"sim_fwd_t_prop_ns"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_fwd_t_prop
,
"sim_fwd_t_prop_ns"
,
ARG_INT
)
,
{
f_bckwd_t_prop
,
"sim_bckwd_t_prop_ns"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_bckwd_t_prop
,
"sim_bckwd_t_prop"
,
ARG_INT
)
,
{
f_jit
,
"sim_jit_ns"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_jit
,
"sim_jit_ns"
,
ARG_INT
)
,
{
f_fwd_jit
,
"sim_fwd_jit_ns"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_fwd_jit
,
"sim_fwd_jit_ns"
,
ARG_INT
)
,
{
f_bckwd_jit
,
"sim_bckwd_jit_ns"
,
ARG_INT
}
,
LEGACY_OPTION
(
f_bckwd_jit
,
"sim_bckwd_jit_ns"
,
ARG_INT
)
,
{
f_iter
,
"sim_iter_max"
,
ARG_TIME
}
,
LEGACY_OPTION
(
f_iter
,
"sim_iter_max"
,
ARG_TIME
)
,
{}
{}
};
};
...
...
arch-unix/unix-conf.c
View file @
c66e9950
...
@@ -8,20 +8,8 @@
...
@@ -8,20 +8,8 @@
#include <ppsi/ppsi.h>
#include <ppsi/ppsi.h>
static
int
f_rxdrop
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
ppg
->
rxdrop
=
arg
->
i
;
return
0
;
}
static
int
f_txdrop
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
ppg
->
txdrop
=
arg
->
i
;
return
0
;
}
struct
pp_argline
pp_arch_arglines
[]
=
{
struct
pp_argline
pp_arch_arglines
[]
=
{
{
f_rxdrop
,
"rx-drop"
,
ARG_INT
}
,
GLOB_OPTION_INT
(
"rx-drop"
,
ARG_INT
,
NULL
,
rxdrop
)
,
{
f_txdrop
,
"tx-drop"
,
ARG_INT
}
,
GLOB_OPTION_INT
(
"tx-drop"
,
ARG_INT
,
NULL
,
txdrop
)
,
{}
{}
};
};
doc/ppsi-manual.in
View file @
c66e9950
...
@@ -1224,12 +1224,6 @@ a list of the other ones please see the help message.
...
@@ -1224,12 +1224,6 @@ a list of the other ones please see the help message.
levels for fsm, time, frames, servo, bmc, extension
(
in that order
)
.
levels for fsm, time, frames, servo, bmc, extension
(
in that order
)
.
See @ref
{
Diagnostic Macros
}
for details.
See @ref
{
Diagnostic Macros
}
for details.
@item
-
b <ifname>
Specify which interface to use, for Ethernet mode
(
default:
architecture
-
dependent, but @t
{
eth
0
}
for Linux builds
)
. This
option can only be used in single
-
port operation.
@item
-
e
@item
-
e
Run in Ethernet mode
(
by default PPSi uses UDP if the architecture
Run in Ethernet mode
(
by default PPSi uses UDP if the architecture
...
...
include/ppsi/ppsi.h
View file @
c66e9950
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include <stdint.h>
#include <stdint.h>
#include <stdarg.h>
#include <stdarg.h>
#include <stddef.h>
#include <ppsi/lib.h>
#include <ppsi/lib.h>
#include <ppsi/ieee1588_types.h>
#include <ppsi/ieee1588_types.h>
#include <ppsi/constants.h>
#include <ppsi/constants.h>
...
@@ -278,6 +279,7 @@ struct pp_cfg_time {
...
@@ -278,6 +279,7 @@ struct pp_cfg_time {
* added inside here, without redefining cfg_handler prototype */
* added inside here, without redefining cfg_handler prototype */
union
pp_cfg_arg
{
union
pp_cfg_arg
{
int
i
;
int
i
;
int
i2
[
2
];
char
*
s
;
char
*
s
;
struct
pp_cfg_time
ts
;
struct
pp_cfg_time
ts
;
};
};
...
@@ -285,8 +287,10 @@ union pp_cfg_arg {
...
@@ -285,8 +287,10 @@ union pp_cfg_arg {
/*
/*
* Configuration: we are structure-based, and a typedef simplifies things
* Configuration: we are structure-based, and a typedef simplifies things
*/
*/
typedef
int
(
*
cfg_handler
)(
int
lineno
,
struct
pp_globals
*
ppg
,
struct
pp_argline
;
union
pp_cfg_arg
*
arg
);
typedef
int
(
*
cfg_handler
)(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
);
struct
pp_argname
{
struct
pp_argname
{
char
*
name
;
char
*
name
;
...
@@ -295,6 +299,7 @@ struct pp_argname {
...
@@ -295,6 +299,7 @@ struct pp_argname {
enum
pp_argtype
{
enum
pp_argtype
{
ARG_NONE
,
ARG_NONE
,
ARG_INT
,
ARG_INT
,
ARG_INT2
,
ARG_STR
,
ARG_STR
,
ARG_NAMES
,
ARG_NAMES
,
ARG_TIME
,
ARG_TIME
,
...
@@ -304,8 +309,48 @@ struct pp_argline {
...
@@ -304,8 +309,48 @@ struct pp_argline {
char
*
keyword
;
/* Each line starts with a keyword */
char
*
keyword
;
/* Each line starts with a keyword */
enum
pp_argtype
t
;
enum
pp_argtype
t
;
struct
pp_argname
*
args
;
struct
pp_argname
*
args
;
size_t
field_offset
;
int
needs_port
;
};
};
/* Below are macros for setting up pp_argline arrays */
#define OFFS(s,f) offsetof(struct s, f)
#define OPTION(s,func,k,typ,a,field,i) \
{ \
.f = func, \
.keyword = k, \
.t = typ, \
.args = a, \
.field_offset = OFFS(s,field), \
.needs_port = i, \
}
#define LEGACY_OPTION(func,k,typ) \
{ \
.f = func, \
.keyword = k, \
.t = typ, \
}
#define INST_OPTION(func,k,t,a,field) \
OPTION(pp_instance,func,k,t,a,field,1)
#define INST_OPTION_INT(k,t,a,field) \
INST_OPTION(f_simple_int,k,t,a,field)
#define RT_OPTION(func,k,t,a,field) \
OPTION(pp_runtime_opts,func,k,t,a,field,0)
#define GLOB_OPTION(func,k,t,a,field) \
OPTION(pp_globals,func,k,t,a,field,0)
#define RT_OPTION_INT(k,t,a,field) \
RT_OPTION(f_simple_int,k,t,a,field)
#define GLOB_OPTION_INT(k,t,a,field) \
GLOB_OPTION(f_simple_int,k,t,a,field)
/* Both the architecture and the extension can provide config arguments */
/* Both the architecture and the extension can provide config arguments */
extern
struct
pp_argline
pp_arch_arglines
[];
extern
struct
pp_argline
pp_arch_arglines
[];
extern
struct
pp_argline
pp_ext_arglines
[];
extern
struct
pp_argline
pp_ext_arglines
[];
...
@@ -313,6 +358,8 @@ extern struct pp_argline pp_ext_arglines[];
...
@@ -313,6 +358,8 @@ extern struct pp_argline pp_ext_arglines[];
/* Note: config_string modifies the string it receives */
/* Note: config_string modifies the string it receives */
extern
int
pp_config_string
(
struct
pp_globals
*
ppg
,
char
*
s
);
extern
int
pp_config_string
(
struct
pp_globals
*
ppg
,
char
*
s
);
extern
int
pp_config_file
(
struct
pp_globals
*
ppg
,
int
force
,
char
*
fname
);
extern
int
pp_config_file
(
struct
pp_globals
*
ppg
,
int
force
,
char
*
fname
);
extern
int
f_simple_int
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
);
#define PPSI_PROTO_RAW 0
#define PPSI_PROTO_RAW 0
#define PPSI_PROTO_UDP 1
#define PPSI_PROTO_UDP 1
...
...
lib/cmdline.c
View file @
c66e9950
...
@@ -28,30 +28,13 @@ static struct cmd_line_opt cmd_line_list[] = {
...
@@ -28,30 +28,13 @@ static struct cmd_line_opt cmd_line_list[] = {
{
"-d STRING"
,
"diagnostic level (see diag-macros.h)"
},
{
"-d STRING"
,
"diagnostic level (see diag-macros.h)"
},
CMD_LINE_SEPARATOR
,
CMD_LINE_SEPARATOR
,
{
"-x"
,
"do not reset the clock if off by more than one second"
},
{
"-x"
,
"do not reset the clock if off by more than one second"
},
{
"-O NUMBER"
,
"do not reset the clock if offset is more than NUMBER nanoseconds"
},
{
"-M NUMBER"
,
"do not accept delay values of more than NUMBER nanoseconds"
},
{
"-t"
,
"do not adjust the system clock"
},
{
"-t"
,
"do not adjust the system clock"
},
{
"-a NUMBER,NUMBER"
,
"specify clock servo P and I values (min == 1)"
},
{
"-w NUMBER"
,
"specify meanPathDelay filter stiffness"
},
{
"-w NUMBER"
,
"specify meanPathDelay filter stiffness"
},
CMD_LINE_SEPARATOR
,
CMD_LINE_SEPARATOR
,
{
"-b NAME"
,
"bind PTP to network interface NAME"
},
//{"-u ADDRESS", "also send uni-cast to ADDRESS\n"}, -- FIXME: useful?
//{"-u ADDRESS", "also send uni-cast to ADDRESS\n"}, -- FIXME: useful?
{
"-e"
,
"run in ethernet mode (level2)"
},
/* {"-h", "run in End to End mode"}, -- we only support end-to-end */
/* {"-h", "run in End to End mode"}, -- we only support end-to-end */
/* {"-G", "run in gPTP mode (implies -e)"}, -- no peer-to-peer mode */
/* {"-G", "run in gPTP mode (implies -e)"}, -- no peer-to-peer mode */
{
"-l NUMBER,NUMBER"
,
"specify inbound, outbound latency in nsec"
},
CMD_LINE_SEPARATOR
,
{
"-i NUMBER"
,
"specify PTP domain number"
},
CMD_LINE_SEPARATOR
,
{
"-n NUMBER"
,
"specify announce interval in 2^NUMBER sec"
},
{
"-y NUMBER"
,
"specify sync interval in 2^NUMBER sec"
},
CMD_LINE_SEPARATOR
,
{
"-g"
,
"run as slave only"
},
{
"-g"
,
"run as slave only"
},
{
"-v NUMBER"
,
"specify system clock allen variance"
},
{
"-r NUMBER"
,
"specify system clock accuracy"
},
{
"-s NUMBER"
,
"specify system clock class"
},
{
"-p NUMBER"
,
"specify priority1 attribute"
},
{
"-q NUMBER"
,
"specify priority2 attribute"
},
CMD_LINE_SEPARATOR
,
CMD_LINE_SEPARATOR
,
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
...
@@ -70,28 +53,11 @@ static void cmd_line_print_help(void)
...
@@ -70,28 +53,11 @@ static void cmd_line_print_help(void)
}
}
}
}
static
void
cmd_line_parse_two
(
char
*
a
,
int
*
n1
,
int
*
n2
)
{
int
i
,
comma
=
0
;
*
n1
=
*
n2
=
0
;
for
(
i
=
0
;
a
[
i
]
!=
'\0'
;
i
++
)
{
if
(
a
[
i
]
==
','
)
{
comma
=
i
;
a
[
i
]
=
'\0'
;
*
n1
=
atoi
(
a
);
break
;
}
}
*
n2
=
atoi
(
&
a
[
comma
+
1
]);
a
[
comma
]
=
','
;
}
int
pp_parse_cmdline
(
struct
pp_globals
*
ppg
,
int
argc
,
char
**
argv
)
int
pp_parse_cmdline
(
struct
pp_globals
*
ppg
,
int
argc
,
char
**
argv
)
{
{
int
i
,
err
=
0
;
int
i
,
err
=
0
;
int
j
;
int
j
;
char
*
a
;
/* cmd line argument */
char
*
a
;
/* cmd line argument */
int
n1
,
n2
;
/* used by cmd_line_parse_two */
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
a
=
argv
[
i
];
a
=
argv
[
i
];
...
@@ -123,76 +89,13 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
...
@@ -123,76 +89,13 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case
'x'
:
case
'x'
:
GOPTS
(
ppg
)
->
flags
|=
PP_FLAG_NO_RESET
;
GOPTS
(
ppg
)
->
flags
|=
PP_FLAG_NO_RESET
;
break
;
break
;
case
'O'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
max_rst
=
atoi
(
a
);
if
(
GOPTS
(
ppg
)
->
max_rst
>
PP_NSEC_PER_SEC
)
{
pp_printf
(
"Use -x to prevent jumps of"
" more than one second
\n
"
);
return
-
1
;
}
break
;
case
'M'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
max_dly
=
atoi
(
a
);
if
(
GOPTS
(
ppg
)
->
max_dly
>
PP_NSEC_PER_SEC
)
{
pp_printf
(
"Use -x to prevent jumps of"
" more than one second
\n
"
);
return
-
1
;
}
break
;
case
't'
:
case
't'
:
GOPTS
(
ppg
)
->
flags
|=
PP_FLAG_NO_ADJUST
;
GOPTS
(
ppg
)
->
flags
|=
PP_FLAG_NO_ADJUST
;
break
;
break
;
case
'a'
:
a
=
argv
[
++
i
];
cmd_line_parse_two
(
a
,
&
n1
,
&
n2
);
/* no negative or zero attenuation */
if
(
n1
<
1
||
n2
<
1
)
return
-
1
;
GOPTS
(
ppg
)
->
ap
=
n1
;
GOPTS
(
ppg
)
->
ai
=
n2
;
break
;
case
'w'
:
case
'w'
:
a
=
argv
[
++
i
];
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
s
=
atoi
(
a
);
GOPTS
(
ppg
)
->
s
=
atoi
(
a
);
break
;
break
;
case
'b'
:
a
=
argv
[
++
i
];
if
(
ppg
->
nlinks
==
1
)
{
INST
(
ppg
,
0
)
->
iface_name
=
a
;
INST
(
ppg
,
0
)
->
port_name
=
a
;
}
else
{
/* If ppsi.conf exists and more than one link is
* configured, it makes no sense trying to set an iface
* name */
pp_printf
(
"Can not use -b option in multi-link conf"
);
return
-
1
;
}
break
;
case
'l'
:
a
=
argv
[
++
i
];
cmd_line_parse_two
(
a
,
&
n1
,
&
n2
);
GOPTS
(
ppg
)
->
inbound_latency
.
nanoseconds
=
n1
;
GOPTS
(
ppg
)
->
outbound_latency
.
nanoseconds
=
n2
;
break
;
case
'i'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
domain_number
=
atoi
(
a
);
break
;
case
'y'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
sync_intvl
=
atoi
(
a
);
break
;
case
'n'
:
a
=
argv
[
++
i
];
/* Page 237 says 0 to 4 (1s .. 16s) */
GOPTS
(
ppg
)
->
announce_intvl
=
atoi
(
a
);
if
(
GOPTS
(
ppg
)
->
announce_intvl
<
0
)
GOPTS
(
ppg
)
->
announce_intvl
=
0
;
if
(
GOPTS
(
ppg
)
->
announce_intvl
>
4
)
GOPTS
(
ppg
)
->
announce_intvl
=
4
;
break
;
case
'g'
:
case
'g'
:
GOPTS
(
ppg
)
->
clock_quality
.
clockClass
GOPTS
(
ppg
)
->
clock_quality
.
clockClass
=
PP_CLASS_SLAVE_ONLY
;
=
PP_CLASS_SLAVE_ONLY
;
...
@@ -200,37 +103,9 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
...
@@ -200,37 +103,9 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
for
(
j
=
0
;
j
<
ppg
->
nlinks
;
j
++
)
for
(
j
=
0
;
j
<
ppg
->
nlinks
;
j
++
)
INST
(
ppg
,
j
)
->
role
=
PPSI_ROLE_SLAVE
;
INST
(
ppg
,
j
)
->
role
=
PPSI_ROLE_SLAVE
;
break
;
break
;
case
'v'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
clock_quality
.
offsetScaledLogVariance
=
atoi
(
a
);
break
;
case
'r'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
clock_quality
.
clockAccuracy
=
atoi
(
a
);
break
;
case
's'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
clock_quality
.
clockClass
=
atoi
(
a
);
break
;
case
'p'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
prio1
=
atoi
(
a
);
break
;
case
'q'
:
a
=
argv
[
++
i
];
GOPTS
(
ppg
)
->
prio2
=
atoi
(
a
);
break
;
case
'h'
:
case
'h'
:
/* ignored: was "GOPTS(ppg)->e2e_mode = 1;" */
/* ignored: was "GOPTS(ppg)->e2e_mode = 1;" */
break
;
break
;
case
'e'
:
/* Apply -e option globally, to each configured link */
for
(
j
=
0
;
j
<
ppg
->
nlinks
;
j
++
)
INST
(
ppg
,
j
)
->
proto
=
PPSI_PROTO_RAW
;
break
;
case
'G'
:
case
'G'
:
/* gptp_mode not supported: fall through */
/* gptp_mode not supported: fall through */
default:
default:
...
...
lib/conf.c
View file @
c66e9950
...
@@ -22,7 +22,8 @@ static inline struct pp_instance *CUR_PPI(struct pp_globals *ppg)
...
@@ -22,7 +22,8 @@ static inline struct pp_instance *CUR_PPI(struct pp_globals *ppg)
}
}
/* A "port" (or "link", for compatibility) line creates or uses a pp instance */
/* A "port" (or "link", for compatibility) line creates or uses a pp instance */
static
int
f_port
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
static
int
f_port
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
{
int
i
;
int
i
;
...
@@ -62,52 +63,35 @@ static int f_port(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg)
...
@@ -62,52 +63,35 @@ static int f_port(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg)
return -1; \
return -1; \
}})
}})
static
int
f_if
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
static
inline
void
ASSIGN_INT_FIELD
(
struct
pp_argline
*
l
,
struct
pp_globals
*
ppg
,
int
v
)
{
{
CHECK_PPI
(
1
);
if
(
l
->
needs_port
)
strcpy
(
CUR_PPI
(
ppg
)
->
cfg
.
iface_name
,
arg
->
s
);
*
(
int
*
)(((
void
*
)
CUR_PPI
(
ppg
))
+
l
->
field_offset
)
=
v
;
return
0
;
else
}
*
(
int
*
)(((
void
*
)
GOPTS
(
ppg
))
+
l
->
field_offset
)
=
v
;
/* The following ones are so similar. Bah... set a pointer somewhere? */
static
int
f_proto
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
CHECK_PPI
(
1
);
CUR_PPI
(
ppg
)
->
proto
=
arg
->
i
;
return
0
;
}
}
static
int
f_role
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
int
f_simple_int
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
{
CHECK_PPI
(
1
);
CHECK_PPI
(
l
->
needs_port
);
CUR_PPI
(
ppg
)
->
role
=
arg
->
i
;
ASSIGN_INT_FIELD
(
l
,
ppg
,
arg
->
i
)
;
return
0
;
return
0
;
}
}
static
int
f_ext
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
static
int
f_if
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
{
CHECK_PPI
(
1
);
CHECK_PPI
(
1
);
CUR_PPI
(
ppg
)
->
cfg
.
ext
=
arg
->
i
;
strcpy
(
CUR_PPI
(
ppg
)
->
cfg
.
iface_name
,
arg
->
s
);
return
0
;
}
/* The following two are identical as well. I really need a pointer... */
static
int
f_class
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
CHECK_PPI
(
0
);
GOPTS
(
ppg
)
->
clock_quality
.
clockClass
=
arg
->
i
;
return
0
;
}
static
int
f_accuracy
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
CHECK_PPI
(
0
);
GOPTS
(
ppg
)
->
clock_quality
.
clockAccuracy
=
arg
->
i
;
return
0
;
return
0
;
}
}
/* Diagnostics can be per-port or global */
/* Diagnostics can be per-port or global */
static
int
f_diag
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
static
int
f_diag
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
{
unsigned
long
level
=
pp_diag_parse
(
arg
->
s
);
unsigned
long
level
=
pp_diag_parse
(
arg
->
s
);
...
@@ -119,7 +103,8 @@ static int f_diag(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg)
...
@@ -119,7 +103,8 @@ static int f_diag(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg)
}
}
/* VLAN support is per-port, and it depends on configuration itmes */
/* VLAN support is per-port, and it depends on configuration itmes */
static
int
f_vlan
(
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
static
int
f_vlan
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
{
struct
pp_instance
*
ppi
=
CUR_PPI
(
ppg
);
struct
pp_instance
*
ppi
=
CUR_PPI
(
ppg
);
int
i
,
n
,
*
v
;
int
i
,
n
,
*
v
;
...
@@ -183,6 +168,48 @@ static int f_vlan(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg)
...
@@ -183,6 +168,48 @@ static int f_vlan(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg)
return
0
;
return
0
;
}
}
static
int
f_servo_pi
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
int
n1
,
n2
;
CHECK_PPI
(
0
);
n1
=
arg
->
i2
[
0
];
n2
=
arg
->
i2
[
1
];
/* no negative or zero attenuation */
if
(
n1
<
1
||
n2
<
1
)
return
-
1
;
GOPTS
(
ppg
)
->
ap
=
n1
;
GOPTS
(
ppg
)
->
ai
=
n2
;
return
0
;
}
static
int
f_latency
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
int
n1
,
n2
;
CHECK_PPI
(
0
);
n1
=
arg
->
i2
[
0
];
n2
=
arg
->
i2
[
1
];
GOPTS
(
ppg
)
->
inbound_latency
.
nanoseconds
=
n1
;
GOPTS
(
ppg
)
->
outbound_latency
.
nanoseconds
=
n2
;
return
0
;
}
static
int
f_announce_intvl
(
struct
pp_argline
*
l
,
int
lineno
,
struct
pp_globals
*
ppg
,
union
pp_cfg_arg
*
arg
)
{
int
i
=
arg
->
i
;
CHECK_PPI
(
0
);
if
(
i
<
0
||
i
>
4
)
{
i
=
i
<
0
?
0
:
4
;
pp_printf
(
"config line %i: announce interval out of range: %i, "
"forced to %i
\n
"
,
lineno
,
arg
->
i
,
i
);
}
GOPTS
(
ppg
)
->
announce_intvl
=
i
;
return
0
;
}
/* These are the tables for the parser */
/* These are the tables for the parser */
static
struct
pp_argname
arg_proto
[]
=
{
static
struct
pp_argname
arg_proto
[]
=
{
{
"raw"
,
PPSI_PROTO_RAW
},
{
"raw"
,
PPSI_PROTO_RAW
},
...
@@ -203,16 +230,26 @@ static struct pp_argname arg_ext[] = {
...
@@ -203,16 +230,26 @@ static struct pp_argname arg_ext[] = {
};
};
static
struct
pp_argline
pp_global_arglines
[]
=
{
static
struct
pp_argline
pp_global_arglines
[]
=
{
{
f_port
,
"port"
,
ARG_STR
},
LEGACY_OPTION
(
f_port
,
"port"
,
ARG_STR
),
{
f_port
,
"link"
,
ARG_STR
},
/* old name for "port" */
LEGACY_OPTION
(
f_port
,
"link"
,
ARG_STR
),
/* Old name for port */
{
f_if
,
"iface"
,
ARG_STR
},
LEGACY_OPTION
(
f_if
,
"iface"
,
ARG_STR
),
{
f_proto
,
"proto"
,
ARG_NAMES
,
arg_proto
},
INST_OPTION_INT
(
"proto"
,
ARG_NAMES
,
arg_proto
,
proto
),
{
f_role
,
"role"
,
ARG_NAMES
,
arg_role
},
INST_OPTION_INT
(
"role"
,
ARG_NAMES
,
arg_role
,
role
),
{
f_ext
,
"extension"
,
ARG_NAMES
,
arg_ext
},
INST_OPTION_INT
(
"extension"
,
ARG_NAMES
,
arg_ext
,
cfg
.
ext
),
{
f_vlan
,
"vlan"
,
ARG_STR
},
LEGACY_OPTION
(
f_vlan
,
"vlan"
,
ARG_STR
),
{
f_diag
,
"diagnostics"
,
ARG_STR
},
LEGACY_OPTION
(
f_diag
,
"diagnostic"
,
ARG_STR
),
{
f_class
,
"clock-class"
,
ARG_INT
},
RT_OPTION_INT
(
"clock-class"
,
ARG_INT
,
NULL
,
clock_quality
.
clockClass
),
{
f_accuracy
,
"clock-accuracy"
,
ARG_INT
},
RT_OPTION_INT
(
"clock-accuracy"
,
ARG_INT
,
NULL
,
clock_quality
.
clockAccuracy
),
RT_OPTION_INT
(
"clock-allan-variance"
,
ARG_INT
,
NULL
,
clock_quality
.
offsetScaledLogVariance
),
LEGACY_OPTION
(
f_servo_pi
,
"servo-pi"
,
ARG_INT2
),
LEGACY_OPTION
(
f_latency
,
"latency"
,
ARG_INT2
),
RT_OPTION_INT
(
"domain-number"
,
ARG_INT
,
NULL
,
domain_number
),
LEGACY_OPTION
(
f_announce_intvl
,
"announce-interval"
,
ARG_INT
),
RT_OPTION_INT
(
"sync-interval"
,
ARG_INT
,
NULL
,
sync_intvl
),
RT_OPTION_INT
(
"priority1"
,
ARG_INT
,
NULL
,
prio1
),
RT_OPTION_INT
(
"priority2"
,
ARG_INT
,
NULL
,
prio2
),
{}
{}
};
};
...
@@ -380,6 +417,14 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
...
@@ -380,6 +417,14 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
}
}
break
;
break
;
case
ARG_INT2
:
if
(
sscanf
(
line
,
"%i,%i"
,
cfg_arg
.
i2
,
&
cfg_arg
.
i2
[
1
])
<
0
)
{
pp_diag
(
NULL
,
config
,
1
,
"line %i: wrong arg
\"
%s
\"
"
" for
\"
%s
\"\n
"
,
lineno
,
line
,
word
);
return
-
1
;
}
break
;
case
ARG_STR
:
case
ARG_STR
:
while
(
*
line
&&
blank
(
*
line
))
while
(
*
line
&&
blank
(
*
line
))
line
++
;
line
++
;
...
@@ -408,7 +453,7 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
...
@@ -408,7 +453,7 @@ static int pp_config_line(struct pp_globals *ppg, char *line, int lineno)
break
;
break
;
}
}
if
(
l
->
f
(
lineno
,
ppg
,
&
cfg_arg
))
if
(
l
->
f
(
l
,
l
ineno
,
ppg
,
&
cfg_arg
))
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
...
time-unix/unix-socket.c
View file @
c66e9950
...
@@ -469,6 +469,10 @@ static int unix_net_init(struct pp_instance *ppi)
...
@@ -469,6 +469,10 @@ static int unix_net_init(struct pp_instance *ppi)
/* The buffer is inside ppi, but we need to set pointers and align */
/* The buffer is inside ppi, but we need to set pointers and align */
pp_prepare_pointers
(
ppi
);
pp_prepare_pointers
(
ppi
);
if
(
!
ppi
->
iface_name
||
!
ppi
->
iface_name
[
0
])
/* No interface name, set it to port name */
ppi
->
iface_name
=
ppi
->
port_name
;
switch
(
ppi
->
proto
)
{
switch
(
ppi
->
proto
)
{
case
PPSI_PROTO_RAW
:
case
PPSI_PROTO_RAW
:
pp_diag
(
ppi
,
frames
,
1
,
"unix_net_init raw Ethernet
\n
"
);
pp_diag
(
ppi
,
frames
,
1
,
"unix_net_init raw Ethernet
\n
"
);
...
...
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