Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
31
Issues
31
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
714f806a
Commit
714f806a
authored
Apr 06, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
host: retrieve a sw timestamp on send/recv
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
6040e771
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
socket.c
host/socket.c
+18
-3
No files found.
host/socket.c
View file @
714f806a
...
...
@@ -140,9 +140,12 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
struct
hw_timestamp
*
hwts
)
{
unsigned
char
frame
[
1500
];
struct
timespec
ts
;
int
ret
;
ret
=
recv
(
sock
,
frame
,
sizeof
(
frame
),
MSG_DONTWAIT
);
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
if
(
ret
<
0
&&
errno
==
EAGAIN
)
return
0
;
if
(
ret
<
0
)
{
...
...
@@ -158,6 +161,11 @@ int minic_rx_frame(struct wr_ethhdr *hdr, uint8_t * payload, uint32_t buf_size,
ret
=
buf_size
;
}
memcpy
(
payload
,
frame
+
14
,
ret
);
hwts
->
sec
=
ts
.
tv_sec
;
hwts
->
nsec
=
ts
.
tv_nsec
;
hwts
->
phase
=
0
;
net_verbose
(
"%s: %9li.%09i.%03i
\n
"
,
__func__
,
(
long
)
hwts
->
sec
,
hwts
->
nsec
,
hwts
->
phase
);
return
ret
;
}
...
...
@@ -165,7 +173,8 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t * payload, uint32_t size,
struct
hw_timestamp
*
hwts
)
{
unsigned
char
frame
[
1500
];
int
hsize
;
struct
timespec
ts
;
int
hsize
,
len
;
if
(
hdr
->
ethtype
==
htons
(
0x8100
))
hsize
=
sizeof
(
struct
wr_ethhdr_vlan
);
...
...
@@ -176,10 +185,16 @@ int minic_tx_frame(struct wr_ethhdr_vlan *hdr, uint8_t * payload, uint32_t size,
dumpstruct
(
stdout
,
"tx header"
,
hdr
,
hsize
);
dumpstruct
(
stdout
,
"tx payload"
,
payload
,
size
);
memcpy
(
frame
,
hdr
,
hsize
);
memcpy
(
frame
+
hsize
,
payload
,
size
);
return
send
(
sock
,
frame
,
size
+
hsize
,
0
);
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
len
=
send
(
sock
,
frame
,
size
+
hsize
,
0
);
hwts
->
sec
=
ts
.
tv_sec
;
hwts
->
nsec
=
ts
.
tv_nsec
;
hwts
->
phase
=
0
;
net_verbose
(
"%s: %9li.%09i.%03i
\n
"
,
__func__
,
(
long
)
hwts
->
sec
,
hwts
->
nsec
,
hwts
->
phase
);
return
len
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment