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)
ppg->max_links = 2; // master and slave, nothing else
ppg->arch_data = calloc(1, sizeof(struct sim_ppg_arch_data));
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))
return -1;
......
......@@ -51,7 +51,7 @@ int main(int argc, char **argv)
ppg->servo = &servo;
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;
else
ppg->delay_mech = PP_E2E_MECH;
......
......@@ -94,7 +94,7 @@ static struct pp_globals ppg_static = {
.parentDS = &parentDS,
.timePropertiesDS = &timePropertiesDS,
.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()
......
......@@ -153,7 +153,7 @@ int main(int argc, char **argv)
ppg->servo = alloc_fn(ppsi_head, sizeof(*ppg->servo));
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;
else
ppg->delay_mech = PP_E2E_MECH;
......
......@@ -43,8 +43,6 @@ struct pp_runtime_opts {
/* 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 */
......
......@@ -9,18 +9,6 @@
#define __PPSI_PPSI_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 <stdarg.h>
#include <stddef.h>
......@@ -373,8 +361,6 @@ extern void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp * presp);
extern void msg_pack_pdelay_resp(struct pp_instance *ppi,
MsgHeader * hdr, Timestamp * rcv_tstamp);
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 */
#define PP_SEND_OK 0
......
......@@ -50,7 +50,7 @@ static struct pp_instance ppi_static = {
/* We now have a structure with all globals, and multiple ppi inside */
static struct pp_globals ppg_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,
.servo = &servo,
.defaultDS = &defaultDS,
......
......@@ -32,8 +32,6 @@ static struct cmd_line_opt cmd_line_list[] = {
{"-w NUMBER", "specify meanPathDelay filter stiffness"},
CMD_LINE_SEPARATOR,
//{"-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"},
CMD_LINE_SEPARATOR,
{NULL, NULL}
......
......@@ -100,8 +100,9 @@ static int wr_master_msg(struct pp_instance *ppi, unsigned char *pkt, int plen,
break;
case PPM_PDELAY_REQ:
wr_handle_preq(ppi);
msgtype = PPM_PDELAY_REQ; /* normal management continues */
if (CONFIG_HAS_P2P)
wr_handle_preq(ppi);
/* normal management continues */
break;
/* This is missing in the standard protocol */
......@@ -214,13 +215,13 @@ static int wr_handle_followup(struct pp_instance *ppi,
wr_servo_got_sync(ppi, precise_orig_timestamp,
&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);
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;
TimeInternal correction_field;
......@@ -291,8 +292,10 @@ struct pp_ext_hooks pp_hooks = {
.execute_slave = wr_execute_slave,
.handle_announce = wr_handle_announce,
.handle_followup = wr_handle_followup,
#if CONFIG_HAS_P2P
.handle_preq = wr_handle_preq,
.handle_presp = wr_handle_presp,
#endif
.pack_announce = wr_pack_announce,
.unpack_announce = wr_unpack_announce,
};
......@@ -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.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.correct = 1;
s->t5.phase = 0;
......@@ -416,7 +416,7 @@ int wr_servo_update(struct pp_instance *ppi)
wrs_shm_write(ppsi_head, WRS_SHM_WRITE_BEGIN);
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))
goto out;
} else {
......
......@@ -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;
to_TimeInternal(&ppi->t1,
&sync.originTimestamp);
if (GLBS(ppi)->delay_mech)
if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
pp_servo_got_psync(ppi);
else
pp_servo_got_sync(ppi);
......@@ -355,7 +355,7 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
if (ret < 0)
return ret;
if (GLBS(ppi)->delay_mech)
if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
pp_servo_got_psync(ppi);
else
pp_servo_got_sync(ppi);
......
......@@ -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 */
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;
UInteger8 *flags;
......@@ -601,9 +602,9 @@ static int msg_issue_pdelay_req(struct pp_instance *ppi)
int msg_issue_request(struct pp_instance *ppi)
{
if (ppi->glbs->delay_mech == PP_E2E_MECH)
return msg_issue_delay_req(ppi);
return msg_issue_pdelay_req(ppi);
if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
return msg_issue_pdelay_req(ppi);
return msg_issue_delay_req(ppi);
}
/* 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)
goto out;
/* 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);
if (plen == 0)
......@@ -36,15 +36,18 @@ int pp_listening(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
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;
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;
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;
default:
......
......@@ -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);
}
/* when the clock is using peer-delay, the muster mast send it too */
if (ppi->glbs->delay_mech == PP_P2P_MECH)
/* when the clock is using peer-delay, the master must send it too */
if (CONFIG_HAS_P2P && ppi->glbs->delay_mech == PP_P2P_MECH)
pp_lib_may_issue_request(ppi);
else {
if (!pre)
......@@ -76,15 +76,18 @@ static int _pp_master(struct pp_instance *ppi, uint8_t *pkt, int plen, int pre)
break;
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;
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;
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;
default:
......
......@@ -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 */
/* 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);
if (plen == 0)
......@@ -31,15 +31,18 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
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;
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;
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;
default:
......
......@@ -17,11 +17,13 @@ static int slave_handle_response(struct pp_instance *ppi, unsigned char *pkt,
static pp_action *actions[] = {
[PPM_SYNC] = st_com_slave_handle_sync,
[PPM_DELAY_REQ] = 0,
#if CONFIG_HAS_P2P
[PPM_PDELAY_REQ] = st_com_peer_handle_preq,
[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_DELAY_RESP] = slave_handle_response,
[PPM_PDELAY_R_FUP] = st_com_peer_handle_pres_followup,
[PPM_ANNOUNCE] = st_com_slave_handle_announce,
/* 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