Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
fc71ea98
Commit
fc71ea98
authored
May 02, 2021
by
Antoine Kaufmann
Browse files
i40e_bm: add udp checksum calculation
With this nopaxos looks better.
parent
edacea02
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
sims/nic/i40e_bm/i40e_bm.h
sims/nic/i40e_bm/i40e_bm.h
+3
-0
sims/nic/i40e_bm/i40e_lan.cc
sims/nic/i40e_bm/i40e_lan.cc
+3
-0
sims/nic/i40e_bm/xsums.cc
sims/nic/i40e_bm/xsums.cc
+16
-0
No files found.
sims/nic/i40e_bm/i40e_bm.h
View file @
fc71ea98
...
...
@@ -620,6 +620,9 @@ class i40e_bm : public nicbm::Runner::Device {
// places the tcp checksum in the packet (assuming ipv4)
void
xsum_tcp
(
void
*
tcphdr
,
size_t
l4len
);
// places the udpp checksum in the packet (assuming ipv4)
void
xsum_udp
(
void
*
udpphdr
,
size_t
l4len
);
// calculates the full ipv4 & tcp checksum without assuming any pseudo header
// xsums
void
xsum_tcpip_tso
(
void
*
iphdr
,
uint8_t
iplen
,
uint8_t
l4len
,
uint16_t
paylen
);
...
...
sims/nic/i40e_bm/i40e_lan.cc
View file @
fc71ea98
...
...
@@ -591,6 +591,9 @@ bool lan_queue_tx::trigger_tx_packet() {
if
(
l4t
==
I40E_TX_DESC_CMD_L4T_EOFT_TCP
)
{
uint16_t
tcp_off
=
maclen
+
iplen
;
xsum_tcp
(
pktbuf
+
tcp_off
,
tso_len
-
tcp_off
);
}
else
if
(
l4t
==
I40E_TX_DESC_CMD_L4T_EOFT_UDP
)
{
uint16_t
udp_off
=
maclen
+
iplen
;
xsum_udp
(
pktbuf
+
udp_off
,
tso_len
-
udp_off
);
}
runner
->
EthSend
(
pktbuf
,
tso_len
);
...
...
sims/nic/i40e_bm/xsums.cc
View file @
fc71ea98
...
...
@@ -30,6 +30,14 @@ struct rte_tcp_hdr {
uint16_t
tcp_urp
;
/**< TCP urgent pointer, if any. */
}
__attribute__
((
packed
));
/* from dpdk/lib/librte_net/rte_udp.h */
struct
rte_udp_hdr
{
uint16_t
src_port
;
uint16_t
dst_port
;
uint16_t
dgram_len
;
uint16_t
dgram_cksum
;
}
__attribute__
((
packed
));
/* from dpdk/lib/librte_net/rte_ip.h */
struct
ipv4_hdr
{
uint8_t
version_ihl
;
/**< version and header length */
...
...
@@ -106,6 +114,14 @@ static inline uint16_t rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr) {
return
rte_raw_cksum
(
&
psd_hdr
,
sizeof
(
psd_hdr
));
}
void
xsum_udp
(
void
*
udphdr
,
size_t
l4_len
)
{
struct
rte_udp_hdr
*
udph
=
reinterpret_cast
<
struct
rte_udp_hdr
*>
(
udphdr
);
uint32_t
cksum
=
rte_raw_cksum
(
udphdr
,
l4_len
);
cksum
=
((
cksum
&
0xffff0000
)
>>
16
)
+
(
cksum
&
0xffff
);
cksum
=
(
~
cksum
)
&
0xffff
;
udph
->
dgram_cksum
=
cksum
;
}
void
xsum_tcp
(
void
*
tcphdr
,
size_t
l4_len
)
{
struct
rte_tcp_hdr
*
tcph
=
reinterpret_cast
<
struct
rte_tcp_hdr
*>
(
tcphdr
);
uint32_t
cksum
=
rte_raw_cksum
(
tcphdr
,
l4_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