Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing stale Tx timestamp fetch. #728

Merged
merged 2 commits into from
Dec 1, 2017

Conversation

mgalka
Copy link

@mgalka mgalka commented Nov 27, 2017

It fixes daemon_cl behavior in the following situation.

  1. Sent gPTP message.
  2. Try to get the timestamp.
  3. Repeat no. 2 until timeout occurs.
  4. Timeout occurs, continue operation.
  5. Timestamp comes (but it's not read).
  6. Sent another gPTP message.
  7. Try to get the timestamp.
  8. Read the timestamp -> Timestamp from message no. 1 is being read.
  9. Time synchronization fails due to the wrong Tx timestamp.

This fix discards stale Tx timestamps. It checks message type and sequence id of the reflected packet to see if it contains the timestamp for the frame being sent at the moment. In case it doesn't the timestamp is discarded.

@andrew-elder
Copy link

@mgalka, thank you for this pull request at the detailed notes. I assume you have actually observed what you are fixing here?

@mgalka
Copy link
Author

mgalka commented Nov 28, 2017

@andrew-elder Yes, I've observed the behaviour on a non-PC device. I couldn't reproduce the it though on a regular PC with i210 NIC, probably due to being unable to reproduce I/O load high enough to get the PDelay timeout to occur.

Copy link
Contributor

@pinealservo pinealservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

If you wouldn't mind, it would be helpful to add some sort of documentation about what you're doing; e.g. why pick 46 for the length of reflected_bytes, or why add 14 to reflected_bytes to get gptpCommonHeader? Comments/#defines would be fine.

I think I know the answers, but it took a while to check up on them and it would be helpful to future reviewers to not have to wonder about them.

@andrew-elder
Copy link

@mgalka - are you going to be able to address @pinealservo's comments? I really do appreciate this pull request and look forward to getting it merged!

@mgalka
Copy link
Author

mgalka commented Dec 1, 2017

@pinealservo @andrew-elder
I changed the code so it's a bit more self-explanatory.

Let's keep the explanation here also for the sake of clarity:

The size of the reflected_bytes is just enough to store the ethernet and ptp common headers. It's enough to get the Sequence Id and Message Type. At first, it took just 46 bytes, because we don't even need the whole PTP Common Header, now I changed it to the full header (2 bytes more than previously) to keep the code more clear.

I added a define ETHER_HDR_LEN for the Ethernet Header length. Previously it was kept as as a magic number 14, which was not the best idea.

I used PTP_COMMON_HDR_TRANSSPEC_MSGTYPE to get the Message Type from the frame. This macro basically does nothing, it's just there to keep the code more consistent.

@andrew-elder
Copy link

@mgalka - looks good to me. I'm merge in the next 24 hours if I don't see any other comments. @christopher-s-hall - do you have any comments on this?

Copy link
Contributor

@pinealservo pinealservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update; it's definitely clearer now.

@christopher-s-hall
Copy link
Contributor

This looks fine to me assuming that it still works with I210. I don't have the time to test right now.

@andrew-elder
Copy link

Thanks for the feedback @christopher-s-hall, merging...

@andrew-elder andrew-elder merged commit 9bbb455 into Avnu:open-avb-next Dec 1, 2017
@mgalka mgalka deleted the open-avb-next branch December 1, 2017 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants