diff mbox series

[v3,9/11] linux-gen: pktio: loop: handle SCTP checksums

Message ID 1534762808-15588-10-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v3,1/11] validation: pktio: check sctp flag in parser tests | expand

Commit Message

Github ODP bot Aug. 20, 2018, 11 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Add code to emulate hardware SCTP checksumming support over loop device
(as it is done for IPv4/TCP/UDP).

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

---
/** Email created from pull request 674 (lumag:sctp-checksum)
 ** https://github.com/Linaro/odp/pull/674
 ** Patch: https://github.com/Linaro/odp/pull/674.patch
 ** Base sha: dc28824415ea510e3ef62e47f7640bf4a8420fde
 ** Merge commit sha: b482f9618a6edb2a2f2491ee5a7af757eab93b24
 **/
 platform/linux-generic/pktio/loop.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c
index faaef3ab5..388a00494 100644
--- a/platform/linux-generic/pktio/loop.c
+++ b/platform/linux-generic/pktio/loop.c
@@ -235,7 +235,8 @@  static inline void loopback_fix_checksums(odp_packet_t pkt,
 	uint8_t l4_proto;
 	void *l3_hdr;
 	uint32_t l3_len;
-	odp_bool_t ipv4_chksum_pkt, udp_chksum_pkt, tcp_chksum_pkt;
+	odp_bool_t ipv4_chksum_pkt, udp_chksum_pkt, tcp_chksum_pkt,
+		   sctp_chksum_pkt;
 	odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
 	l3_hdr = odp_packet_l3_ptr(pkt, &l3_len);
@@ -259,6 +260,11 @@  static inline void loopback_fix_checksums(odp_packet_t pkt,
 					   l4_proto == _ODP_IPPROTO_TCP,
 					   pkt_hdr->p.flags.l4_chksum_set,
 					   pkt_hdr->p.flags.l4_chksum);
+	sctp_chksum_pkt =  OL_TX_CHKSUM_PKT(pktout_cfg->bit.sctp_chksum,
+					    pktout_capa->bit.sctp_chksum,
+					    l4_proto == _ODP_IPPROTO_SCTP,
+					    pkt_hdr->p.flags.l4_chksum_set,
+					    pkt_hdr->p.flags.l4_chksum);
 
 	if (ipv4_chksum_pkt)
 		_odp_packet_ipv4_chksum_insert(pkt);
@@ -268,6 +274,9 @@  static inline void loopback_fix_checksums(odp_packet_t pkt,
 
 	if (udp_chksum_pkt)
 		_odp_packet_udp_chksum_insert(pkt);
+
+	if (sctp_chksum_pkt)
+		_odp_packet_sctp_chksum_insert(pkt);
 }
 
 static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
@@ -375,9 +384,11 @@  static int loopback_init_capability(pktio_entry_t *pktio_entry)
 	capa->config.pktin.bit.ipv4_chksum = 1;
 	capa->config.pktin.bit.tcp_chksum = 1;
 	capa->config.pktin.bit.udp_chksum = 1;
+	capa->config.pktin.bit.sctp_chksum = 1;
 	capa->config.pktout.bit.ipv4_chksum = 1;
 	capa->config.pktout.bit.tcp_chksum = 1;
 	capa->config.pktout.bit.udp_chksum = 1;
+	capa->config.pktout.bit.sctp_chksum = 1;
 	capa->config.inbound_ipsec = 1;
 	capa->config.outbound_ipsec = 1;
 
@@ -387,6 +398,8 @@  static int loopback_init_capability(pktio_entry_t *pktio_entry)
 		capa->config.pktout.bit.udp_chksum;
 	capa->config.pktout.bit.tcp_chksum_ena =
 		capa->config.pktout.bit.tcp_chksum;
+	capa->config.pktout.bit.sctp_chksum_ena =
+		capa->config.pktout.bit.sctp_chksum;
 
 	return 0;
 }