Commit e90716f7 authored by Alessandro Rubini's avatar Alessandro Rubini

massive: remove pdelay material.

pdelay (peer delay) is a configuration option for a PTP domain. IT is
a huge mass of code, which we never actually used and is most likely
buggy.

This commits remove all related code, and configures our PTP engine as
end-to-end.  I doubt this commit can be reverted in the future, but at
least it leaves traces about what was there and is not there any more.

Something about pdelay is still there: the message names, one field in
a structure and one configuration variable, to ease recovery in the
future.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9c406c41
......@@ -28,10 +28,7 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
hdr = PROTO_HDR(pkt);
hdr->h_proto = htons(ETH_P_1588);
if (OPTS(ppi)->gptp_mode)
memcpy(hdr->h_dest, PP_PEER_MACADDRESS, 6);
else
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, 6);
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, 6);
/* raw socket implementation always uses gen socket */
memcpy(hdr->h_source, NP(ppi)->ch[PP_NP_GEN].addr, 6);
......@@ -114,11 +111,6 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
sys_setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
/* also the PEER multicast address */
memcpy(pmr.mr_address, PP_PEER_MACADDRESS, ETH_ALEN);
sys_setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
NP(ppi)->ch[PP_NP_GEN].fd = sock;
NP(ppi)->ch[PP_NP_EVT].fd = sock;
......
......@@ -28,10 +28,7 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
hdr = PROTO_HDR(pkt);
hdr->h_proto = htons(ETH_P_1588);
if (OPTS(ppi)->gptp_mode)
memcpy(hdr->h_dest, PP_PEER_MACADDRESS, 6);
else
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, 6);
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, 6);
/* raw socket implementation always uses gen socket */
memcpy(hdr->h_source, NP(ppi)->ch[PP_NP_GEN].addr, 6);
......@@ -114,11 +111,6 @@ static int bare_open_ch(struct pp_instance *ppi, char *ifname)
sys_setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
/* also the PEER multicast address */
memcpy(pmr.mr_address, PP_PEER_MACADDRESS, ETH_ALEN);
sys_setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
NP(ppi)->ch[PP_NP_GEN].fd = sock;
NP(ppi)->ch[PP_NP_EVT].fd = sock;
......
......@@ -136,10 +136,7 @@ static int posix_net_send(struct pp_instance *ppi, void *pkt, int len,
hdr->h_proto = htons(ETH_P_1588);
if (OPTS(ppi)->gptp_mode)
memcpy(hdr->h_dest, PP_PEER_MACADDRESS, ETH_ALEN);
else
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, ETH_ALEN);
/* raw socket implementation always uses gen socket */
memcpy(hdr->h_source, NP(ppi)->ch[PP_NP_GEN].addr, ETH_ALEN);
return send(NP(ppi)->ch[PP_NP_GEN].fd, hdr,
......@@ -150,10 +147,7 @@ static int posix_net_send(struct pp_instance *ppi, void *pkt, int len,
addr.sin_family = AF_INET;
addr.sin_port = htons(chtype == PP_NP_GEN ? PP_GEN_PORT : PP_EVT_PORT);
if (!use_pdelay_addr)
addr.sin_addr.s_addr = NP(ppi)->mcast_addr;
else
addr.sin_addr.s_addr = NP(ppi)->peer_mcast_addr;
addr.sin_addr.s_addr = NP(ppi)->mcast_addr;
if (t)
pp_t_ops.get(t);
......@@ -227,11 +221,6 @@ static int posix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
/* also the PEER multicast address */
memcpy(pmr.mr_address, PP_PEER_MACADDRESS, ETH_ALEN);
setsockopt(sock, SOL_PACKET, PACKET_ADD_MEMBERSHIP,
&pmr, sizeof(pmr)); /* lazily ignore errors */
NP(ppi)->ch[chtype].fd = sock;
/* make timestamps available through recvmsg() -- FIXME: hw? */
......@@ -324,15 +313,6 @@ static int posix_open_ch(struct pp_instance *ppi, char *ifname, int chtype)
}
/* End of General multicast Ip address init */
/* Init Peer multicast IP address */
memcpy(addr_str, PP_PEER_DOMAIN_ADDRESS, INET_ADDRSTRLEN);
if (!inet_aton(addr_str, &net_addr)) {
pp_diag_error_str2(ppi, "inet_aton()", strerror(errno));
return -1;
}
NP(ppi)->peer_mcast_addr = net_addr.s_addr;
/* multicast sends only on specified interface */
imr.imr_multiaddr.s_addr = net_addr.s_addr;
imr.imr_interface.s_addr = iface_addr.s_addr;
......@@ -431,13 +411,6 @@ static int posix_net_exit(struct pp_instance *ppi)
setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
&imr, sizeof(struct ip_mreq));
/* Close Peer Multicast */
imr.imr_multiaddr.s_addr = NP(ppi)->peer_mcast_addr;
imr.imr_interface.s_addr = htonl(INADDR_ANY);
setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
&imr, sizeof(struct ip_mreq));
close(fd);
NP(ppi)->ch[i].fd = -1;
......
......@@ -44,11 +44,10 @@
#define PP_DEFAULT_MAX_RESET 0
#define PP_DEFAULT_MAX_DELAY 0
#define PP_DEFAULT_NO_ADJUST 0
#define PP_DEFAULT_E2E_MODE 0
#define PP_DEFAULT_TTL 1
/* We use an array of timers, with these indexes */
#define PP_TIMER_PDELAYREQ 0
#define PP_TIMER_UNUSED 0
#define PP_TIMER_DELAYREQ 1
#define PP_TIMER_SYNC 2
#define PP_TIMER_ANN_RECEIPT 3
......@@ -91,7 +90,7 @@
#define PP_EVT_PORT 319
#define PP_GEN_PORT 320
#define PP_DEFAULT_DOMAIN_ADDRESS "224.0.1.129"
#define PP_PEER_DOMAIN_ADDRESS "224.0.0.107"
#define PP_PDELAY_DOMAIN_ADDRESS "224.0.0.107"
#define PP_MM_STARTING_BOUNDARY_HOPS 0x7fff
/* Raw ethernet dependent */
......@@ -100,7 +99,7 @@
#endif
#define PP_MCAST_MACADDRESS "\x01\x1B\x19\x00\x00\x00"
#define PP_PEER_MACADDRESS "\x01\x80\xC2\x00\x00\x0E"
#define PP_PDELAY_MACADDRESS "\x01\x80\xC2\x00\x00\x0E"
#include <arch/constants.h> /* architectures may override the defaults */
......
......@@ -176,20 +176,20 @@ typedef struct MsgDelayResp {
PortIdentity requestingPortIdentity;
} MsgDelayResp;
/* PdelayReq Message (table 29, page 131) */
typedef struct MsgPDelayReq {
/* PdelayReq Message (table 29, page 131) -- not used in ppsi */
struct MsgPDelayReq {
Timestamp originTimestamp;
} MsgPDelayReq;
/* PdelayResp Message (table 30, page 131) */
typedef struct MsgPDelayResp {
/* PdelayResp Message (table 30, page 131) -- not used in ppsi */
struct MsgPDelayResp {
Timestamp requestReceiptTimestamp;
PortIdentity requestingPortIdentity;
} MsgPDelayResp;
/* PdelayRespFollowUp Message (table 31, page 132) */
typedef struct MsgPDelayRespFollowUp {
/* PdelayRespFollowUp Message (table 31, page 132) -- not used in ppsi */
struct MsgPDelayRespFollowUp {
Timestamp responseOriginTimestamp;
PortIdentity requestingPortIdentity;
} MsgPDelayRespFollowUp;
......
......@@ -29,8 +29,8 @@ struct pp_runtime_opts {
display_stats:1,
csv_stats:1,
ethernet_mode:1,
e2e_mode:1,
gptp_mode:1,
/* e2e_mode:1, -- no more: we only support e2e */
/* gptp_mode:1, -- no more: peer-to-peer unsupported */
ofst_first_updated:1,
no_rst_clk:1,
use_syslog:1;
......@@ -120,8 +120,6 @@ struct pp_servo {
TimeInternal s_to_m_dly;
TimeInternal delay_ms;
TimeInternal delay_sm;
TimeInternal pdelay_ms;
TimeInternal pdelay_sm;
Integer32 obs_drift;
struct pp_owd_fltr owd_fltr;
struct pp_ofm_fltr ofm_fltr;
......@@ -181,12 +179,6 @@ struct pp_instance {
TimeInternal last_snt_time; /* used to store timestamp retreived from
* sent packet */
TimeInternal last_sync_corr_field;
TimeInternal last_pdelay_req_corr_field;
TimeInternal last_pdelay_resp_corr_field;
TimeInternal pdelay_req_send_time;
TimeInternal pdelay_req_receive_time;
TimeInternal pdelay_resp_send_time;
TimeInternal pdelay_resp_receive_time;
TimeInternal delay_req_send_time;
TimeInternal delay_req_receive_time;
Integer8 log_min_delay_req_interval;
......@@ -195,15 +187,12 @@ struct pp_instance {
MsgSync sync;
MsgFollowUp follow;
MsgDelayResp resp;
MsgPDelayResp presp;
MsgPDelayRespFollowUp prespfollow;
MsgAnnounce announce;
} msg_tmp;
UInteger16 *sent_seq_id; /* sequence id of the last message sent of the
* same type
*/
MsgHeader msg_tmp_header;
MsgHeader pdelay_req_hdr;
MsgHeader delay_req_hdr;
UInteger32
is_from_self:1,
......@@ -291,7 +280,7 @@ struct pp_network_operations {
int (*exit)(struct pp_instance *ppi);
int (*recv)(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t);
/* chtype here is PP_NP_GEN or PP_NP_EVT */
/* chtype here is PP_NP_GEN or PP_NP_EVT -- use_pdelay must be 0 */
int (*send)(struct pp_instance *ppi, void *pkt, int len,
TimeInternal *t, int chtype, int use_pdelay_addr);
};
......@@ -366,35 +355,19 @@ extern void msg_unpack_announce(void *buf, MsgAnnounce *ann);
extern void msg_pack_follow_up(struct pp_instance *ppi,
Timestamp *prec_orig_tstamp);
extern void msg_unpack_follow_up(void *buf, MsgFollowUp *flwup);
extern void msg_pack_pdelay_req(struct pp_instance *ppi,
Timestamp *orig_tstamp);
extern void msg_unpack_pdelay_req(void *buf, MsgPDelayReq *pdelay_req);
extern void msg_pack_delay_req(struct pp_instance *ppi,
Timestamp *orig_tstamp);
extern void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req);
extern void msg_pack_delay_resp(struct pp_instance *ppi,
MsgHeader *hdr, Timestamp *rcv_tstamp);
extern void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp);
extern void msg_pack_pdelay_resp(struct pp_instance *ppi,
MsgHeader *hdr, Timestamp *req_rec_tstamp);
extern void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp *presp);
extern void msg_pack_pdelay_resp_followup(struct pp_instance *ppi,
MsgHeader *hdr,
Timestamp *resp_orig_tstamp);
extern void msg_unpack_pdelay_resp_followup(void *buf,
MsgPDelayRespFollowUp *presp_follow);
/* each of them returns 0 if no error and -1 in case of error in send */
extern int msg_issue_announce(struct pp_instance *ppi);
extern int msg_issue_sync(struct pp_instance *ppi);
extern int msg_issue_followup(struct pp_instance *ppi, TimeInternal *time);
extern int msg_issue_delay_req(struct pp_instance *ppi);
extern int msg_issue_pdelay_req(struct pp_instance *ppi);
extern int msg_issue_pdelay_resp(struct pp_instance *ppi, TimeInternal *time,
MsgHeader *hdr);
extern int msg_issue_delay_resp(struct pp_instance *ppi, TimeInternal *time);
extern int msg_issue_pdelay_resp_follow_up(struct pp_instance *ppi,
TimeInternal *time);
/* Functions for timestamp handling (internal to protocol format conversion*/
......
......@@ -34,8 +34,8 @@ static struct cmd_line_opt cmd_line_list[] = {
{"-b NAME", "bind PTP to network interface NAME"},
//{"-u ADDRESS", "also send uni-cast to ADDRESS\n"}, -- FIXME: useful?
{"-e", "run in ethernet mode (level2)"},
{"-h", "run in End to End mode"},
{"-G", "run in gPTP mode (implies -e)"},
/* {"-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 */
{"-l NUMBER,NUMBER", "specify inbound, outbound latency in nsec"},
CMD_LINE_SEPARATOR,
{"-o NUMBER", "specify current UTC offset"},
......@@ -201,15 +201,13 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
OPTS(ppi)->prio2 = atoi(a);
break;
case 'h':
OPTS(ppi)->e2e_mode = 1;
break;
case 'G':
OPTS(ppi)->gptp_mode = 1;
OPTS(ppi)->e2e_mode = 1;
/* ignored: was "OPTS(ppi)->e2e_mode = 1;" */
break;
case 'e':
OPTS(ppi)->ethernet_mode = 1;
break;
case 'G':
/* gptp_mode not supported: fall through */
default:
cmd_line_print_help();
return -1;
......
......@@ -35,26 +35,17 @@ int st_com_execute_slave(struct pp_instance *ppi, int check_delayreq)
if (!check_delayreq)
return 0;
if (OPTS(ppi)->e2e_mode) {
if (pp_timer_expired(ppi->timers[PP_TIMER_DELAYREQ])) {
PP_VPRINTF("event DELAYREQ_INTERVAL_TIMEOUT_EXPIRES\n");
if (pp_timer_expired(ppi->timers[PP_TIMER_DELAYREQ])) {
PP_VPRINTF("event DELAYREQ_INTERVAL_TIMEOUT_EXPIRES\n");
ret = msg_issue_delay_req(ppi);
ret = msg_issue_delay_req(ppi);
ppi->delay_req_send_time = ppi->last_snt_time;
ppi->delay_req_send_time = ppi->last_snt_time;
/* Add latency */
add_TimeInternal(&ppi->delay_req_send_time,
&ppi->delay_req_send_time,
&OPTS(ppi)->outbound_latency);
}
} else {
if (pp_timer_expired(ppi->timers[PP_TIMER_PDELAYREQ])) {
PP_VPRINTF("event PDELAYREQ_INTERVAL_TOUT_EXPIRES\n");
ret = msg_issue_pdelay_req(ppi);
}
/* Add latency */
add_TimeInternal(&ppi->delay_req_send_time,
&ppi->delay_req_send_time,
&OPTS(ppi)->outbound_latency);
}
return ret;
}
......@@ -301,41 +292,6 @@ int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
return 0;
}
int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
int len)
{
TimeInternal *time;
MsgHeader *hdr = &ppi->msg_tmp_header;
if (len < PP_PDELAY_REQ_LENGTH)
return -1;
if (OPTS(ppi)->e2e_mode)
return 0;
time = &ppi->last_rcv_time;
if (ppi->is_from_self) {
/* Get sending timestamp from IP stack
* with So_TIMESTAMP */
ppi->pdelay_req_send_time.seconds =
time->seconds;
ppi->pdelay_req_send_time.nanoseconds =
time->nanoseconds;
/*Add latency*/
add_TimeInternal(&ppi->pdelay_req_send_time,
&ppi->pdelay_req_send_time,
&OPTS(ppi)->outbound_latency);
} else {
msg_copy_header(&ppi->pdelay_req_hdr, hdr);
return msg_issue_pdelay_resp(ppi, time, hdr);
}
return 0;
}
int st_com_master_handle_announce(struct pp_instance *ppi, unsigned char *buf,
int len)
{
......
......@@ -36,9 +36,6 @@ int st_com_master_handle_sync(struct pp_instance *ppi, unsigned char *buf,
int st_com_slave_handle_followup(struct pp_instance *ppi, unsigned char *buf,
int len);
int st_com_handle_pdelay_req(struct pp_instance *ppi, unsigned char *buf,
int len);
#define MSG_SEND_AND_RET_VARLEN(x, y, z, w) \
if (pp_net_ops.send(ppi, ppi->buf_out, w,\
&ppi->last_snt_time, PP_NP_##y , z) < w) { \
......
......@@ -133,9 +133,6 @@ void msg_pack_header(struct pp_instance *ppi, void *buf)
{
Nibble transport = 0x80;
if (OPTS(ppi)->gptp_mode)
transport = 0x10;
/* (spec annex D) */
*(UInteger8 *) (buf + 0) = transport;
*(UInteger4 *) (buf + 1) = DSPOR(ppi)->versionNumber;
......@@ -315,39 +312,6 @@ void msg_unpack_follow_up(void *buf, MsgFollowUp *flwup)
}
}
/* pack PdelayReq message into out buffer of ppi */
void msg_pack_pdelay_req(struct pp_instance *ppi, Timestamp *orig_tstamp)
{
void *buf;
buf = ppi->buf_out;
/* changes in header */
*(char *)(buf + 0) = *(char *)(buf + 0) & 0xF0;
/* RAZ messageType */
*(char *)(buf + 0) = *(char *)(buf + 0) | 0x02;
/* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_PDELAY_REQ_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->sent_seq_id[PPM_PDELAY_REQ]);
*(UInteger8 *) (buf + 32) = 0x05;
/* Table 23 */
*(Integer8 *) (buf + 33) = 0x7F;
/* Table 24 */
memset((buf + 8), 0, 8);
/* Pdelay_req message */
*(UInteger16 *) (buf + 34) = htons(orig_tstamp->secondsField.msb);
*(UInteger32 *) (buf + 36) = htonl(orig_tstamp->secondsField.lsb);
*(UInteger32 *) (buf + 40) = htonl(orig_tstamp->nanosecondsField);
memset((buf + 44), 0, 10);
/* RAZ reserved octets */
}
/* pack DelayReq message into out buffer of ppi */
void msg_pack_delay_req(struct pp_instance *ppi, Timestamp *orig_tstamp)
{
......@@ -419,41 +383,6 @@ void msg_pack_delay_resp(struct pp_instance *ppi,
htons(hdr->sourcePortIdentity.portNumber);
}
/* Pack PdelayResp message into out buffer of ppi */
void msg_pack_pdelay_resp(struct pp_instance *ppi, MsgHeader *hdr,
Timestamp *req_rec_tstamp)
{
void *buf;
buf = ppi->buf_out;
/* changes in header */
*(char *)(buf + 0) = *(char *)(buf + 0) & 0xF0;
/* RAZ messageType */
*(char *)(buf + 0) = *(char *)(buf + 0) | 0x03;
/* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_PDELAY_RESP_LENGTH);
*(UInteger8 *) (buf + 4) = hdr->domainNumber;
memset((buf + 8), 0, 8);
*(UInteger16 *) (buf + 30) = htons(hdr->sequenceId);
*(UInteger8 *) (buf + 32) = 0x05;
/* Table 23 */
*(Integer8 *) (buf + 33) = 0x7F;
/* Table 24 */
/* Pdelay_resp message */
*(UInteger16 *) (buf + 34) = htons(req_rec_tstamp->secondsField.msb);
*(UInteger32 *) (buf + 36) = htonl(req_rec_tstamp->secondsField.lsb);
*(UInteger32 *) (buf + 40) = htonl(req_rec_tstamp->nanosecondsField);
memcpy((buf + 44), hdr->sourcePortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH);
*(UInteger16 *) (buf + 52) =
htons(hdr->sourcePortIdentity.portNumber);
}
/* Unpack delayReq message from in buffer of ppi to msgtmp.req */
void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req)
{
......@@ -472,24 +401,6 @@ void msg_unpack_delay_req(void *buf, MsgDelayReq *delay_req)
}
}
/* Unpack PdelayReq message from IN buffer of ppi to msgtmp.req */
void msg_unpack_pdelay_req(void *buf, MsgPDelayReq *pdelay_req)
{
pdelay_req->originTimestamp.secondsField.msb =
htons(*(UInteger16 *) (buf + 34));
pdelay_req->originTimestamp.secondsField.lsb =
htonl(*(UInteger32 *) (buf + 36));
pdelay_req->originTimestamp.nanosecondsField =
htonl(*(UInteger32 *) (buf + 40));
if (pp_verbose_dump) {
PP_VPRINTF("Message PDELAY_REQ\n");
timestamp_display("Origin Timestamp",
&pdelay_req->originTimestamp);
PP_VPRINTF("\n");
}
}
/* Unpack delayResp message from IN buffer of ppi to msgtmp.presp */
void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp)
{
......@@ -513,94 +424,6 @@ void msg_unpack_delay_resp(void *buf, MsgDelayResp *resp)
}
}
/* Unpack PdelayResp message from IN buffer of ppi to msgtmp.presp */
void msg_unpack_pdelay_resp(void *buf, MsgPDelayResp *presp)
{
presp->requestReceiptTimestamp.secondsField.msb =
htons(*(UInteger16 *) (buf + 34));
presp->requestReceiptTimestamp.secondsField.lsb =
htonl(*(UInteger32 *) (buf + 36));
presp->requestReceiptTimestamp.nanosecondsField =
htonl(*(UInteger32 *) (buf + 40));
memcpy(presp->requestingPortIdentity.clockIdentity,
(buf + 44), PP_CLOCK_IDENTITY_LENGTH);
presp->requestingPortIdentity.portNumber =
htons(*(UInteger16 *) (buf + 52));
if (pp_verbose_dump) {
PP_VPRINTF("Message PDELAY_RESP\n");
timestamp_display("Request Receipt Timestamp",
&presp->requestReceiptTimestamp);
/* FIXME diag display requestingPortIdentity */
PP_VPRINTF("\n");
}
}
/* Pack PdelayRespFollowUp message into out buffer of ppi */
void msg_pack_pdelay_resp_followup(struct pp_instance *ppi,
MsgHeader *hdr,
Timestamp *resp_orig_tstamp)
{
void *buf;
buf = ppi->buf_out;
/* changes in header */
*(char *)(buf + 0) = *(char *)(buf + 0) & 0xF0;
/* RAZ messageType */
*(char *)(buf + 0) = *(char *)(buf + 0) | 0x0A;
/* Table 19 */
*(UInteger16 *) (buf + 2) = htons(PP_PDELAY_RESP_FOLLOW_UP_LENGTH);
*(UInteger16 *) (buf + 30) = htons(ppi->pdelay_req_hdr.sequenceId);
*(UInteger8 *) (buf + 32) = 0x05;
/* Table 23 */
*(Integer8 *) (buf + 33) = 0x7F;
/* Table 24 */
/* Copy correctionField of PdelayReqMessage */
*(Integer32 *) (buf + 8) = htonl(hdr->correctionfield.msb);
*(Integer32 *) (buf + 12) = htonl(hdr->correctionfield.lsb);
/* Pdelay_resp_follow_up message */
*(UInteger16 *) (buf + 34) =
htons(resp_orig_tstamp->secondsField.msb);
*(UInteger32 *) (buf + 36) =
htonl(resp_orig_tstamp->secondsField.lsb);
*(UInteger32 *) (buf + 40) =
htonl(resp_orig_tstamp->nanosecondsField);
memcpy((buf + 44), hdr->sourcePortIdentity.clockIdentity,
PP_CLOCK_IDENTITY_LENGTH);
*(UInteger16 *) (buf + 52) =
htons(hdr->sourcePortIdentity.portNumber);
}
/* Unpack PdelayResp message from in buffer of ppi to msgtmp.presp */
void msg_unpack_pdelay_resp_followup(void *buf,
MsgPDelayRespFollowUp *presp_follow)
{
presp_follow->responseOriginTimestamp.secondsField.msb =
htons(*(UInteger16 *) (buf + 34));
presp_follow->responseOriginTimestamp.secondsField.lsb =
htonl(*(UInteger32 *) (buf + 36));
presp_follow->responseOriginTimestamp.nanosecondsField =
htonl(*(UInteger32 *) (buf + 40));
memcpy(presp_follow->requestingPortIdentity.clockIdentity,
(buf + 44), PP_CLOCK_IDENTITY_LENGTH);
presp_follow->requestingPortIdentity.portNumber =
htons(*(UInteger16 *) (buf + 52));
if (pp_verbose_dump) {
PP_VPRINTF("Message PDELAY_RESP_FOLLOW_UP\n");
timestamp_display("Response Origin Timestamp",
&presp_follow->responseOriginTimestamp);
/* FIXME diag display requestingPortIdentity */
PP_VPRINTF("\n");
}
}
const char const *pp_msg_names[] = {
[PPM_SYNC] = "sync",
[PPM_DELAY_REQ] = "delay_req",
......@@ -660,30 +483,6 @@ int msg_issue_delay_req(struct pp_instance *ppi)
MSG_SEND_AND_RET(DELAY_REQ, EVT, 0);
}
/* Pack and send on event multicast ip address a PDelayReq message */
int msg_issue_pdelay_req(struct pp_instance *ppi)
{
Timestamp orig_tstamp;
TimeInternal now;
pp_t_ops.get(&now);
from_TimeInternal(&now, &orig_tstamp);
msg_pack_pdelay_req(ppi, &orig_tstamp);
MSG_SEND_AND_RET(PDELAY_REQ, EVT, 1);
}
/* Pack and send on event multicast ip address a PDelayResp message */
int msg_issue_pdelay_resp(struct pp_instance *ppi, TimeInternal *time,
MsgHeader *hdr)
{
Timestamp req_rec_tstamp;
from_TimeInternal(time, &req_rec_tstamp);
msg_pack_pdelay_resp(ppi, hdr, &req_rec_tstamp);
MSG_SEND_AND_RET(PDELAY_RESP, EVT, 1);
}
/* Pack and send on event multicast ip adress a DelayResp message */
int msg_issue_delay_resp(struct pp_instance *ppi, TimeInternal *time)
{
......@@ -694,15 +493,3 @@ int msg_issue_delay_resp(struct pp_instance *ppi, TimeInternal *time)
MSG_SEND_AND_RET(DELAY_RESP, GEN, 0);
}
/* Pack and send on event multicast ip adress a DelayResp message */
int msg_issue_pdelay_resp_follow_up(struct pp_instance *ppi, TimeInternal *time)
{
Timestamp resp_orig_tstamp;
from_TimeInternal(time, &resp_orig_tstamp);
msg_pack_pdelay_resp_followup(ppi, &ppi->pdelay_req_hdr,
&resp_orig_tstamp);
MSG_SEND_AND_RET(PDELAY_RESP_FOLLOW_UP, GEN, 0);
}
......@@ -27,8 +27,6 @@ struct pp_runtime_opts default_rt_opts = {
.ai = PP_DEFAULT_AI,
.s = PP_DEFAULT_DELAY_S,
.ethernet_mode = PP_DEFAULT_ETHERNET_MODE,
.e2e_mode = PP_DEFAULT_E2E_MODE,
.gptp_mode = PP_DEFAULT_GPTP_MODE,
.ofst_first_updated = 0, /* FIXME: is it a option or a state var? */
.max_foreign_records = PP_DEFAULT_MAX_FOREIGN_RECORDS,
.cur_utc_ofst = PP_DEFAULT_UTC_OFFSET,
......
......@@ -104,76 +104,6 @@ void pp_update_delay(struct pp_instance *ppi, TimeInternal *correction_field)
}
}
void pp_update_peer_delay(struct pp_instance *ppi,
TimeInternal *correction_field, int two_step)
{
Integer16 s;
struct pp_owd_fltr *owd_fltr = &SRV(ppi)->owd_fltr;
if (two_step) {
/* calc 'slave_to_master_delay' */
sub_TimeInternal(&SRV(ppi)->pdelay_ms,
&ppi->pdelay_resp_receive_time,
&ppi->pdelay_resp_send_time);
sub_TimeInternal(&SRV(ppi)->pdelay_sm,
&ppi->pdelay_req_receive_time,
&ppi->pdelay_req_send_time);
/* update 'one_way_delay' */
add_TimeInternal(&DSPOR(ppi)->peerMeanPathDelay,
&SRV(ppi)->pdelay_ms,
&SRV(ppi)->pdelay_sm);
/* Substract correctionField */
sub_TimeInternal(&DSPOR(ppi)->peerMeanPathDelay,
&DSPOR(ppi)->peerMeanPathDelay, correction_field);
/* Compute one-way delay */
div2_TimeInternal(&DSPOR(ppi)->peerMeanPathDelay);
} else {
/* One step clock */
sub_TimeInternal(&DSPOR(ppi)->peerMeanPathDelay,
&ppi->pdelay_resp_receive_time,
&ppi->pdelay_req_send_time);
/* Substract correctionField */
sub_TimeInternal(&DSPOR(ppi)->peerMeanPathDelay,
&DSPOR(ppi)->peerMeanPathDelay, correction_field);
/* Compute one-way delay */
div2_TimeInternal(&DSPOR(ppi)->peerMeanPathDelay);
}
if (DSPOR(ppi)->peerMeanPathDelay.seconds) {
/* cannot filter with secs, clear filter */
owd_fltr->s_exp = owd_fltr->nsec_prev = 0;
return;
}
/* avoid overflowing filter */
s = OPTS(ppi)->s;
while (abs(owd_fltr->y) >> (31 - s))
--s;
/* crank down filter cutoff by increasing 's_exp' */
if (owd_fltr->s_exp < 1)
owd_fltr->s_exp = 1;
else if (owd_fltr->s_exp < 1 << s)
++owd_fltr->s_exp;
else if (owd_fltr->s_exp > 1 << s)
owd_fltr->s_exp = 1 << s;
/* filter 'meanPathDelay' */
owd_fltr->y = (owd_fltr->s_exp - 1) *
owd_fltr->y / owd_fltr->s_exp +
(DSPOR(ppi)->peerMeanPathDelay.nanoseconds / 2 +
owd_fltr->nsec_prev / 2) / owd_fltr->s_exp;
owd_fltr->nsec_prev = DSPOR(ppi)->peerMeanPathDelay.nanoseconds;
DSPOR(ppi)->peerMeanPathDelay.nanoseconds = owd_fltr->y;
}
void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time,
TimeInternal *recv_time, TimeInternal *correction_field)
{
......@@ -209,17 +139,10 @@ void pp_update_offset(struct pp_instance *ppi, TimeInternal *send_time,
sub_TimeInternal(&SRV(ppi)->m_to_s_dly,
&SRV(ppi)->m_to_s_dly, correction_field);
/* update 'offsetFromMaster' */
if (!OPTS(ppi)->e2e_mode) {
sub_TimeInternal(&DSCUR(ppi)->offsetFromMaster,
&SRV(ppi)->m_to_s_dly,
&DSPOR(ppi)->peerMeanPathDelay);
} else {
/* (End to End mode) */
sub_TimeInternal(&DSCUR(ppi)->offsetFromMaster,
/* update 'offsetFromMaster', (End to End mode) */
sub_TimeInternal(&DSCUR(ppi)->offsetFromMaster,
&SRV(ppi)->m_to_s_dly,
&DSCUR(ppi)->meanPathDelay);
}
if (DSCUR(ppi)->offsetFromMaster.seconds) {
/* cannot filter with secs, clear filter */
......@@ -325,15 +248,9 @@ display:
PP_VPRINTF("\n--Offset and Delay filtered--\n");
if (!OPTS(ppi)->e2e_mode) {
PP_VPRINTF("one-way delay averaged (P2P): %9i.%09i\n",
DSPOR(ppi)->peerMeanPathDelay.seconds,
DSPOR(ppi)->peerMeanPathDelay.nanoseconds);
} else {
PP_VPRINTF("one-way delay averaged (E2E): %9i.%09i\n",
DSCUR(ppi)->meanPathDelay.seconds,
DSCUR(ppi)->meanPathDelay.nanoseconds);
}
PP_VPRINTF("one-way delay averaged (E2E): %9i.%09i\n",
DSCUR(ppi)->meanPathDelay.seconds,
DSCUR(ppi)->meanPathDelay.nanoseconds);
PP_VPRINTF("offset from master: %9i.%09i\n",
DSCUR(ppi)->offsetFromMaster.seconds,
......
......@@ -11,9 +11,6 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
{
TimeInternal *time;
TimeInternal *time_snt;
TimeInternal req_rec_tstamp;
TimeInternal correction_field;
TimeInternal resp_orig_tstamp;
int msgtype;
int e = 0; /* error var, to check errors in msg handling */
MsgHeader *hdr = &ppi->msg_tmp_header;
......@@ -28,9 +25,6 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
pp_timer_start((1 << DSPOR(ppi)->logAnnounceInterval) * 1000,
ppi->timers[PP_TIMER_ANN_INTERVAL]);
pp_timer_start(
(1 << DSPOR(ppi)->logMinPdelayReqInterval) * 1000,
ppi->timers[PP_TIMER_PDELAYREQ]);
/* Send an announce immediately, when becomes master */
if (msg_issue_announce(ppi) < 0)
goto out;
......@@ -57,14 +51,6 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
goto out;
}
if (!OPTS(ppi)->e2e_mode) {
if (pp_timer_expired(ppi->timers[PP_TIMER_PDELAYREQ])) {
PP_VPRINTF("event PDELAYREQ_INTERVAL_TOUT_EXPIRES\n");
if (msg_issue_pdelay_req(ppi) < 0)
goto out;
}
}
if (plen == 0)
goto out;
......@@ -99,99 +85,12 @@ int pp_master(struct pp_instance *ppi, unsigned char *pkt, int plen)
msg_issue_delay_resp(ppi, time);
break;
case PPM_PDELAY_REQ:
e = st_com_handle_pdelay_req(ppi, pkt, plen);
break;
case PPM_PDELAY_RESP:
/* Loopback Timestamp */
if (OPTS(ppi)->e2e_mode)
break;
if (ppi->is_from_self) {
/*Add latency*/
add_TimeInternal(time, time,
&OPTS(ppi)->outbound_latency);
e = msg_issue_pdelay_resp_follow_up(ppi, time);
break;
}
msg_unpack_pdelay_resp(pkt, &ppi->msg_tmp.presp);
if (!((ppi->sent_seq_id[PPM_PDELAY_REQ] ==
hdr->sequenceId)
&& (!memcmp(DSPOR(ppi)->portIdentity.clockIdentity,
ppi->msg_tmp.presp.requestingPortIdentity.
clockIdentity,
PP_CLOCK_IDENTITY_LENGTH))
&& (DSPOR(ppi)->portIdentity.portNumber ==
ppi->msg_tmp.presp.requestingPortIdentity.portNumber))
) {
if ((hdr->flagField[0] & PP_TWO_STEP_FLAG) != 0) {
/* Two Step Clock */
/* Store t4 (Fig 35) */
ppi->pdelay_resp_receive_time.seconds =
time->seconds;
ppi->pdelay_resp_receive_time.nanoseconds =
time->nanoseconds;
/* Store t2 (Fig 35) */
to_TimeInternal(&req_rec_tstamp,
&ppi->msg_tmp.presp.
requestReceiptTimestamp);
ppi->pdelay_req_receive_time.seconds =
req_rec_tstamp.seconds;
ppi->pdelay_req_receive_time.nanoseconds =
req_rec_tstamp.nanoseconds;
int64_to_TimeInternal(
hdr->correctionfield,
&correction_field);
ppi->last_pdelay_resp_corr_field.seconds =
correction_field.seconds;
ppi->last_pdelay_resp_corr_field.nanoseconds =
correction_field.nanoseconds;
break;
} else {
/* One step Clock */
/* Store t4 (Fig 35)*/
ppi->pdelay_resp_receive_time.seconds =
time->seconds;
ppi->pdelay_resp_receive_time.nanoseconds =
time->nanoseconds;
int64_to_TimeInternal(
hdr->correctionfield,
&correction_field);
pp_update_peer_delay(ppi, &correction_field, 0);
break;
}
}
break; /* XXX added by gnn for safety */
case PPM_PDELAY_RESP_FOLLOW_UP:
if (hdr->sequenceId == ppi->sent_seq_id[PPM_PDELAY_REQ] - 1) {
msg_unpack_pdelay_resp_followup(pkt,
&ppi->msg_tmp.prespfollow);
to_TimeInternal(&resp_orig_tstamp,
&ppi->msg_tmp.prespfollow.
responseOriginTimestamp);
ppi->pdelay_resp_send_time.seconds =
resp_orig_tstamp.seconds;
ppi->pdelay_resp_send_time.nanoseconds =
resp_orig_tstamp.nanoseconds;
int64_to_TimeInternal(
ppi->msg_tmp_header.correctionfield,
&correction_field);
add_TimeInternal(&correction_field,
&correction_field,
&ppi->last_pdelay_resp_corr_field);
pp_update_peer_delay(ppi, &correction_field, 1);
break;
}
break;
/*
* We are not supporting pdelay (not configured to, see
* 9.5.13.1, p 106), so all the code about pdelay is removed
* as a whole by one commit in our history. It can be recoverd
* and fixed if needed
*/
default:
/* disregard, nothing to do */
......@@ -212,7 +111,6 @@ state_updated:
if (ppi->next_state != ppi->state) {
pp_timer_stop(ppi->timers[PP_TIMER_SYNC]);
pp_timer_stop(ppi->timers[PP_TIMER_ANN_INTERVAL]);
pp_timer_stop(ppi->timers[PP_TIMER_PDELAYREQ]);
}
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
......
......@@ -12,9 +12,6 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (ppi->is_new_state) {
DSPOR(ppi)->portState = PPS_PASSIVE;
pp_timer_start(
(1 << DSPOR(ppi)->logMinPdelayReqInterval) * 1000,
ppi->timers[PP_TIMER_PDELAYREQ]);
st_com_restart_annrec_timer(ppi);
}
......@@ -31,10 +28,6 @@ int pp_passive(struct pp_instance *ppi, unsigned char *pkt, int plen)
e = st_com_master_handle_announce(ppi, pkt, plen);
break;
case PPM_PDELAY_REQ:
e = st_com_handle_pdelay_req(ppi, pkt, plen);
break;
case PPM_SYNC:
e = st_com_master_handle_sync(ppi, pkt, plen);
break;
......@@ -57,7 +50,6 @@ state_updated:
/* Leaving this state */
if (ppi->next_state != ppi->state) {
pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
pp_timer_stop(ppi->timers[PP_TIMER_PDELAYREQ]);
}
ppi->next_delay = PP_DEFAULT_NEXT_DELAY_MS;
......
......@@ -12,7 +12,6 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
int e = 0; /* error var, to check errors in msg handling */
TimeInternal *time;
TimeInternal correction_field;
TimeInternal resp_orig_tstamp;
MsgHeader *hdr = &ppi->msg_tmp_header;
time = &ppi->last_rcv_time;
......@@ -29,21 +28,10 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
ppi->waiting_for_follow = FALSE;
clear_TimeInternal(&ppi->pdelay_req_send_time);
clear_TimeInternal(&ppi->pdelay_req_receive_time);
clear_TimeInternal(&ppi->pdelay_resp_send_time);
clear_TimeInternal(&ppi->pdelay_resp_receive_time);
st_com_restart_annrec_timer(ppi);
if (OPTS(ppi)->e2e_mode)
pp_timer_start(
(1 << DSPOR(ppi)->logMinDelayReqInterval) * 1000,
ppi->timers[PP_TIMER_DELAYREQ]);
else
pp_timer_start(
(1 << DSPOR(ppi)->logMinPdelayReqInterval) * 1000,
ppi->timers[PP_TIMER_PDELAYREQ]);
pp_timer_start((1 << DSPOR(ppi)->logMinDelayReqInterval)
* 1000, ppi->timers[PP_TIMER_DELAYREQ]);
}
if (st_com_check_record_update(ppi))
......@@ -83,9 +71,6 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
if (e)
break;
if (!OPTS(ppi)->e2e_mode)
break;
msg_unpack_delay_resp(pkt, &ppi->msg_tmp.resp);
if ((memcmp(DSPOR(ppi)->portIdentity.clockIdentity,
......@@ -121,110 +106,12 @@ int pp_slave(struct pp_instance *ppi, unsigned char *pkt, int plen)
break;
case PPM_PDELAY_REQ:
e = st_com_handle_pdelay_req(ppi, pkt, plen);
break;
case PPM_PDELAY_RESP:
if (OPTS(ppi)->e2e_mode)
break;
e = (plen < PP_PDELAY_RESP_LENGTH);
if (e)
break;
if (ppi->is_from_self) {
add_TimeInternal(time, time,
&OPTS(ppi)->outbound_latency);
msg_issue_pdelay_resp_follow_up(ppi, time);
break;
}
msg_unpack_pdelay_resp(pkt,
&ppi->msg_tmp.presp);
if (!((ppi->sent_seq_id[PPM_PDELAY_REQ] ==
hdr->sequenceId)
&& (!memcmp(DSPOR(ppi)->portIdentity.clockIdentity,
ppi->msg_tmp.presp.requestingPortIdentity.
clockIdentity, PP_CLOCK_IDENTITY_LENGTH))
&& (DSPOR(ppi)->portIdentity.portNumber ==
ppi->msg_tmp.presp.
requestingPortIdentity.portNumber))) {
if ((hdr->flagField[0] & 0x02) ==
PP_TWO_STEP_FLAG) {
/* Two Step Clock */
/* Store t4 (Fig 35) */
ppi->pdelay_resp_receive_time.seconds =
time->seconds;
ppi->pdelay_resp_receive_time.nanoseconds =
time->nanoseconds;
/* Store t2 (Fig 35) */
to_TimeInternal(&ppi->pdelay_req_receive_time,
&ppi->msg_tmp.presp.
requestReceiptTimestamp);
int64_to_TimeInternal(hdr->correctionfield,
&correction_field);
ppi->last_pdelay_resp_corr_field.seconds =
correction_field.seconds;
ppi->last_pdelay_resp_corr_field.nanoseconds =
correction_field.nanoseconds;
} else {
/* One step Clock */
/* Store t4 (Fig 35) */
ppi->pdelay_resp_receive_time.seconds =
time->seconds;
ppi->pdelay_resp_receive_time.nanoseconds =
time->nanoseconds;
int64_to_TimeInternal(hdr->correctionfield,
&correction_field);
pp_update_peer_delay(ppi, &correction_field, 0);
}
} else {
PP_VPRINTF("pp_slave : PDelay Resp doesn't "
"match PDelay Req.\n");
}
break;
case PPM_PDELAY_RESP_FOLLOW_UP:
if (OPTS(ppi)->e2e_mode)
break;
e = (plen < PP_PDELAY_RESP_FOLLOW_UP_LENGTH);
if (e)
break;
if (hdr->sequenceId ==
ppi->sent_seq_id[PPM_PDELAY_REQ]) {
msg_unpack_pdelay_resp_followup(
pkt,
&ppi->msg_tmp.prespfollow);
to_TimeInternal(
&resp_orig_tstamp,
&ppi->msg_tmp.prespfollow.
responseOriginTimestamp);
ppi->pdelay_resp_send_time.seconds =
resp_orig_tstamp.seconds;
ppi->pdelay_resp_send_time.nanoseconds =
resp_orig_tstamp.nanoseconds;
int64_to_TimeInternal(
hdr->correctionfield,
&correction_field);
add_TimeInternal(&correction_field, &correction_field,
&ppi->last_pdelay_req_corr_field);
pp_update_peer_delay(ppi, &correction_field, 1);
}
break;
/*
* We are not supporting pdelay (not configured to, see
* 9.5.13.1, p 106), so all the code about pdelay is removed
* as a whole by one commit in our history. It can be recoverd
* and fixed if needed
*/
default:
/* disregard, nothing to do */
......@@ -245,10 +132,7 @@ state_updated:
if (ppi->next_state != ppi->state) {
pp_timer_stop(ppi->timers[PP_TIMER_ANN_RECEIPT]);
if (OPTS(ppi)->e2e_mode)
pp_timer_stop(ppi->timers[PP_TIMER_DELAYREQ]);
else
pp_timer_stop(ppi->timers[PP_TIMER_PDELAYREQ]);
pp_timer_stop(ppi->timers[PP_TIMER_DELAYREQ]);
pp_init_clock(ppi);
}
......
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