-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: eth: native_posix: Enable gPTP support #8620
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| #include <sys/ioctl.h> | ||
| #include <sys/socket.h> | ||
| #include <net/if.h> | ||
| #include <time.h> | ||
|
|
||
| #ifdef __linux | ||
| #include <linux/if_tun.h> | ||
|
|
@@ -38,6 +39,10 @@ | |
| #include <sys_clock.h> | ||
| #include <logging/sys_log.h> | ||
|
|
||
| #if defined(CONFIG_NET_GPTP) | ||
| #include <net/gptp.h> | ||
| #endif | ||
|
|
||
| #include "eth_native_posix_priv.h" | ||
|
|
||
| /* Note that we cannot create the TUN/TAP device from the setup script | ||
|
|
@@ -138,3 +143,21 @@ ssize_t eth_write_data(int fd, void *buf, size_t buf_len) | |
| { | ||
| return write(fd, buf, buf_len); | ||
| } | ||
|
|
||
| #if defined(CONFIG_NET_GPTP) | ||
| int eth_clock_gettime(struct net_ptp_time *time) | ||
| { | ||
| struct timespec tp; | ||
| int ret; | ||
|
|
||
| ret = clock_gettime(CLOCK_MONOTONIC_RAW, &tp); | ||
|
||
| if (ret < 0) { | ||
| return -errno; | ||
| } | ||
|
|
||
| time->second = tp.tv_sec; | ||
| time->nanosecond = tp.tv_nsec; | ||
|
|
||
| return 0; | ||
| } | ||
| #endif /* CONFIG_NET_GPTP */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # Settings for native_posix ethernet driver | ||
| CONFIG_SYS_LOG_ETHERNET_LEVEL=1 | ||
| CONFIG_ETH_NATIVE_POSIX_PTP_CLOCK=y | ||
|
|
||
| #CONFIG_ETH_NATIVE_POSIX_RANDOM_MAC=y | ||
| CONFIG_ETH_NATIVE_POSIX_MAC_ADDR="00:00:5e:00:53:2a" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would not be too difficult to provide you a version of the host device time which could be offset. If you want tell, and I can add you a couple of functions in the timer driver. Same about the 2 functions below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the host device time is probably not needed here, at least for now. The reason being that the native_posix target is typically used when testing things and it might not be ok to change the host time in this case. Of course we could make this optional if someone really wishes to have this kind of feature. I am ok if you send a PR that adds this kind of support thou.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but note that I did not mean that we would change the real host time, but instead that we would provide you a fake time which would be offset compared to the real host one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I misunderstood you then. That kind of fake time would be much welcomed feature so if you have time to add such a feature, I would appreciate that.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger. I added a note in #6044 about it. Hopefully I will have time in the following days to add it.