diff mbox series

[API-NEXT,v2,2/4] linux-gen: packet: implement checksum validation status functions

Message ID 1510218017-21165-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/4] linux-gen: packet: add L3/L4 checksum validation flags | expand

Commit Message

Github ODP bot Nov. 9, 2017, 9 a.m. UTC
From: Bogdan Pricope <bogdan.pricope@linaro.org>


Checksum validation status functions return the status of the latest
checksum check done for the packet based on packet input flags and
packet error flags.

Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

---
/** Email created from pull request 269 (bogdanPricope:api_next_csum_status_pr)
 ** https://github.com/Linaro/odp/pull/269
 ** Patch: https://github.com/Linaro/odp/pull/269.patch
 ** Base sha: d22c949cc466bf28de559855a1cb525740578137
 ** Merge commit sha: 31b12178be4753494e806513020d7706600c8382
 **/
 platform/linux-generic/odp_packet.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 3b2fac212..59b943637 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -1284,6 +1284,32 @@  int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset)
 	return 0;
 }
 
+odp_packet_chksum_status_t odp_packet_l3_chksum_status(odp_packet_t pkt)
+{
+	odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+	if (!pkt_hdr->p.input_flags.l3_chksum_done)
+		return ODP_PACKET_CHKSUM_UNKNOWN;
+
+	if (pkt_hdr->p.error_flags.l3_chksum)
+		return ODP_PACKET_CHKSUM_BAD;
+
+	return ODP_PACKET_CHKSUM_OK;
+}
+
+odp_packet_chksum_status_t odp_packet_l4_chksum_status(odp_packet_t pkt)
+{
+	odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
+
+	if (!pkt_hdr->p.input_flags.l4_chksum_done)
+		return ODP_PACKET_CHKSUM_UNKNOWN;
+
+	if (pkt_hdr->p.error_flags.l4_chksum)
+		return ODP_PACKET_CHKSUM_BAD;
+
+	return ODP_PACKET_CHKSUM_OK;
+}
+
 void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash)
 {
 	odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);