Commit 884bcf0a authored by Alessandro Rubini's avatar Alessandro Rubini

Merge branch 'no-bitfields'

parents ea6042b4 996e152b
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#Warning "Please include <ppsi/constants.h> before <arch/constants.h>" #Warning "Please include <ppsi/constants.h> before <arch/constants.h>"
#endif #endif
#undef PP_DEFAULT_ETHERNET_MODE #undef PP_DEFAULT_PROTO
#define PP_DEFAULT_ETHERNET_MODE 1 /* We only use raw ethernet */ #define PP_DEFAULT_PROTO PPSI_PROTO_RAW /* We only use raw ethernet */
#endif /* __PPSI_ARCH_CONSTANTS_H__ */ #endif /* __PPSI_ARCH_CONSTANTS_H__ */
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#Warning "Please include <ppsi/constants.h> before <arch/constants.h>" #Warning "Please include <ppsi/constants.h> before <arch/constants.h>"
#endif #endif
#undef PP_DEFAULT_ETHERNET_MODE #undef PP_DEFAULT_PROTO
#define PP_DEFAULT_ETHERNET_MODE 1 /* We only use raw ethernet */ #define PP_DEFAULT_PROTO PPSI_PROTO_RAW /* We only use raw ethernet */
#endif /* __PPSI_ARCH_CONSTANTS_H__ */ #endif /* __PPSI_ARCH_CONSTANTS_H__ */
...@@ -20,8 +20,7 @@ static struct pp_runtime_opts sim_master_rt_opts = { ...@@ -20,8 +20,7 @@ static struct pp_runtime_opts sim_master_rt_opts = {
.outbound_latency = {0, PP_DEFAULT_OUTBOUND_LATENCY}, .outbound_latency = {0, PP_DEFAULT_OUTBOUND_LATENCY},
.max_rst = PP_DEFAULT_MAX_RESET, .max_rst = PP_DEFAULT_MAX_RESET,
.max_dly = PP_DEFAULT_MAX_DELAY, .max_dly = PP_DEFAULT_MAX_DELAY,
.no_adjust = PP_DEFAULT_NO_ADJUST, .flags = PP_DEFAULT_FLAGS,
.no_rst_clk = PP_DEFAULT_NO_RESET_CLOCK,
.ap = PP_DEFAULT_AP, .ap = PP_DEFAULT_AP,
.ai = PP_DEFAULT_AI, .ai = PP_DEFAULT_AI,
.s = PP_DEFAULT_DELAY_S, .s = PP_DEFAULT_DELAY_S,
...@@ -58,6 +57,7 @@ int sim_set_global_DS(struct pp_instance *ppi) ...@@ -58,6 +57,7 @@ int sim_set_global_DS(struct pp_instance *ppi)
static int sim_ppi_init(struct pp_instance *ppi, int which_ppi) static int sim_ppi_init(struct pp_instance *ppi, int which_ppi)
{ {
struct sim_ppi_arch_data *data; struct sim_ppi_arch_data *data;
ppi->proto = PP_DEFAULT_PROTO;
ppi->arch_data = calloc(1, sizeof(struct sim_ppi_arch_data)); ppi->arch_data = calloc(1, sizeof(struct sim_ppi_arch_data));
ppi->portDS = calloc(1, sizeof(*ppi->portDS)); ppi->portDS = calloc(1, sizeof(*ppi->portDS));
if ((!ppi->arch_data) || (!ppi->portDS)) if ((!ppi->arch_data) || (!ppi->portDS))
...@@ -143,16 +143,9 @@ int main(int argc, char **argv) ...@@ -143,16 +143,9 @@ int main(int argc, char **argv)
if (ppi->cfg.proto == PPSI_PROTO_RAW) if (ppi->cfg.proto == PPSI_PROTO_RAW)
pp_printf("Warning: simulator doesn't support raw " pp_printf("Warning: simulator doesn't support raw "
"ethernet. Using UDP\n"); "ethernet. Using UDP\n");
ppi->ethernet_mode = 0;
NP(ppi)->ch[PP_NP_GEN].fd = -1; NP(ppi)->ch[PP_NP_GEN].fd = -1;
NP(ppi)->ch[PP_NP_EVT].fd = -1; NP(ppi)->ch[PP_NP_EVT].fd = -1;
if (ppi->cfg.role == PPSI_ROLE_MASTER) { ppi->role = ppi->cfg.role;
ppi->master_only = 1;
ppi->slave_only = 0;
} else if (ppi->cfg.role == PPSI_ROLE_SLAVE) {
ppi->master_only = 0;
ppi->slave_only = 1;
}
ppi->t_ops = &DEFAULT_TIME_OPS; ppi->t_ops = &DEFAULT_TIME_OPS;
ppi->n_ops = &DEFAULT_NET_OPS; ppi->n_ops = &DEFAULT_NET_OPS;
if (pp_sim_is_master(ppi)) if (pp_sim_is_master(ppi))
......
...@@ -52,7 +52,7 @@ void unix_main_loop(struct pp_globals *ppg) ...@@ -52,7 +52,7 @@ void unix_main_loop(struct pp_globals *ppg)
* If we are sending or receiving raw ethernet frames, * If we are sending or receiving raw ethernet frames,
* the ptp payload is one-eth-header bytes into the frame * the ptp payload is one-eth-header bytes into the frame
*/ */
if (ppi->ethernet_mode) if (ppi->proto == PPSI_PROTO_RAW)
NP(ppi)->ptp_offset = ETH_HLEN; NP(ppi)->ptp_offset = ETH_HLEN;
/* /*
......
...@@ -55,6 +55,11 @@ int main(int argc, char **argv) ...@@ -55,6 +55,11 @@ int main(int argc, char **argv)
ppg->max_links = PP_MAX_LINKS; ppg->max_links = PP_MAX_LINKS;
ppg->arch_data = calloc(1, sizeof(struct unix_arch_data)); ppg->arch_data = calloc(1, sizeof(struct unix_arch_data));
ppg->pp_instances = calloc(ppg->max_links, sizeof(struct pp_instance)); ppg->pp_instances = calloc(ppg->max_links, sizeof(struct pp_instance));
for (i = 0; i < ppg->max_links; i++) {
ppi = INST(ppg, i);
ppi->proto = PP_DEFAULT_PROTO;
ppi->role = PP_DEFAULT_ROLE;
}
if ((!ppg->arch_data) || (!ppg->pp_instances)) if ((!ppg->arch_data) || (!ppg->pp_instances))
exit(__LINE__); exit(__LINE__);
...@@ -82,15 +87,8 @@ int main(int argc, char **argv) ...@@ -82,15 +87,8 @@ int main(int argc, char **argv)
ppi->iface_name = ppi->cfg.iface_name; ppi->iface_name = ppi->cfg.iface_name;
ppi->port_name = ppi->cfg.port_name; ppi->port_name = ppi->cfg.port_name;
/* this old-fashioned "ethernet_mode" is a single bit */ /* this old-fashioned "ethernet_mode" is a single bit */
ppi->ethernet_mode = (ppi->cfg.proto == PPSI_PROTO_RAW); ppi->proto = ppi->cfg.proto;
if (ppi->cfg.role == PPSI_ROLE_MASTER) { ppi->role = ppi->cfg.role;
ppi->master_only = 1;
ppi->slave_only = 0;
}
else if (ppi->cfg.role == PPSI_ROLE_SLAVE) {
ppi->master_only = 0;
ppi->slave_only = 1;
}
/* FIXME set ppi ext enable as defined in its pp_link */ /* FIXME set ppi ext enable as defined in its pp_link */
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#Warning "Please include <ppsi/constants.h> before <arch/constants.h>" #Warning "Please include <ppsi/constants.h> before <arch/constants.h>"
#endif #endif
#undef PP_DEFAULT_ETHERNET_MODE #undef PP_DEFAULT_PROTO
#define PP_DEFAULT_ETHERNET_MODE 1 /* We only use raw ethernet */ #define PP_DEFAULT_PROTO PPSI_PROTO_RAW /* We only use raw ethernet */
#endif /* __PPSI_ARCH_CONSTANTS_H__ */ #endif /* __PPSI_ARCH_CONSTANTS_H__ */
...@@ -74,6 +74,7 @@ struct pp_instance ppi_static = { ...@@ -74,6 +74,7 @@ struct pp_instance ppi_static = {
.portDS = &portDS, .portDS = &portDS,
.n_ops = &wrpc_net_ops, .n_ops = &wrpc_net_ops,
.t_ops = &wrpc_time_ops, .t_ops = &wrpc_time_ops,
.proto = PP_DEFAULT_PROTO,
.iface_name = "wr1", .iface_name = "wr1",
.port_name = "wr1", .port_name = "wr1",
}; };
...@@ -124,8 +125,7 @@ int wrc_ptp_set_mode(int mode) ...@@ -124,8 +125,7 @@ int wrc_ptp_set_mode(int mode)
switch (mode) { switch (mode) {
case WRC_MODE_GM: case WRC_MODE_GM:
wrp->wrConfig = WR_M_ONLY; wrp->wrConfig = WR_M_ONLY;
ppi->master_only = TRUE; ppi->role = PPSI_ROLE_MASTER;
ppi->slave_only = FALSE;
*class_ptr = PP_CLASS_WR_GM_LOCKED; *class_ptr = PP_CLASS_WR_GM_LOCKED;
spll_init(SPLL_MODE_GRAND_MASTER, 0, 1); spll_init(SPLL_MODE_GRAND_MASTER, 0, 1);
lock_timeout = LOCK_TIMEOUT_GM; lock_timeout = LOCK_TIMEOUT_GM;
...@@ -133,8 +133,7 @@ int wrc_ptp_set_mode(int mode) ...@@ -133,8 +133,7 @@ int wrc_ptp_set_mode(int mode)
case WRC_MODE_MASTER: case WRC_MODE_MASTER:
wrp->wrConfig = WR_M_ONLY; wrp->wrConfig = WR_M_ONLY;
ppi->master_only = TRUE; ppi->role = PPSI_ROLE_MASTER;
ppi->slave_only = FALSE;
*class_ptr = PP_CLASS_DEFAULT; *class_ptr = PP_CLASS_DEFAULT;
spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, 1); spll_init(SPLL_MODE_FREE_RUNNING_MASTER, 0, 1);
lock_timeout = LOCK_TIMEOUT_FM; lock_timeout = LOCK_TIMEOUT_FM;
...@@ -142,8 +141,7 @@ int wrc_ptp_set_mode(int mode) ...@@ -142,8 +141,7 @@ int wrc_ptp_set_mode(int mode)
case WRC_MODE_SLAVE: case WRC_MODE_SLAVE:
wrp->wrConfig = WR_S_ONLY; wrp->wrConfig = WR_S_ONLY;
ppi->master_only = FALSE; ppi->role = PPSI_ROLE_SLAVE;
ppi->slave_only = TRUE;
*class_ptr = PP_CLASS_SLAVE_ONLY; *class_ptr = PP_CLASS_SLAVE_ONLY;
spll_init(SPLL_MODE_SLAVE, 0, 1); spll_init(SPLL_MODE_SLAVE, 0, 1);
break; break;
......
...@@ -88,7 +88,7 @@ void wrs_main_loop(struct pp_globals *ppg) ...@@ -88,7 +88,7 @@ void wrs_main_loop(struct pp_globals *ppg)
* If we are sending or receiving raw ethernet frames, * If we are sending or receiving raw ethernet frames,
* the ptp payload is one-eth-header bytes into the frame * the ptp payload is one-eth-header bytes into the frame
*/ */
if (ppi->ethernet_mode) if (ppi->proto == PPSI_PROTO_RAW)
NP(ppi)->ptp_offset = ETH_HLEN; NP(ppi)->ptp_offset = ETH_HLEN;
/* /*
......
...@@ -155,17 +155,8 @@ int main(int argc, char **argv) ...@@ -155,17 +155,8 @@ int main(int argc, char **argv)
ppi->glbs = ppg; ppi->glbs = ppg;
ppi->iface_name = ppi->cfg.iface_name; ppi->iface_name = ppi->cfg.iface_name;
ppi->port_name = ppi->cfg.port_name; ppi->port_name = ppi->cfg.port_name;
/* this old-fashioned "ethernet_mode" is a single bit */ ppi->proto = ppi->cfg.proto;
ppi->ethernet_mode = (ppi->cfg.proto == PPSI_PROTO_RAW); ppi->role = ppi->cfg.role;
if (ppi->cfg.role == PPSI_ROLE_MASTER) {
ppi->master_only = 1;
ppi->slave_only = 0;
}
else if (ppi->cfg.role == PPSI_ROLE_SLAVE) {
ppi->master_only = 0;
ppi->slave_only = 1;
}
ppi->portDS = calloc(1, sizeof(*ppi->portDS)); ppi->portDS = calloc(1, sizeof(*ppi->portDS));
if (!ppi->portDS) if (!ppi->portDS)
exit(__LINE__); exit(__LINE__);
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
@setchapternewpage off @setchapternewpage off
@set update-month July 2014 @set update-month November 2014
@set release __RELEASE_GIT_ID__ @set release __RELEASE_GIT_ID__
@finalout @finalout
...@@ -356,7 +356,8 @@ unfair to hide them. ...@@ -356,7 +356,8 @@ unfair to hide them.
We want to allow run-time modification of diagnostics flags We want to allow run-time modification of diagnostics flags
with a per-link granularity. Currently we have configuration-based with a per-link granularity. Currently we have configuration-based
per-link diagnostic flags and global flags that can be changed per-link diagnostic flags and global diagnostic
flags that can be changed
at run time (for example, arch-wrpc offers that through a shell at run time (for example, arch-wrpc offers that through a shell
command). We think this feature is useful command). We think this feature is useful
when you run more than a pair of interfaces and have problems when you run more than a pair of interfaces and have problems
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
unsigned long pp_global_flags; /* This is the only "global" file in ppsi */ unsigned long pp_global_d_flags; /* This is the only "global" file in ppsi */
/* /*
* This is somehow a duplicate of __pp_diag, but I still want * This is somehow a duplicate of __pp_diag, but I still want
...@@ -17,15 +17,15 @@ static void pp_fsm_printf(struct pp_instance *ppi, char *fmt, ...) ...@@ -17,15 +17,15 @@ static void pp_fsm_printf(struct pp_instance *ppi, char *fmt, ...)
{ {
va_list args; va_list args;
TimeInternal t; TimeInternal t;
unsigned long oflags = pp_global_flags; unsigned long oflags = pp_global_d_flags;
if (!pp_diag_allow(ppi, fsm, 1)) if (!pp_diag_allow(ppi, fsm, 1))
return; return;
/* temporarily set NOTIMELOG, as we'll print the time ourselves */ /* temporarily set NOTIMELOG, as we'll print the time ourselves */
pp_global_flags |= PP_FLAG_NOTIMELOG; pp_global_d_flags |= PP_FLAG_NOTIMELOG;
ppi->t_ops->get(ppi, &t); ppi->t_ops->get(ppi, &t);
pp_global_flags = oflags; pp_global_d_flags = oflags;
pp_printf("diag-fsm-1-%s: %09d.%03d: ", ppi->port_name, pp_printf("diag-fsm-1-%s: %09d.%03d: ", ppi->port_name,
(int)t.seconds, (int)t.nanoseconds / 1000000); (int)t.seconds, (int)t.nanoseconds / 1000000);
......
...@@ -13,13 +13,15 @@ ...@@ -13,13 +13,15 @@
#define PP_NSEC_PER_SEC (1000*1000*1000) #define PP_NSEC_PER_SEC (1000*1000*1000)
/* implementation specific constants */ /* implementation specific constants */
#define PP_DEFAULT_PPI_FLAGS 0 /* UDP mode */
#define PP_MAX_LINKS 64 #define PP_MAX_LINKS 64
#define PP_DEFAULT_CONFIGFILE "/etc/ppsi.conf" #define PP_DEFAULT_CONFIGFILE "/etc/ppsi.conf"
#define PP_DEFAULT_INBOUND_LATENCY 0 /* in nsec */ #define PP_DEFAULT_INBOUND_LATENCY 0 /* in nsec */
#define PP_DEFAULT_OUTBOUND_LATENCY 0 /* in nsec */ #define PP_DEFAULT_OUTBOUND_LATENCY 0 /* in nsec */
#define PP_DEFAULT_NO_RESET_CLOCK 0 #define PP_DEFAULT_FLAGS 0
#define PP_DEFAULT_ETHERNET_MODE 0 #define PP_DEFAULT_ROLE PPSI_ROLE_AUTO
#define PP_DEFAULT_PROTO PPSI_PROTO_UDP /* overridden by arch */
#define PP_DEFAULT_DOMAIN_NUMBER 0 #define PP_DEFAULT_DOMAIN_NUMBER 0
#define PP_DEFAULT_AP 10 #define PP_DEFAULT_AP 10
#define PP_DEFAULT_AI 1000 #define PP_DEFAULT_AI 1000
...@@ -46,7 +48,6 @@ ...@@ -46,7 +48,6 @@
#define PP_NR_FOREIGN_RECORDS 5 #define PP_NR_FOREIGN_RECORDS 5
#define PP_DEFAULT_MAX_RESET 0 #define PP_DEFAULT_MAX_RESET 0
#define PP_DEFAULT_MAX_DELAY 0 #define PP_DEFAULT_MAX_DELAY 0
#define PP_DEFAULT_NO_ADJUST 0
#define PP_DEFAULT_TTL 1 #define PP_DEFAULT_TTL 1
/* We use an array of timeouts, with these indexes */ /* We use an array of timeouts, with these indexes */
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#define pp_error(...) pp_printf("ERROR: " __VA_ARGS__) #define pp_error(...) pp_printf("ERROR: " __VA_ARGS__)
/* /*
* The "new" diagnostics is based on flags: there are per-instance flags * The "new" diagnostics is based on flags: there are per-instance d_flags
* and global flags. * and global d_flags.
* *
* Basically, we may have just bits about what to print, but we might * Basically, we may have just bits about what to print, but we might
* want to add extra-verbose stuff for specific cases, like looking at * want to add extra-verbose stuff for specific cases, like looking at
...@@ -37,17 +37,17 @@ enum pp_diag_things { ...@@ -37,17 +37,17 @@ enum pp_diag_things {
/* /*
* Note: we may use less bits and have more things, without changing * Note: we may use less bits and have more things, without changing
* anything. Set's say levels are ony 0..3 -- still,I prefer to be * anything. Set's say levels are ony 0..3 -- still,I prefer to be
* able to print the active flags as %x while debugging this very * able to print the active d_flags as %x while debugging this very
* mechanism). * mechanism).
*/ */
extern unsigned long pp_global_flags; /* Supplement ppi-specific ones */ extern unsigned long pp_global_d_flags; /* Supplement ppi-specific ones */
#define PP_FLAG_NOTIMELOG 1 /* This is for a special case, I'm sorry */ #define PP_FLAG_NOTIMELOG 1 /* This is for a special case, I'm sorry */
/* So, extract the level */ /* So, extract the level */
#define __PP_FLAGS(ppi) ((ppi ? ppi->flags : 0) | pp_global_flags) #define __PP_FLAGS(ppi) ((ppi ? ppi->d_flags : 0) | pp_global_d_flags)
#define __PP_DIAG_ALLOW(ppi, th, level) \ #define __PP_DIAG_ALLOW(ppi, th, level) \
((__PP_FLAGS(ppi) >> (4 * (th)) & 0xf) >= level) ((__PP_FLAGS(ppi) >> (4 * (th)) & 0xf) >= level)
......
...@@ -20,13 +20,7 @@ struct pp_runtime_opts { ...@@ -20,13 +20,7 @@ struct pp_runtime_opts {
Integer32 max_rst; /* Maximum number of nanoseconds to reset */ Integer32 max_rst; /* Maximum number of nanoseconds to reset */
Integer32 max_dly; /* Maximum number of nanoseconds of delay */ Integer32 max_dly; /* Maximum number of nanoseconds of delay */
Integer32 ttl; Integer32 ttl;
UInteger32 /* slave_only:1, -- moved to ppsi, is no more global */ int flags; /* see below */
/* master_only:1, -- moved to ppsi, is no more global */
no_adjust:1,
/* ethernet_mode:1, -- moved to ppsi, is no more global */
/* e2e_mode:1, -- no more: we only support e2e */
/* gptp_mode:1, -- no more: peer-to-peer unsupported */
no_rst_clk:1;
Integer16 ap, ai; Integer16 ap, ai;
Integer16 s; Integer16 s;
Integer8 announce_intvl; Integer8 announce_intvl;
...@@ -37,6 +31,23 @@ struct pp_runtime_opts { ...@@ -37,6 +31,23 @@ struct pp_runtime_opts {
void *arch_opts; void *arch_opts;
}; };
/*
* Flags for the above structure
*/
#define PP_FLAG_NO_ADJUST 0x01
#define PP_FLAG_NO_RESET 0x02
/* I'd love to use inlines, but we still miss some structure at this point*/
#define pp_can_adjust(ppi) (!(OPTS(ppi)->flags & PP_FLAG_NO_ADJUST))
#define pp_can_reset_clock(ppi) (!(OPTS(ppi)->flags & PP_FLAG_NO_RESET))
/* slave_only:1, -- moved to ppi, no more global */
/* master_only:1, -- moved to ppi, no more global */
/* ethernet_mode:1, -- moved to ppi, no more global */
/* e2e_mode:1, -- no more: we only support e2e */
/* gptp_mode:1, -- no more: peer-to-peer unsupported */
/* We need a globally-accessible structure with preset defaults */ /* We need a globally-accessible structure with preset defaults */
extern struct pp_runtime_opts __pp_default_rt_opts; extern struct pp_runtime_opts __pp_default_rt_opts;
...@@ -129,7 +140,10 @@ struct pp_instance { ...@@ -129,7 +140,10 @@ struct pp_instance {
int next_state, next_delay, is_new_state; /* set by state processing */ int next_state, next_delay, is_new_state; /* set by state processing */
void *arch_data; /* if arch needs it */ void *arch_data; /* if arch needs it */
void *ext_data; /* if protocol ext needs it */ void *ext_data; /* if protocol ext needs it */
unsigned long flags; /* ppi-specific flags (diag mainly) */ unsigned long d_flags; /* diagnostics, ppi-specific flags */
unsigned char flags, /* protocol flags (see below) */
role, /* same as in config file */
proto; /* same as in config file */
/* Pointer to global instance owning this pp_instance*/ /* Pointer to global instance owning this pp_instance*/
struct pp_globals *glbs; struct pp_globals *glbs;
...@@ -171,18 +185,16 @@ struct pp_instance { ...@@ -171,18 +185,16 @@ struct pp_instance {
UInteger16 sent_seq[__PP_NR_MESSAGES_TYPES]; /* last sent this type */ UInteger16 sent_seq[__PP_NR_MESSAGES_TYPES]; /* last sent this type */
MsgHeader received_ptp_header; MsgHeader received_ptp_header;
MsgHeader delay_req_hdr; MsgHeader delay_req_hdr;
UInteger32
is_from_cur_par:1,
waiting_for_follow:1,
slave_only:1,
master_only:1,
ethernet_mode:1;
char *iface_name; /* for direct actions on hardware */ char *iface_name; /* for direct actions on hardware */
char *port_name; /* for diagnostics, mainly */ char *port_name; /* for diagnostics, mainly */
int port_idx; int port_idx;
struct pp_instance_cfg cfg; struct pp_instance_cfg cfg;
}; };
/* The following things used to be bit fields. Other flags are now enums */
#define PPI_FLAG_FROM_CURRENT_PARENT 0x01
#define PPI_FLAG_WAITING_FOR_F_UP 0x02
struct pp_globals_cfg { struct pp_globals_cfg {
int cfg_items; /* Remember how many we parsed */ int cfg_items; /* Remember how many we parsed */
......
...@@ -39,7 +39,7 @@ static struct pp_instance ppi_static = { ...@@ -39,7 +39,7 @@ static struct pp_instance ppi_static = {
.t_ops = &bare_time_ops, .t_ops = &bare_time_ops,
.iface_name = "eth0", .iface_name = "eth0",
.port_name = "eth0", .port_name = "eth0",
.ethernet_mode = PP_DEFAULT_ETHERNET_MODE, .proto = PP_DEFAULT_PROTO,
}; };
/* We now have a structure with all globals, and multiple ppi inside */ /* We now have a structure with all globals, and multiple ppi inside */
......
...@@ -110,7 +110,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv) ...@@ -110,7 +110,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case 'd': case 'd':
/* Use the general flags, per-instance TBD */ /* Use the general flags, per-instance TBD */
a = argv[++i]; a = argv[++i];
pp_global_flags = pp_diag_parse(a); pp_global_d_flags = pp_diag_parse(a);
break; break;
case 'C': case 'C':
if (pp_config_string(ppg, argv[++i]) != 0) if (pp_config_string(ppg, argv[++i]) != 0)
...@@ -121,7 +121,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv) ...@@ -121,7 +121,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
return -1; return -1;
break; break;
case 'x': case 'x':
GOPTS(ppg)->no_rst_clk = 1; GOPTS(ppg)->flags |= PP_FLAG_NO_RESET;
break; break;
case 'O': case 'O':
a = argv[++i]; a = argv[++i];
...@@ -142,7 +142,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv) ...@@ -142,7 +142,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
} }
break; break;
case 't': case 't':
GOPTS(ppg)->no_adjust = 1; GOPTS(ppg)->flags |= PP_FLAG_NO_ADJUST;
break; break;
case 'a': case 'a':
a = argv[++i]; a = argv[++i];
...@@ -198,7 +198,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv) ...@@ -198,7 +198,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
= PP_CLASS_SLAVE_ONLY; = PP_CLASS_SLAVE_ONLY;
/* Apply -g option globally, to each configured link */ /* Apply -g option globally, to each configured link */
for (j = 0; j < ppg->nlinks; j++) for (j = 0; j < ppg->nlinks; j++)
INST(ppg, j)->slave_only = 1; INST(ppg, j)->role = PPSI_ROLE_SLAVE;
break; break;
case 'v': case 'v':
a = argv[++i]; a = argv[++i];
...@@ -229,7 +229,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv) ...@@ -229,7 +229,7 @@ int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
case 'e': case 'e':
/* Apply -e option globally, to each configured link */ /* Apply -e option globally, to each configured link */
for (j = 0; j < ppg->nlinks; j++) for (j = 0; j < ppg->nlinks; j++)
INST(ppg, j)->ethernet_mode = 1; INST(ppg, j)->proto = PPSI_PROTO_RAW;
break; break;
case 'G': case 'G':
/* gptp_mode not supported: fall through */ /* gptp_mode not supported: fall through */
......
...@@ -112,9 +112,9 @@ static int f_diag(int lineno, struct pp_globals *ppg, union pp_cfg_arg *arg) ...@@ -112,9 +112,9 @@ static int f_diag(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);
if (ppg->cfg.cur_ppi_n >= 0) if (ppg->cfg.cur_ppi_n >= 0)
CUR_PPI(ppg)->flags = level; CUR_PPI(ppg)->d_flags = level;
else else
pp_global_flags = level; pp_global_d_flags = level;
return 0; return 0;
} }
......
...@@ -260,7 +260,7 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -260,7 +260,7 @@ int wr_servo_update(struct pp_instance *ppi)
got_sync = 0; got_sync = 0;
if (__PP_DIAG_ALLOW_FLAGS(pp_global_flags, pp_dt_servo, 1)) { if (__PP_DIAG_ALLOW_FLAGS(pp_global_d_flags, pp_dt_servo, 1)) {
dump_timestamp(ppi, "servo:t1", s->t1); dump_timestamp(ppi, "servo:t1", s->t1);
dump_timestamp(ppi, "servo:t2", s->t2); dump_timestamp(ppi, "servo:t2", s->t2);
dump_timestamp(ppi, "servo:t3", s->t3); dump_timestamp(ppi, "servo:t3", s->t3);
......
...@@ -192,10 +192,10 @@ static int bmc_state_decision(struct pp_instance *ppi, ...@@ -192,10 +192,10 @@ static int bmc_state_decision(struct pp_instance *ppi,
int cmpres; int cmpres;
struct pp_frgn_master myself; struct pp_frgn_master myself;
if (ppi->master_only) if (ppi->role == PPSI_ROLE_MASTER)
goto master; goto master;
if (ppi->slave_only) if (ppi->role == PPSI_ROLE_SLAVE)
goto slave; goto slave;
if ((!ppi->frgn_rec_num) && (ppi->state == PPS_LISTENING)) if ((!ppi->frgn_rec_num) && (ppi->state == PPS_LISTENING))
......
...@@ -50,7 +50,7 @@ int st_com_execute_slave(struct pp_instance *ppi) ...@@ -50,7 +50,7 @@ int st_com_execute_slave(struct pp_instance *ppi)
if (pp_timeout_z(ppi, PP_TO_ANN_RECEIPT)) { if (pp_timeout_z(ppi, PP_TO_ANN_RECEIPT)) {
ppi->frgn_rec_num = 0; ppi->frgn_rec_num = 0;
if (DSDEF(ppi)->clockQuality.clockClass != PP_CLASS_SLAVE_ONLY if (DSDEF(ppi)->clockQuality.clockClass != PP_CLASS_SLAVE_ONLY
&& !ppi->slave_only) { && (ppi->role != PPSI_ROLE_SLAVE)) {
m1(ppi); m1(ppi);
ppi->next_state = PPS_MASTER; ppi->next_state = PPS_MASTER;
} else { } else {
...@@ -131,7 +131,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -131,7 +131,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
if (len < PP_SYNC_LENGTH) if (len < PP_SYNC_LENGTH)
return -1; return -1;
if (!ppi->is_from_cur_par) if (!(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT))
return 0; return 0;
/* t2 may be overriden by follow-up, cField is always valid */ /* t2 may be overriden by follow-up, cField is always valid */
...@@ -139,12 +139,12 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -139,12 +139,12 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
cField_to_TimeInternal(&ppi->cField, hdr->correctionfield); cField_to_TimeInternal(&ppi->cField, hdr->correctionfield);
if ((hdr->flagField[0] & PP_TWO_STEP_FLAG) != 0) { if ((hdr->flagField[0] & PP_TWO_STEP_FLAG) != 0) {
ppi->waiting_for_follow = TRUE; ppi->flags |= PPI_FLAG_WAITING_FOR_F_UP;
ppi->recv_sync_sequence_id = hdr->sequenceId; ppi->recv_sync_sequence_id = hdr->sequenceId;
return 0; return 0;
} }
msg_unpack_sync(buf, &sync); msg_unpack_sync(buf, &sync);
ppi->waiting_for_follow = FALSE; ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP;
to_TimeInternal(&ppi->t1, to_TimeInternal(&ppi->t1,
&sync.originTimestamp); &sync.originTimestamp);
pp_servo_got_sync(ppi); pp_servo_got_sync(ppi);
...@@ -163,13 +163,13 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf, ...@@ -163,13 +163,13 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
if (len < PP_FOLLOW_UP_LENGTH) if (len < PP_FOLLOW_UP_LENGTH)
return -1; return -1;
if (!ppi->is_from_cur_par) { if (!(ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
pp_error("%s: Follow up message is not from current parent\n", pp_error("%s: Follow up message is not from current parent\n",
__func__); __func__);
return 0; return 0;
} }
if (!ppi->waiting_for_follow) { if (!(ppi->flags & PPI_FLAG_WAITING_FOR_F_UP)) {
pp_error("%s: Slave was not waiting a follow up message\n", pp_error("%s: Slave was not waiting a follow up message\n",
__func__); __func__);
return 0; return 0;
...@@ -182,7 +182,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf, ...@@ -182,7 +182,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
} }
msg_unpack_follow_up(buf, &follow); msg_unpack_follow_up(buf, &follow);
ppi->waiting_for_follow = FALSE; ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP;
to_TimeInternal(&ppi->t1, &follow.preciseOriginTimestamp); to_TimeInternal(&ppi->t1, &follow.preciseOriginTimestamp);
/* Call the extension; it may do it all and ask to return */ /* Call the extension; it may do it all and ask to return */
......
...@@ -49,7 +49,7 @@ int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen) ...@@ -49,7 +49,7 @@ int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen)
return -1; return -1;
/* /*
* This "is_from_cur_par" must be killed. Meanwhile, say it's * This FLAG_FROM_CURRENT_PARENT must be killed. Meanwhile, say it's
* from current parent if we have no current parent, so the rest works * from current parent if we have no current parent, so the rest works
*/ */
if (!DSPAR(ppi)->parentPortIdentity.portNumber || if (!DSPAR(ppi)->parentPortIdentity.portNumber ||
...@@ -58,9 +58,9 @@ int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen) ...@@ -58,9 +58,9 @@ int msg_unpack_header(struct pp_instance *ppi, void *buf, int plen)
PP_CLOCK_IDENTITY_LENGTH) && PP_CLOCK_IDENTITY_LENGTH) &&
(DSPAR(ppi)->parentPortIdentity.portNumber == (DSPAR(ppi)->parentPortIdentity.portNumber ==
hdr->sourcePortIdentity.portNumber))) hdr->sourcePortIdentity.portNumber)))
ppi->is_from_cur_par = 1; ppi->flags |= PPI_FLAG_FROM_CURRENT_PARENT;
else else
ppi->is_from_cur_par = 0; ppi->flags &= ~PPI_FLAG_FROM_CURRENT_PARENT;
return 0; return 0;
} }
......
...@@ -21,8 +21,7 @@ struct pp_runtime_opts __pp_default_rt_opts = { ...@@ -21,8 +21,7 @@ struct pp_runtime_opts __pp_default_rt_opts = {
.outbound_latency = {0, PP_DEFAULT_OUTBOUND_LATENCY}, .outbound_latency = {0, PP_DEFAULT_OUTBOUND_LATENCY},
.max_rst = PP_DEFAULT_MAX_RESET, .max_rst = PP_DEFAULT_MAX_RESET,
.max_dly = PP_DEFAULT_MAX_DELAY, .max_dly = PP_DEFAULT_MAX_DELAY,
.no_adjust = PP_DEFAULT_NO_ADJUST, .flags = PP_DEFAULT_FLAGS,
.no_rst_clk = PP_DEFAULT_NO_RESET_CLOCK,
.ap = PP_DEFAULT_AP, .ap = PP_DEFAULT_AP,
.ai = PP_DEFAULT_AI, .ai = PP_DEFAULT_AI,
.s = PP_DEFAULT_DELAY_S, .s = PP_DEFAULT_DELAY_S,
...@@ -63,7 +62,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts) ...@@ -63,7 +62,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts)
sizeof(ClockQuality)); sizeof(ClockQuality));
if (def->numberPorts == 1) if (def->numberPorts == 1)
def->slaveOnly = INST(ppg, 0)->slave_only; def->slaveOnly = (INST(ppg, 0)->role == PPSI_ROLE_SLAVE);
else else
def->slaveOnly = 1; /* the for cycle below will set it to 0 if not def->slaveOnly = 1; /* the for cycle below will set it to 0 if not
* ports are not all slave_only */ * ports are not all slave_only */
...@@ -75,7 +74,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts) ...@@ -75,7 +74,7 @@ int pp_init_globals(struct pp_globals *ppg, struct pp_runtime_opts *pp_rt_opts)
for (i = 0; i < def->numberPorts; i++) { for (i = 0; i < def->numberPorts; i++) {
struct pp_instance *ppi = INST(ppg, i); struct pp_instance *ppi = INST(ppg, i);
if (def->slaveOnly && !ppi->slave_only) if (def->slaveOnly && ppi->role != PPSI_ROLE_SLAVE)
def->slaveOnly = 0; def->slaveOnly = 0;
ppi->state = PPS_INITIALIZING; ppi->state = PPS_INITIALIZING;
......
...@@ -26,7 +26,7 @@ void pp_servo_init(struct pp_instance *ppi) ...@@ -26,7 +26,7 @@ void pp_servo_init(struct pp_instance *ppi)
SRV(ppi)->obs_drift = -d << 10; /* note "-" */ SRV(ppi)->obs_drift = -d << 10; /* note "-" */
} else { } else {
/* level clock */ /* level clock */
if (!OPTS(ppi)->no_adjust) if (pp_can_adjust(ppi))
ppi->t_ops->adjust(ppi, 0, 0); ppi->t_ops->adjust(ppi, 0, 0);
SRV(ppi)->obs_drift = 0; SRV(ppi)->obs_drift = 0;
} }
...@@ -209,8 +209,8 @@ void pp_servo_got_resp(struct pp_instance *ppi) ...@@ -209,8 +209,8 @@ void pp_servo_got_resp(struct pp_instance *ppi)
TimeInternal time_tmp; TimeInternal time_tmp;
/* if secs, reset clock or set freq adjustment to max */ /* if secs, reset clock or set freq adjustment to max */
if (!OPTS(ppi)->no_adjust) { if (pp_can_adjust(ppi)) {
if (!OPTS(ppi)->no_rst_clk) { if (pp_can_reset_clock(ppi)) {
/* Can't use adjust, limited to +/- 2s */ /* Can't use adjust, limited to +/- 2s */
time_tmp = ppi->t4; time_tmp = ppi->t4;
add_TimeInternal(&time_tmp, &time_tmp, add_TimeInternal(&time_tmp, &time_tmp,
...@@ -278,7 +278,7 @@ void pp_servo_got_resp(struct pp_instance *ppi) ...@@ -278,7 +278,7 @@ void pp_servo_got_resp(struct pp_instance *ppi)
/* apply controller output as a clock tick rate adjustment, if /* apply controller output as a clock tick rate adjustment, if
* provided by arch, or as a raw offset otherwise */ * provided by arch, or as a raw offset otherwise */
if (!OPTS(ppi)->no_adjust) { if (pp_can_adjust(ppi)) {
if (ppi->t_ops->adjust_freq) if (ppi->t_ops->adjust_freq)
ppi->t_ops->adjust_freq(ppi, -adj); ppi->t_ops->adjust_freq(ppi, -adj);
else else
......
...@@ -68,7 +68,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -68,7 +68,7 @@ int pp_initializing(struct pp_instance *ppi, unsigned char *pkt, int plen)
msg_pack_header(ppi, ppi->tx_ptp); /* This is used for all tx */ msg_pack_header(ppi, ppi->tx_ptp); /* This is used for all tx */
if (!ppi->master_only) if (ppi->role != PPSI_ROLE_MASTER)
ppi->next_state = PPS_LISTENING; ppi->next_state = PPS_LISTENING;
else else
ppi->next_state = PPS_MASTER; ppi->next_state = PPS_MASTER;
......
...@@ -98,7 +98,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -98,7 +98,7 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
out: out:
if (e == 0) { if (e == 0) {
if (DSDEF(ppi)->clockQuality.clockClass == PP_CLASS_SLAVE_ONLY if (DSDEF(ppi)->clockQuality.clockClass == PP_CLASS_SLAVE_ONLY
|| ppi->slave_only) || (ppi->role == PPSI_ROLE_SLAVE))
ppi->next_state = PPS_LISTENING; ppi->next_state = PPS_LISTENING;
} else { } else {
ppi->next_state = PPS_FAULTY; ppi->next_state = PPS_FAULTY;
......
...@@ -24,7 +24,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -24,7 +24,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (e) if (e)
goto out; goto out;
ppi->waiting_for_follow = FALSE; ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP;
pp_timeout_restart_annrec(ppi); pp_timeout_restart_annrec(ppi);
...@@ -69,7 +69,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -69,7 +69,7 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
hdr->sequenceId) && hdr->sequenceId) &&
(DSPOR(ppi)->portIdentity.portNumber == (DSPOR(ppi)->portIdentity.portNumber ==
resp.requestingPortIdentity.portNumber) resp.requestingPortIdentity.portNumber)
&& ppi->is_from_cur_par) { && (ppi->flags & PPI_FLAG_FROM_CURRENT_PARENT)) {
to_TimeInternal(&ppi->t4, &resp.receiveTimestamp); to_TimeInternal(&ppi->t4, &resp.receiveTimestamp);
......
...@@ -63,7 +63,7 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname) ...@@ -63,7 +63,7 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
struct bare_packet_mreq pmr; struct bare_packet_mreq pmr;
char *context; char *context;
if (ppi->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
/* open socket */ /* open socket */
context = "socket()"; context = "socket()";
sock = sys_socket(PF_PACKET, SOCK_RAW, ETH_P_1588); sock = sys_socket(PF_PACKET, SOCK_RAW, ETH_P_1588);
...@@ -141,7 +141,7 @@ static int bare_net_init(struct pp_instance *ppi) ...@@ -141,7 +141,7 @@ static int bare_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->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
pp_diag(ppi, frames, 1, "bare_net_init IEEE 802.3\n"); pp_diag(ppi, frames, 1, "bare_net_init IEEE 802.3\n");
/* raw sockets implementation always use gen socket */ /* raw sockets implementation always use gen socket */
......
...@@ -19,7 +19,7 @@ static int bare_time_get(struct pp_instance *ppi, TimeInternal *t) ...@@ -19,7 +19,7 @@ static int bare_time_get(struct pp_instance *ppi, TimeInternal *t)
/* TAI = UTC + 35 */ /* TAI = UTC + 35 */
t->seconds = tv.tv_sec + DSPRO(ppi)->currentUtcOffset; t->seconds = tv.tv_sec + DSPRO(ppi)->currentUtcOffset;
t->nanoseconds = tv.tv_usec * 1000; t->nanoseconds = tv.tv_usec * 1000;
if (!(pp_global_flags & PP_FLAG_NOTIMELOG)) if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: %9li.%06li\n", __func__, pp_diag(ppi, time, 2, "%s: %9li.%06li\n", __func__,
tv.tv_sec, tv.tv_usec); tv.tv_sec, tv.tv_usec);
return 0; return 0;
......
...@@ -54,7 +54,7 @@ static int sim_time_get(struct pp_instance *ppi, TimeInternal *t) ...@@ -54,7 +54,7 @@ static int sim_time_get(struct pp_instance *ppi, TimeInternal *t)
(long long)PP_NSEC_PER_SEC; (long long)PP_NSEC_PER_SEC;
t->correct = 1; t->correct = 1;
if (!(pp_global_flags & PP_FLAG_NOTIMELOG)) if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: %9li.%09li\n", __func__, pp_diag(ppi, time, 2, "%s: %9li.%09li\n", __func__,
(long)t->seconds, (long)t->nanoseconds); (long)t->seconds, (long)t->nanoseconds);
return 0; return 0;
......
...@@ -106,7 +106,7 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len, ...@@ -106,7 +106,7 @@ static int unix_net_recv(struct pp_instance *ppi, void *pkt, int len,
struct pp_channel *ch1, *ch2; struct pp_channel *ch1, *ch2;
int ret; int ret;
if (ppi->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
int fd = NP(ppi)->ch[PP_NP_GEN].fd; int fd = NP(ppi)->ch[PP_NP_GEN].fd;
ret = unix_recv_msg(ppi, fd, pkt, len, t); ret = unix_recv_msg(ppi, fd, pkt, len, t);
...@@ -146,7 +146,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len, ...@@ -146,7 +146,7 @@ static int unix_net_send(struct pp_instance *ppi, void *pkt, int len,
return len; return len;
} }
if (ppi->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
hdr->h_proto = htons(ETH_P_1588); hdr->h_proto = htons(ETH_P_1588);
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN); memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
...@@ -193,7 +193,7 @@ static int unix_open_ch(struct pp_instance *ppi, char *ifname, int chtype) ...@@ -193,7 +193,7 @@ static int unix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
char addr_str[INET_ADDRSTRLEN]; char addr_str[INET_ADDRSTRLEN];
char *context; char *context;
if (ppi->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
/* open socket */ /* open socket */
context = "socket()"; context = "socket()";
sock = socket(PF_PACKET, SOCK_RAW, ETH_P_1588); sock = socket(PF_PACKET, SOCK_RAW, ETH_P_1588);
...@@ -359,7 +359,7 @@ static int unix_net_init(struct pp_instance *ppi) ...@@ -359,7 +359,7 @@ 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->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
pp_diag(ppi, frames, 1, "unix_net_init IEEE 802.3\n"); pp_diag(ppi, frames, 1, "unix_net_init IEEE 802.3\n");
/* raw sockets implementation always use gen socket */ /* raw sockets implementation always use gen socket */
...@@ -385,7 +385,7 @@ static int unix_net_exit(struct pp_instance *ppi) ...@@ -385,7 +385,7 @@ static int unix_net_exit(struct pp_instance *ppi)
int fd; int fd;
int i; int i;
if (ppi->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
fd = NP(ppi)->ch[PP_NP_GEN].fd; fd = NP(ppi)->ch[PP_NP_GEN].fd;
if (fd > 0) { if (fd > 0) {
close(fd); close(fd);
......
...@@ -32,7 +32,7 @@ static int unix_time_get(struct pp_instance *ppi, TimeInternal *t) ...@@ -32,7 +32,7 @@ static int unix_time_get(struct pp_instance *ppi, TimeInternal *t)
t->seconds = tp.tv_sec + DSPRO(ppi)->currentUtcOffset; t->seconds = tp.tv_sec + DSPRO(ppi)->currentUtcOffset;
t->nanoseconds = tp.tv_nsec; t->nanoseconds = tp.tv_nsec;
t->correct = 1; t->correct = 1;
if (!(pp_global_flags & PP_FLAG_NOTIMELOG)) if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: %9li.%09li\n", __func__, pp_diag(ppi, time, 2, "%s: %9li.%09li\n", __func__,
tp.tv_sec, tp.tv_nsec); tp.tv_sec, tp.tv_nsec);
return 0; return 0;
......
...@@ -18,7 +18,7 @@ static int wrpc_time_get(struct pp_instance *ppi, TimeInternal *t) ...@@ -18,7 +18,7 @@ static int wrpc_time_get(struct pp_instance *ppi, TimeInternal *t)
t->seconds = sec; t->seconds = sec;
t->nanoseconds = nsec; t->nanoseconds = nsec;
if (!(pp_global_flags & PP_FLAG_NOTIMELOG)) if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: %9lu.%09li\n", __func__, pp_diag(ppi, time, 2, "%s: %9lu.%09li\n", __func__,
(long)sec, (long)nsec); (long)sec, (long)nsec);
return 0; return 0;
......
...@@ -248,7 +248,7 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len, ...@@ -248,7 +248,7 @@ int wrs_net_recv(struct pp_instance *ppi, void *pkt, int len,
struct pp_channel *ch1, *ch2; struct pp_channel *ch1, *ch2;
int ret = -1; int ret = -1;
if (ppi->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
int fd = NP(ppi)->ch[PP_NP_GEN].fd; int fd = NP(ppi)->ch[PP_NP_GEN].fd;
ret = wrs_recv_msg(ppi, fd, pkt, len, t); ret = wrs_recv_msg(ppi, fd, pkt, len, t);
...@@ -317,7 +317,7 @@ static void poll_tx_timestamp(struct pp_instance *ppi, ...@@ -317,7 +317,7 @@ static void poll_tx_timestamp(struct pp_instance *ppi,
* a tx timestamp. Udp doesn't so don't check in udp mode * a tx timestamp. Udp doesn't so don't check in udp mode
* (the pointer is only checked for non-null) * (the pointer is only checked for non-null)
*/ */
if (!ppi->ethernet_mode) if (!(ppi->proto == PPSI_PROTO_RAW))
serr = (void *)1; serr = (void *)1;
for (cmsg = CMSG_FIRSTHDR(&msg); for (cmsg = CMSG_FIRSTHDR(&msg);
...@@ -361,7 +361,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len, ...@@ -361,7 +361,7 @@ int wrs_net_send(struct pp_instance *ppi, void *pkt, int len,
*/ */
drop = ppsi_drop_tx(); drop = ppsi_drop_tx();
if (ppi->ethernet_mode) { if (ppi->proto == PPSI_PROTO_RAW) {
fd = NP(ppi)->ch[PP_NP_GEN].fd; fd = NP(ppi)->ch[PP_NP_GEN].fd;
hdr->h_proto = htons(ETH_P_1588); hdr->h_proto = htons(ETH_P_1588);
if (drop) if (drop)
......
...@@ -176,7 +176,7 @@ static int wrs_time_get(struct pp_instance *ppi, TimeInternal *t) ...@@ -176,7 +176,7 @@ static int wrs_time_get(struct pp_instance *ppi, TimeInternal *t)
t->nanoseconds = p.current_nsec; t->nanoseconds = p.current_nsec;
t->correct = p.pps_valid; t->correct = p.pps_valid;
if (!(pp_global_flags & PP_FLAG_NOTIMELOG)) if (!(pp_global_d_flags & PP_FLAG_NOTIMELOG))
pp_diag(ppi, time, 2, "%s: (valid %x) %9li.%09li\n", __func__, pp_diag(ppi, time, 2, "%s: (valid %x) %9li.%09li\n", __func__,
p.pps_valid, p.pps_valid,
(long)p.current_sec, (long)p.current_nsec); (long)p.current_sec, (long)p.current_nsec);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment