Commit f760717f authored by Aurelio Colosimo's avatar Aurelio Colosimo

arch-gnu-linux/posix-socket.c: Fix order of EVT/GEN frames reception

This patch fixes a bug related to reception order of msgs. Sync msgs
are defined as "Event" messages and FollowUp are "General" messages, and we
need to handle them in the very same order they were sent (i.e. FollowUp is
after Sync). With the implementation prior to this patch, we tried to
serve Event and General alternatively. Now we always check for Event frames
before General ones. I didn't find, in ieee spec, whether they cleary state
that Event class is higher priority, at reception, with respect to General,
but this is likely to be in this way, since Event messages are those needing
the most precise timing.

For more information about PTP message classes, see IEEE 1588v2, pag. 17,
paragraph 6.4.
Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent 01290482
......@@ -105,16 +105,10 @@ static int posix_net_recv(struct pp_instance *ppi, void *pkt, int len,
return ret;
}
/* else: UDP, we can return one frame only, so swap priority */
if (POSIX_ARCH(ppi)->rcv_switch) {
ch1 = &(NP(ppi)->ch[PP_NP_GEN]);
ch2 = &(NP(ppi)->ch[PP_NP_EVT]);
} else {
ch1 = &(NP(ppi)->ch[PP_NP_EVT]);
ch2 = &(NP(ppi)->ch[PP_NP_GEN]);
}
POSIX_ARCH(ppi)->rcv_switch = !POSIX_ARCH(ppi)->rcv_switch;
/* else: UDP, we can return one frame only, always handle EVT msgs
* before GEN */
ch1 = &(NP(ppi)->ch[PP_NP_EVT]);
ch2 = &(NP(ppi)->ch[PP_NP_GEN]);
ret = -1;
if (ch1->pkt_present)
......
......@@ -9,7 +9,6 @@
#define POSIX_ARCH(ppi) ((struct posix_arch_data *)(ppi->arch_data))
struct posix_arch_data {
struct timeval tv;
int rcv_switch; /* flag for event / general receive order */
};
extern int posix_net_check_pkt(struct pp_instance *ppi, int delay_ms);
......
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