Commit 0a50c6d3 authored by Alessandro Rubini's avatar Alessandro Rubini

pdelay: fix init, audit frame formats

This commit ensures all architectures do the proper things to work
with either end-to-end and peer-to-peer, and all frames use the
proper addresses

 * we avoid ifdef by using HAS_PTP and HAS_E2E
 * no need to -D config items in Makefile
 * wrpc now correctly sets ppg->delay_mech at startup
 * the simulator now correctly sets ppg->delay_mech at startup
 * bare archs correctly set ppg->delay_mech at startup
 * bare archs properly use one or the other multicast address
 * pp_instance_cfg->delay_mech is removed as not yet used
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c9855d2a
......@@ -77,12 +77,6 @@ ifneq ($(PROTO_EXT),)
endif
include proto-standard/Makefile
ifeq ($(CONFIG_E2E),y)
CFLAGS += -DCONFIG_E2E
else
CFLAGS += -DCONFIG_P2P
endif
# ...and the TIME choice sets the default operations
CFLAGS += -DDEFAULT_TIME_OPS=$(TIME)_time_ops
CFLAGS += -DDEFAULT_NET_OPS=$(TIME)_net_ops
......
......@@ -98,6 +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;
if ((!ppg->arch_data) || (!ppg->pp_instances))
return -1;
......
......@@ -50,11 +50,11 @@ int main(int argc, char **argv)
ppg->timePropertiesDS = &timePropertiesDS;
ppg->servo = &servo;
ppg->rt_opts = &__pp_default_rt_opts;
#ifdef CONFIG_P2P
ppg->delay_mech = PP_P2P_MECH;
#else
ppg->delay_mech = PP_E2E_MECH;
#endif
if (HAS_P2P) /* FIXME: turn this to a configuration opion */
ppg->delay_mech = PP_P2P_MECH;
else
ppg->delay_mech = PP_E2E_MECH;
/* We are hosted, so we can allocate */
ppg->max_links = PP_MAX_LINKS;
......
......@@ -95,7 +95,7 @@ static struct pp_globals ppg_static = {
.parentDS = &parentDS,
.timePropertiesDS = &timePropertiesDS,
.global_ext_data = &servo_state,
.delay_mech = WRC_E2E,
.delay_mech = HAS_P2P ? PP_P2P_MECH : PP_E2E_MECH,
};
int wrc_ptp_init()
......
......@@ -152,11 +152,11 @@ int main(int argc, char **argv)
sizeof(*ppg->timePropertiesDS));
ppg->servo = alloc_fn(ppsi_head, sizeof(*ppg->servo));
ppg->rt_opts = &__pp_default_rt_opts;
#ifdef CONFIG_P2P
ppg->delay_mech = PP_P2P_MECH;
#else
ppg->delay_mech = PP_E2E_MECH;
#endif
if (HAS_P2P) /* FIXME: turn this to a configuration opion */
ppg->delay_mech = PP_P2P_MECH;
else
ppg->delay_mech = PP_E2E_MECH;
ppg->max_links = PP_MAX_LINKS;
ppg->global_ext_data = alloc_fn(ppsi_head,
......
......@@ -115,7 +115,6 @@ struct pp_instance_cfg {
char port_name[16];
char iface_name[16];
int ext; /* 0: none, 1: whiterabbit */ /* FIXME extension enumeration */
int delay_mech; /* E2E: 0, P2P: 1 */
};
/*
......@@ -217,7 +216,7 @@ struct pp_globals {
DSTimeProperties *timePropertiesDS; /* page 70 */
/* Sync Mechanism */
int delay_mech; /* E2E : 0 , P2P : 1 */
int delay_mech; /* PP_E2E_MECH, PP_P2P_MECH */
/* Index of the pp_instance receiving the "Ebest" clock */
int ebest_idx;
......
......@@ -9,6 +9,18 @@
#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>
......
......@@ -50,6 +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,
.nlinks = 1,
.servo = &servo,
.defaultDS = &defaultDS,
......
......@@ -221,7 +221,7 @@ static int wr_handle_followup(struct pp_instance *ppi,
wr_servo_got_sync(ppi, precise_orig_timestamp,
&ppi->t2);
if (GLBS(ppi)->delay_mech)
if (GLBS(ppi)->delay_mech == PP_P2P_MECH)
wr_servo_update(ppi);
return 1; /* the caller returns too */
......
......@@ -32,7 +32,10 @@ static int bare_net_send(struct pp_instance *ppi, void *pkt, int len,
hdr->h_proto = htons(ETH_P_1588);
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, 6);
if (use_pdelay_addr)
memcpy(hdr->h_dest, PP_PDELAY_MACADDRESS, 6);
else
memcpy(hdr->h_dest, PP_MCAST_MACADDRESS, 6);
/* raw socket implementation always uses gen socket */
memcpy(hdr->h_source, ppi->ch[PP_NP_GEN].addr, 6);
......
......@@ -27,13 +27,12 @@ static int wrpc_open_ch(struct pp_instance *ppi)
struct wrpc_socket *sock;
mac_addr_t mac;
struct wr_sockaddr addr;
char *macaddr = PP_MCAST_MACADDRESS;
if (ppi->glbs->delay_mech == PP_P2P_MECH)
macaddr = PP_PDELAY_MACADDRESS;
addr.ethertype = ETH_P_1588;
#ifdef CONFIG_E2E
memcpy(addr.mac, PP_MCAST_MACADDRESS, sizeof(mac_addr_t));
#else
memcpy(addr.mac, PP_PDELAY_MACADDRESS, sizeof(mac_addr_t));
#endif
memcpy(addr.mac, macaddr, sizeof(mac_addr_t));
sock = ptpd_netif_create_socket(&__static_ptp_socket, &addr,
PTPD_SOCK_RAW_ETHERNET, 0);
if (!sock)
......
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