diff mbox series

[API-NEXT,v3,2/4] linux-gen: packet: implement packet result calls

Message ID 1534759208-15203-3-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v3,1/4] api: packet: add parse result call | expand

Commit Message

Github ODP bot Aug. 20, 2018, 10 a.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Simple implementation of the new packet result calls. Especially,
flag copy needs to be optimized by storing flag bits directly into
API defined format (packet_parse_result_flag_t) in the packet
header.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 672 (psavol:next-packet-metadata)
 ** https://github.com/Linaro/odp/pull/672
 ** Patch: https://github.com/Linaro/odp/pull/672.patch
 ** Base sha: 2722279b31b075586551801eb2860687ff966ea8
 ** Merge commit sha: e76448d8a8f2575ab3a4c445be84d19f055cbf2d
 **/
 platform/linux-generic/odp_packet.c | 53 +++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 7bb93e1e1..0df32d1c8 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2732,6 +2732,59 @@  int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[],
 	return num;
 }
 
+void odp_packet_parse_result(odp_packet_t pkt,
+			     odp_packet_parse_result_t *result)
+{
+	/* TODO: optimize to single word copy when packet header stores bits
+	 * directly into odp_packet_parse_result_flag_t */
+	result->flag.all           = 0;
+	result->flag.has_error     = odp_packet_has_error(pkt);
+	result->flag.has_l2_error  = odp_packet_has_l2_error(pkt);
+	result->flag.has_l3_error  = odp_packet_has_l3_error(pkt);
+	result->flag.has_l4_error  = odp_packet_has_l4_error(pkt);
+	result->flag.has_l2        = odp_packet_has_l2(pkt);
+	result->flag.has_l3        = odp_packet_has_l3(pkt);
+	result->flag.has_l4        = odp_packet_has_l4(pkt);
+	result->flag.has_eth       = odp_packet_has_eth(pkt);
+	result->flag.has_eth_bcast = odp_packet_has_eth_bcast(pkt);
+	result->flag.has_eth_mcast = odp_packet_has_eth_mcast(pkt);
+	result->flag.has_jumbo     = odp_packet_has_jumbo(pkt);
+	result->flag.has_vlan      = odp_packet_has_vlan(pkt);
+	result->flag.has_vlan_qinq = odp_packet_has_vlan_qinq(pkt);
+	result->flag.has_arp       = odp_packet_has_arp(pkt);
+	result->flag.has_ipv4      = odp_packet_has_ipv4(pkt);
+	result->flag.has_ipv6      = odp_packet_has_ipv6(pkt);
+	result->flag.has_ip_bcast  = odp_packet_has_ip_bcast(pkt);
+	result->flag.has_ip_mcast  = odp_packet_has_ip_mcast(pkt);
+	result->flag.has_ipfrag    = odp_packet_has_ipfrag(pkt);
+	result->flag.has_ipopt     = odp_packet_has_ipopt(pkt);
+	result->flag.has_ipsec     = odp_packet_has_ipsec(pkt);
+	result->flag.has_udp       = odp_packet_has_udp(pkt);
+	result->flag.has_tcp       = odp_packet_has_tcp(pkt);
+	result->flag.has_sctp      = odp_packet_has_sctp(pkt);
+	result->flag.has_icmp      = odp_packet_has_icmp(pkt);
+
+	result->packet_len       = odp_packet_len(pkt);
+	result->l2_offset        = odp_packet_l2_offset(pkt);
+	result->l3_offset        = odp_packet_l3_offset(pkt);
+	result->l4_offset        = odp_packet_l4_offset(pkt);
+	result->l3_chksum_status = odp_packet_l3_chksum_status(pkt);
+	result->l4_chksum_status = odp_packet_l4_chksum_status(pkt);
+	result->l2_type          = odp_packet_l2_type(pkt);
+	result->l3_type          = odp_packet_l3_type(pkt);
+	result->l4_type          = odp_packet_l4_type(pkt);
+}
+
+void odp_packet_parse_result_multi(const odp_packet_t pkt[],
+				   odp_packet_parse_result_t *result[],
+				   int num)
+{
+	int i;
+
+	for (i = 0; i < num; i++)
+		odp_packet_parse_result(pkt[i], result[i]);
+}
+
 uint64_t odp_packet_to_u64(odp_packet_t hdl)
 {
 	return _odp_pri(hdl);