Commit 3542ae48 authored by Alessandro Rubini's avatar Alessandro Rubini

Support E2E build without P2P. Saves 5kB in wrpc-sw

Here in ppsi,

  ./MAKEALL wrpc_defconfig wrpc_pdelay_defconfig

shows a very small difference, but most pdelay code is then
discarded by the wrpc-sw link time, due to --gc-sections.
This is the result:

   laptopo% ./MAKEALL spec_defconfig spec_pdelay_defconfig
   ##### Building with 'spec_defconfig'
   /opt/lm32-gcc-4.5.3/bin/lm32-elf-ar: creating libsdbfs.a
      text    data     bss     dec     hex filename
     87688    3492    6352   97532   17cfc wrc.elf
   ##### Building with 'spec_pdelay_defconfig'
   /opt/lm32-gcc-4.5.3/bin/lm32-elf-ar: creating libsdbfs.a
      text    data     bss     dec     hex filename
     93140    3492    6360  102992   19250 wrc.elf

What is missing now is the run-time choice between e2e and p2p. Later....
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 687d8432
...@@ -98,7 +98,7 @@ int main(int argc, char **argv) ...@@ -98,7 +98,7 @@ int main(int argc, char **argv)
ppg->max_links = 2; // master and slave, nothing else ppg->max_links = 2; // master and slave, nothing else
ppg->arch_data = calloc(1, sizeof(struct sim_ppg_arch_data)); ppg->arch_data = calloc(1, sizeof(struct sim_ppg_arch_data));
ppg->pp_instances = calloc(ppg->max_links, sizeof(struct pp_instance)); ppg->pp_instances = calloc(ppg->max_links, sizeof(struct pp_instance));
ppg->delay_mech = HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH; ppg->delay_mech = CONFIG_HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH;
if ((!ppg->arch_data) || (!ppg->pp_instances)) if ((!ppg->arch_data) || (!ppg->pp_instances))
return -1; return -1;
......
...@@ -51,7 +51,7 @@ int main(int argc, char **argv) ...@@ -51,7 +51,7 @@ int main(int argc, char **argv)
ppg->servo = &servo; ppg->servo = &servo;
ppg->rt_opts = &__pp_default_rt_opts; ppg->rt_opts = &__pp_default_rt_opts;
if (HAS_P2P) /* FIXME: turn this to a configuration opion */ if (CONFIG_HAS_P2P) /* FIXME: should be a run-time configuration */
ppg->delay_mech = PP_P2P_MECH; ppg->delay_mech = PP_P2P_MECH;
else else
ppg->delay_mech = PP_E2E_MECH; ppg->delay_mech = PP_E2E_MECH;
......
...@@ -94,7 +94,7 @@ static struct pp_globals ppg_static = { ...@@ -94,7 +94,7 @@ static struct pp_globals ppg_static = {
.parentDS = &parentDS, .parentDS = &parentDS,
.timePropertiesDS = &timePropertiesDS, .timePropertiesDS = &timePropertiesDS,
.global_ext_data = &servo_state, .global_ext_data = &servo_state,
.delay_mech = HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH, .delay_mech = CONFIG_HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH,
}; };
int wrc_ptp_init() int wrc_ptp_init()
......
...@@ -153,7 +153,7 @@ int main(int argc, char **argv) ...@@ -153,7 +153,7 @@ int main(int argc, char **argv)
ppg->servo = alloc_fn(ppsi_head, sizeof(*ppg->servo)); ppg->servo = alloc_fn(ppsi_head, sizeof(*ppg->servo));
ppg->rt_opts = &__pp_default_rt_opts; ppg->rt_opts = &__pp_default_rt_opts;
if (HAS_P2P) /* FIXME: turn this to a configuration opion */ if (CONFIG_HAS_P2P) /* FIXME: should be a run-time configuration */
ppg->delay_mech = PP_P2P_MECH; ppg->delay_mech = PP_P2P_MECH;
else else
ppg->delay_mech = PP_E2E_MECH; ppg->delay_mech = PP_E2E_MECH;
......
...@@ -43,8 +43,6 @@ struct pp_runtime_opts { ...@@ -43,8 +43,6 @@ struct pp_runtime_opts {
/* slave_only:1, -- moved to ppi, no more global */ /* slave_only:1, -- moved to ppi, no more global */
/* master_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 */ /* 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 */
......
...@@ -9,18 +9,6 @@ ...@@ -9,18 +9,6 @@
#define __PPSI_PPSI_H__ #define __PPSI_PPSI_H__
#include <generated/autoconf.h> #include <generated/autoconf.h>
#ifdef CONFIG_E2E
# define HAS_E2E 1
#else
# define HAS_E2E 0
#endif
#ifdef CONFIG_P2P
# define HAS_P2P 1
#else
# define HAS_P2P 0
#endif
#include <stdint.h> #include <stdint.h>
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
...@@ -373,8 +361,6 @@ extern void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp * presp); ...@@ -373,8 +361,6 @@ extern void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp * presp);
extern void msg_pack_pdelay_resp(struct pp_instance *ppi, extern void msg_pack_pdelay_resp(struct pp_instance *ppi,
MsgHeader * hdr, Timestamp * rcv_tstamp); MsgHeader * hdr, Timestamp * rcv_tstamp);
extern void msg_unpack_pdelay_req(void *buf, MsgPDelayReq * pdelay_req); extern void msg_unpack_pdelay_req(void *buf, MsgPDelayReq * pdelay_req);
extern void msg_pack_pdelay_req(struct pp_instance *ppi,
Timestamp * orig_tstamp);
/* each of them returns 0 if ok, -1 in case of error in send, 1 if stamp err */ /* each of them returns 0 if ok, -1 in case of error in send, 1 if stamp err */
#define PP_SEND_OK 0 #define PP_SEND_OK 0
......
...@@ -50,7 +50,7 @@ static struct pp_instance ppi_static = { ...@@ -50,7 +50,7 @@ static struct pp_instance ppi_static = {
/* We now have a structure with all globals, and multiple ppi inside */ /* We now have a structure with all globals, and multiple ppi inside */
static struct pp_globals ppg_static = { static struct pp_globals ppg_static = {
.pp_instances = &ppi_static, .pp_instances = &ppi_static,
.delay_mech = HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH, .delay_mech = CONFIG_HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH,
.nlinks = 1, .nlinks = 1,
.servo = &servo, .servo = &servo,
.defaultDS = &defaultDS, .defaultDS = &defaultDS,
......
...@@ -32,8 +32,6 @@ static struct cmd_line_opt cmd_line_list[] = { ...@@ -32,8 +32,6 @@ static struct cmd_line_opt cmd_line_list[] = {
{"-w NUMBER", "specify meanPathDelay filter stiffness"}, {"-w NUMBER", "specify meanPathDelay filter stiffness"},
CMD_LINE_SEPARATOR, CMD_LINE_SEPARATOR,
//{"-u ADDRESS", "also send uni-cast to ADDRESS\n"}, -- FIXME: useful? //{"-u ADDRESS", "also send uni-cast to ADDRESS\n"}, -- FIXME: useful?
/* {"-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 as slave only"}, {"-g", "run as slave only"},
CMD_LINE_SEPARATOR, CMD_LINE_SEPARATOR,
{NULL, NULL} {NULL, NULL}
......
...@@ -100,8 +100,9 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen, ...@@ -100,8 +100,9 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
break; break;
case PPM_PDELAY_REQ: case PPM_PDELAY_REQ:
wr_handle_preq(ppi); if (CONFIG_HAS_P2P)
msgtype = PPM_PDELAY_REQ; /* normal management continues */ wr_handle_preq(ppi);
/* normal management continues */
break; break;
/* This is missing in the standard protocol */ /* This is missing in the standard protocol */
...@@ -214,13 +215,13 @@ static int wr_handle_followup(struct pp_instance *ppi, ...@@ -214,13 +215,13 @@ static int wr_handle_followup(struct pp_instance *ppi,
wr_servo_got_sync(ppi, precise_orig_timestamp, wr_servo_got_sync(ppi, precise_orig_timestamp,
&ppi->t2); &ppi->t2);
if (GLBS(ppi)->delay_mech == PP_P2P_MECH) if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
wr_servo_update(ppi); wr_servo_update(ppi);
return 1; /* the caller returns too */ return 1; /* the caller returns too */
} }
static int wr_handle_presp(struct pp_instance *ppi) static __attribute__((used)) int wr_handle_presp(struct pp_instance *ppi)
{ {
MsgHeader *hdr = &ppi->received_ptp_header; MsgHeader *hdr = &ppi->received_ptp_header;
TimeInternal correction_field; TimeInternal correction_field;
...@@ -291,8 +292,10 @@ struct pp_ext_hooks pp_hooks = { ...@@ -291,8 +292,10 @@ struct pp_ext_hooks pp_hooks = {
.execute_slave = wr_execute_slave, .execute_slave = wr_execute_slave,
.handle_announce = wr_handle_announce, .handle_announce = wr_handle_announce,
.handle_followup = wr_handle_followup, .handle_followup = wr_handle_followup,
#if CONFIG_HAS_P2P
.handle_preq = wr_handle_preq, .handle_preq = wr_handle_preq,
.handle_presp = wr_handle_presp, .handle_presp = wr_handle_presp,
#endif
.pack_announce = wr_pack_announce, .pack_announce = wr_pack_announce,
.unpack_announce = wr_unpack_announce, .unpack_announce = wr_unpack_announce,
}; };
...@@ -247,7 +247,7 @@ int wr_servo_got_delay(struct pp_instance *ppi, Integer32 cf) ...@@ -247,7 +247,7 @@ int wr_servo_got_delay(struct pp_instance *ppi, Integer32 cf)
s->t4.correct = 1; /* clock->delay_req_receive_time.correct; */ s->t4.correct = 1; /* clock->delay_req_receive_time.correct; */
s->t4.phase = (int64_t) cf * 1000LL / 65536LL; s->t4.phase = (int64_t) cf * 1000LL / 65536LL;
if (GLBS(ppi)->delay_mech == PP_P2P_MECH) { if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH) {
s->t5 = ppi->t5; s->t5 = ppi->t5;
s->t5.correct = 1; s->t5.correct = 1;
s->t5.phase = 0; s->t5.phase = 0;
...@@ -416,7 +416,7 @@ int wr_servo_update(struct pp_instance *ppi) ...@@ -416,7 +416,7 @@ int wr_servo_update(struct pp_instance *ppi)
wrs_shm_write(ppsi_head, WRS_SHM_WRITE_BEGIN); wrs_shm_write(ppsi_head, WRS_SHM_WRITE_BEGIN);
picos_mu_prev = s->picos_mu; picos_mu_prev = s->picos_mu;
if (GLBS(ppi)->delay_mech == PP_P2P_MECH) { if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH) {
if (!wr_p2p_offset(ppi, s, &ts_offset_hw)) if (!wr_p2p_offset(ppi, s, &ts_offset_hw))
goto out; goto out;
} else { } else {
......
...@@ -186,7 +186,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf, ...@@ -186,7 +186,7 @@ int st_com_slave_handle_sync(struct pp_instance *ppi, unsigned char *buf,
ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP; ppi->flags &= ~PPI_FLAG_WAITING_FOR_F_UP;
to_TimeInternal(&ppi->t1, to_TimeInternal(&ppi->t1,
&sync.originTimestamp); &sync.originTimestamp);
if (GLBS(ppi)->delay_mech) if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
pp_servo_got_psync(ppi); pp_servo_got_psync(ppi);
else else
pp_servo_got_sync(ppi); pp_servo_got_sync(ppi);
...@@ -355,7 +355,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf, ...@@ -355,7 +355,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
if (ret < 0) if (ret < 0)
return ret; return ret;
if (GLBS(ppi)->delay_mech) if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
pp_servo_got_psync(ppi); pp_servo_got_psync(ppi);
else else
pp_servo_got_sync(ppi); pp_servo_got_sync(ppi);
......
...@@ -341,7 +341,8 @@ static void msg_pack_delay_req(struct pp_instance *ppi, Timestamp *orig_tstamp) ...@@ -341,7 +341,8 @@ static void msg_pack_delay_req(struct pp_instance *ppi, Timestamp *orig_tstamp)
} }
/* pack DelayReq message into out buffer of ppi */ /* pack DelayReq message into out buffer of ppi */
void msg_pack_pdelay_req(struct pp_instance *ppi, Timestamp * orig_tstamp) static void msg_pack_pdelay_req(struct pp_instance *ppi,
Timestamp * orig_tstamp)
{ {
void *buf; void *buf;
UInteger8 *flags; UInteger8 *flags;
...@@ -601,9 +602,9 @@ static int msg_issue_pdelay_req(struct pp_instance *ppi) ...@@ -601,9 +602,9 @@ static int msg_issue_pdelay_req(struct pp_instance *ppi)
int msg_issue_request(struct pp_instance *ppi) int msg_issue_request(struct pp_instance *ppi)
{ {
if (ppi->glbs->delay_mech == PP_E2E_MECH) if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
return msg_issue_delay_req(ppi); return msg_issue_pdelay_req(ppi);
return msg_issue_pdelay_req(ppi); return msg_issue_delay_req(ppi);
} }
/* Pack and send on event multicast ip adress a DelayResp message */ /* Pack and send on event multicast ip adress a DelayResp message */
......
...@@ -19,7 +19,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -19,7 +19,7 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
goto out; goto out;
/* when the clock is using peer-delay, listening must send it too */ /* when the clock is using peer-delay, listening must send it too */
if (ppi->glbs->delay_mech == PP_P2P_MECH) if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
e = pp_lib_may_issue_request(ppi); e = pp_lib_may_issue_request(ppi);
if (plen == 0) if (plen == 0)
...@@ -36,15 +36,18 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -36,15 +36,18 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
break; break;
case PPM_PDELAY_REQ: case PPM_PDELAY_REQ:
st_com_peer_handle_preq(ppi, pkt, plen); if (CONFIG_HAS_P2P)
st_com_peer_handle_preq(ppi, pkt, plen);
break; break;
case PPM_PDELAY_RESP: case PPM_PDELAY_RESP:
e = st_com_peer_handle_pres(ppi, pkt, plen); if (CONFIG_HAS_P2P)
e = st_com_peer_handle_pres(ppi, pkt, plen);
break; break;
case PPM_PDELAY_R_FUP: case PPM_PDELAY_R_FUP:
e = st_com_peer_handle_pres_followup(ppi, pkt, plen); if (CONFIG_HAS_P2P)
e = st_com_peer_handle_pres_followup(ppi, pkt, plen);
break; break;
default: default:
......
...@@ -33,8 +33,8 @@ static int _pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen, int pre) ...@@ -33,8 +33,8 @@ static int _pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen, int pre)
pp_lib_may_issue_announce(ppi); pp_lib_may_issue_announce(ppi);
} }
/* when the clock is using peer-delay, the muster mast send it too */ /* when the clock is using peer-delay, the master must send it too */
if (ppi->glbs->delay_mech == PP_P2P_MECH) if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
pp_lib_may_issue_request(ppi); pp_lib_may_issue_request(ppi);
else { else {
if (!pre) if (!pre)
...@@ -76,15 +76,18 @@ static int _pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen, int pre) ...@@ -76,15 +76,18 @@ static int _pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen, int pre)
break; break;
case PPM_PDELAY_REQ: case PPM_PDELAY_REQ:
st_com_peer_handle_preq(ppi, pkt, plen); if (CONFIG_HAS_P2P)
st_com_peer_handle_preq(ppi, pkt, plen);
break; break;
case PPM_PDELAY_RESP: case PPM_PDELAY_RESP:
e = st_com_peer_handle_pres(ppi, pkt, plen); if (CONFIG_HAS_P2P)
e = st_com_peer_handle_pres(ppi, pkt, plen);
break; break;
case PPM_PDELAY_R_FUP: case PPM_PDELAY_R_FUP:
e = st_com_peer_handle_pres_followup(ppi, pkt, plen); if (CONFIG_HAS_P2P)
e = st_com_peer_handle_pres_followup(ppi, pkt, plen);
break; break;
default: default:
......
...@@ -14,7 +14,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -14,7 +14,7 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
int e = 0; /* error var, to check errors in msg handling */ int e = 0; /* error var, to check errors in msg handling */
/* when the clock is using peer-delay, listening must send it too */ /* when the clock is using peer-delay, listening must send it too */
if (ppi->glbs->delay_mech == PP_P2P_MECH) if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
e = pp_lib_may_issue_request(ppi); e = pp_lib_may_issue_request(ppi);
if (plen == 0) if (plen == 0)
...@@ -31,15 +31,18 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen) ...@@ -31,15 +31,18 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
break; break;
case PPM_PDELAY_REQ: case PPM_PDELAY_REQ:
st_com_peer_handle_preq(ppi, pkt, plen); if (CONFIG_HAS_P2P)
st_com_peer_handle_preq(ppi, pkt, plen);
break; break;
case PPM_PDELAY_RESP: case PPM_PDELAY_RESP:
e = st_com_peer_handle_pres(ppi, pkt, plen); if (CONFIG_HAS_P2P)
e = st_com_peer_handle_pres(ppi, pkt, plen);
break; break;
case PPM_PDELAY_R_FUP: case PPM_PDELAY_R_FUP:
e = st_com_peer_handle_pres_followup(ppi, pkt, plen); if (CONFIG_HAS_P2P)
e = st_com_peer_handle_pres_followup(ppi, pkt, plen);
break; break;
default: default:
......
...@@ -17,11 +17,13 @@ static int slave_handle_response(struct pp_instance *ppi, unsigned char *pkt, ...@@ -17,11 +17,13 @@ static int slave_handle_response(struct pp_instance *ppi, unsigned char *pkt,
static pp_action *actions[] = { static pp_action *actions[] = {
[PPM_SYNC] = st_com_slave_handle_sync, [PPM_SYNC] = st_com_slave_handle_sync,
[PPM_DELAY_REQ] = 0, [PPM_DELAY_REQ] = 0,
#if CONFIG_HAS_P2P
[PPM_PDELAY_REQ] = st_com_peer_handle_preq, [PPM_PDELAY_REQ] = st_com_peer_handle_preq,
[PPM_PDELAY_RESP] = st_com_peer_handle_pres, [PPM_PDELAY_RESP] = st_com_peer_handle_pres,
[PPM_PDELAY_R_FUP] = st_com_peer_handle_pres_followup,
#endif
[PPM_FOLLOW_UP] = st_com_slave_handle_followup, [PPM_FOLLOW_UP] = st_com_slave_handle_followup,
[PPM_DELAY_RESP] = slave_handle_response, [PPM_DELAY_RESP] = slave_handle_response,
[PPM_PDELAY_R_FUP] = st_com_peer_handle_pres_followup,
[PPM_ANNOUNCE] = st_com_slave_handle_announce, [PPM_ANNOUNCE] = st_com_slave_handle_announce,
/* skip signaling and management, for binary size */ /* skip signaling and management, for binary size */
}; };
......
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