Commit b069c347 authored by Aurelio Colosimo's avatar Aurelio Colosimo Committed by Alessandro Rubini

ppsi: socket api rewritten to use wrpc-sw functions

This patch makes ppsi use lib/net.c socket functions, whose declaration is
in include/ptpd_netif.h
Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent cb0bfe80
ppsi @ 22c7e74f
Subproject commit 3c8d3a813413f6fc0740efeca6a4bb405123eedb Subproject commit 22c7e74fbd627dfc1a8eb3bcc3954a5abd3c20fd
...@@ -39,6 +39,7 @@ static struct pp_servo servo; ...@@ -39,6 +39,7 @@ static struct pp_servo servo;
static struct pp_frgn_master frgn_master; static struct pp_frgn_master frgn_master;
static int delay_ms = PP_DEFAULT_NEXT_DELAY_MS; static int delay_ms = PP_DEFAULT_NEXT_DELAY_MS;
static int start_tics = 0;
int wrc_ptp_init() int wrc_ptp_init()
{ {
...@@ -59,14 +60,6 @@ int wrc_ptp_init() ...@@ -59,14 +60,6 @@ int wrc_ptp_init()
ppi->frgn_master = &frgn_master; ppi->frgn_master = &frgn_master;
ppi->arch_data = NULL; ppi->arch_data = NULL;
#ifdef FIXME_NET_INIT
if (spec_open_ch(ppi)) {
/* FIXME spec_errno pp_diag_error(ppi, spec_errno); */
/* FIXME pp_diag_fatal(ppi, "open_ch", ""); */
}
#endif
pp_open_instance(ppi, 0 /* no opts */);
#ifdef PPSI_SLAVE #ifdef PPSI_SLAVE
/* FIXME slave_only */ /* FIXME slave_only */
OPTS(ppi)->slave_only = 1; OPTS(ppi)->slave_only = 1;
...@@ -171,21 +164,21 @@ int wrc_ptp_update() ...@@ -171,21 +164,21 @@ int wrc_ptp_update()
/* FIXME Alignment */ /* FIXME Alignment */
unsigned char *packet = _packet + 2; unsigned char *packet = _packet + 2;
/* Wait for a packet or for the timeout */
while (delay_ms && !minic_poll_rx()) {
timer_delay(1000);
delay_ms--;
}
if (!minic_poll_rx()) {
delay_ms = pp_state_machine(ppi, NULL, 0);
return 0;
}
/* /*
* We got a packet. If it's not ours, continue consuming * We got a packet. If it's not ours, continue consuming
* the pending timeout * the pending timeout
*/ */
/* FIXME i = spec_recv_packet(ppi, packet, sizeof(_packet), &ppi->last_rcv_time);*/ i = spec_recv_packet(ppi, packet, sizeof(_packet),
if (0) { &ppi->last_rcv_time);
if ((!i) && (timer_get_tics() - start_tics < delay_ms))
return 0;
if (!i) {
/* Nothing received, but timeout elapsed */
start_tics = timer_get_tics();
delay_ms = pp_state_machine(ppi, NULL, 0);
return 0;
}
if (pp_diag_verbosity > 1) {
int j; int j;
pp_printf("recvd: %i\n", i); pp_printf("recvd: %i\n", i);
for (j = 0; j < i - eth_ofst; j++) { for (j = 0; j < i - eth_ofst; j++) {
...@@ -197,10 +190,7 @@ int wrc_ptp_update() ...@@ -197,10 +190,7 @@ int wrc_ptp_update()
} }
/* Warning: PP_ETHERTYPE is endian-agnostic by design */ /* Warning: PP_ETHERTYPE is endian-agnostic by design */
if (((struct spec_ethhdr *)packet)->h_proto != delay_ms = pp_state_machine(ppi, packet, i);
htons(PP_ETHERTYPE))
return 0;
delay_ms = pp_state_machine(ppi, packet + eth_ofst, i - eth_ofst);
} }
return 0; return 0;
} }
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