diff mbox series

[API-NEXT,v3,1/3] example: switch to using ODP chksum API

Message ID 1511190013-8520-2-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v3,1/3] example: switch to using ODP chksum API | expand

Commit Message

Github ODP bot Nov. 20, 2017, 3 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


ODP now provides odp_chksum_ones_comp16, switch examples to use it
instead of odph_chksum helper function.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 280 (lumag:chksum)
 ** https://github.com/Linaro/odp/pull/280
 ** Patch: https://github.com/Linaro/odp/pull/280.patch
 ** Base sha: d4b364849c4abb4c71e0c5260e1a793ebb8dc97d
 ** Merge commit sha: 9fda6f107cef0c4074880995a90b30cbeac27ce8
 **/
 example/generator/odp_generator.c | 7 ++++---
 example/ipsec/odp_ipsec_stream.c  | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 912fe7e9e..e1d98539f 100644
--- a/example/generator/odp_generator.c
+++ b/example/generator/odp_generator.c
@@ -355,7 +355,7 @@  static int setup_udp_pkt(odp_packet_t pkt, odp_pktout_config_opt_t *pktout_cfg)
 	ip->id = odp_cpu_to_be_16(seq);
 	if (!pktout_cfg->bit.ipv4_chksum) {
 		ip->chksum = 0;
-		ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN);
+		ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN);
 	}
 
 	if (pktout_cfg->bit.ipv4_chksum || pktout_cfg->bit.udp_chksum) {
@@ -453,7 +453,7 @@  static int setup_icmp_pkt(odp_packet_t pkt,
 	ip->id = odp_cpu_to_be_16(seq);
 	if (!pktout_cfg->bit.ipv4_chksum) {
 		ip->chksum = 0;
-		ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN);
+		ip->chksum = ~odp_chksum_ones_comp16(ip, ODPH_IPV4HDR_LEN);
 	}
 
 	/* icmp */
@@ -466,7 +466,8 @@  static int setup_icmp_pkt(odp_packet_t pkt,
 	memcpy(tval_d, &tval, sizeof(uint64_t));
 
 	icmp->chksum = 0;
-	icmp->chksum = odph_chksum(icmp, args->appl.payload + ODPH_ICMPHDR_LEN);
+	icmp->chksum = ~odp_chksum_ones_comp16(icmp, args->appl.payload +
+					       ODPH_ICMPHDR_LEN);
 
 	if (pktout_cfg->bit.ipv4_chksum) {
 		odp_packet_l2_offset_set(pkt, 0);
diff --git a/example/ipsec/odp_ipsec_stream.c b/example/ipsec/odp_ipsec_stream.c
index e37fbee29..bc5d572f0 100644
--- a/example/ipsec/odp_ipsec_stream.c
+++ b/example/ipsec/odp_ipsec_stream.c
@@ -269,7 +269,8 @@  odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
 		inner_ip->frag_offset = 0;
 		inner_ip->src_addr = odp_cpu_to_be_32(stream->src_ip);
 		inner_ip->dst_addr = odp_cpu_to_be_32(stream->dst_ip);
-		inner_ip->chksum = odph_chksum(inner_ip, sizeof(*inner_ip));
+		inner_ip->chksum = ~odp_chksum_ones_comp16(inner_ip,
+							   sizeof(*inner_ip));
 		data += sizeof(*inner_ip);
 	}
 
@@ -290,7 +291,7 @@  odp_packet_t create_ipv4_packet(stream_db_entry_t *stream,
 
 	/* Close ICMP */
 	icmp->chksum = 0;
-	icmp->chksum = odph_chksum(icmp, data - (uint8_t *)icmp);
+	icmp->chksum = ~odp_chksum_ones_comp16(icmp, data - (uint8_t *)icmp);
 
 	/* Close ESP if specified */
 	if (esp) {