Commit fc71ea98 authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

i40e_bm: add udp checksum calculation

With this nopaxos looks better.
parent edacea02
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
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