diff mbox series

[API-NEXT,v3,1/4] api: packet: add parse result call

Message ID 1534759208-15203-2-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>


This enables application to read all commonly used packet parser
results with a single function call. This may improve performance
when multiple results are needed, especially in ABI compatible
builds where function inlining is likely disabled.

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
 **/
 include/odp/api/abi-default/packet.h          | 64 +++++++++++++++++++
 include/odp/api/spec/packet.h                 | 56 ++++++++++++++++
 .../include-abi/odp/api/abi/packet.h          | 35 ++++++++++
 3 files changed, 155 insertions(+)
diff mbox series

Patch

diff --git a/include/odp/api/abi-default/packet.h b/include/odp/api/abi-default/packet.h
index 97c0d0883..d3bd5f6e4 100644
--- a/include/odp/api/abi-default/packet.h
+++ b/include/odp/api/abi-default/packet.h
@@ -72,6 +72,70 @@  typedef enum {
 
 #define ODP_NUM_PACKET_COLORS 3
 
+/** Parse result flags */
+typedef struct odp_packet_parse_result_flag_t {
+	/** Flags union */
+	union {
+		/** All flags as a 64 bit word */
+		uint64_t all;
+
+		/** Flags as a bitfield struct */
+		struct {
+			/** @see odp_packet_has_error() */
+			uint64_t has_error    : 1;
+			/** @see odp_packet_has_l2_error() */
+			uint64_t has_l2_error : 1;
+			/** @see odp_packet_has_l3_error() */
+			uint64_t has_l3_error : 1;
+			/** @see odp_packet_has_l4_error() */
+			uint64_t has_l4_error : 1;
+			/** @see odp_packet_has_l2() */
+			uint64_t has_l2 : 1;
+			/** @see odp_packet_has_l3() */
+			uint64_t has_l3 : 1;
+			/** @see odp_packet_has_l4() */
+			uint64_t has_l4 : 1;
+			/** @see odp_packet_has_eth() */
+			uint64_t has_eth : 1;
+			/** @see odp_packet_has_eth_bcast() */
+			uint64_t has_eth_bcast : 1;
+			/** @see odp_packet_has_eth_mcast() */
+			uint64_t has_eth_mcast : 1;
+			/** @see odp_packet_has_jumbo() */
+			uint64_t has_jumbo : 1;
+			/** @see odp_packet_has_vlan() */
+			uint64_t has_vlan : 1;
+			/** @see odp_packet_has_vlan_qinq() */
+			uint64_t has_vlan_qinq : 1;
+			/** @see odp_packet_has_arp() */
+			uint64_t has_arp : 1;
+			/** @see odp_packet_has_ipv4() */
+			uint64_t has_ipv4 : 1;
+			/** @see odp_packet_has_ipv6() */
+			uint64_t has_ipv6 : 1;
+			/** @see odp_packet_has_ip_bcast() */
+			uint64_t has_ip_bcast : 1;
+			/** @see odp_packet_has_ip_mcast() */
+			uint64_t has_ip_mcast : 1;
+			/** @see odp_packet_has_ipfrag() */
+			uint64_t has_ipfrag : 1;
+			/** @see odp_packet_has_ipopt() */
+			uint64_t has_ipopt : 1;
+			/** @see odp_packet_has_ipsec() */
+			uint64_t has_ipsec : 1;
+			/** @see odp_packet_has_udp() */
+			uint64_t has_udp : 1;
+			/** @see odp_packet_has_tcp() */
+			uint64_t has_tcp : 1;
+			/** @see odp_packet_has_sctp() */
+			uint64_t has_sctp : 1;
+			/** @see odp_packet_has_icmp() */
+			uint64_t has_icmp : 1;
+		};
+	};
+
+} odp_packet_parse_result_flag_t;
+
 /**
  * @}
  */
diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 78e519ac3..3fd571a38 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -1428,6 +1428,62 @@  int odp_packet_parse(odp_packet_t pkt, uint32_t offset,
 int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[],
 			   int num, const odp_packet_parse_param_t *param);
 
+/** Packet parse results */
+typedef struct odp_packet_parse_result_t {
+	/** Parse result flags */
+	odp_packet_parse_result_flag_t flag;
+
+	/** @see odp_packet_len() */
+	uint32_t packet_len;
+
+	/** @see odp_packet_l2_offset() */
+	uint32_t l2_offset;
+	/** @see odp_packet_l3_offset() */
+	uint32_t l3_offset;
+	/** @see odp_packet_l4_offset() */
+	uint32_t l4_offset;
+
+	/** @see odp_packet_l3_chksum_status() */
+	odp_packet_chksum_status_t l3_chksum_status;
+	/** @see odp_packet_l4_chksum_status() */
+	odp_packet_chksum_status_t l4_chksum_status;
+
+	/** @see odp_packet_l2_type() */
+	odp_proto_l2_type_t l2_type;
+	/** @see odp_packet_l3_type() */
+	odp_proto_l3_type_t l3_type;
+	/** @see odp_packet_l4_type() */
+	odp_proto_l4_type_t l4_type;
+
+} odp_packet_parse_result_t;
+
+/**
+ * Read parse results
+ *
+ * Read out the most commonly used packet parse results. The same information is
+ * available through individual function calls, but this call may be more
+ * efficient when reading multiple results from a packet.
+ *
+ * @param      pkt     Packet handle
+ * @param[out] result  Pointer for parse result output
+ */
+void odp_packet_parse_result(odp_packet_t pkt,
+			     odp_packet_parse_result_t *result);
+
+/**
+ * Read parse results from multiple packets
+ *
+ * Otherwise same functionality as odp_packet_parse_result() but handles
+ * multiple packets.
+ *
+ * @param      pkt     Packet handle array
+ * @param[out] result  Parse result array for output
+ * @param      num     Number of packets and results
+ */
+void odp_packet_parse_result_multi(const odp_packet_t pkt[],
+				   odp_packet_parse_result_t *result[],
+				   int num);
+
 /**
  * Packet pool
  *
diff --git a/platform/linux-generic/include-abi/odp/api/abi/packet.h b/platform/linux-generic/include-abi/odp/api/abi/packet.h
index fe21c7d9f..e11aed978 100644
--- a/platform/linux-generic/include-abi/odp/api/abi/packet.h
+++ b/platform/linux-generic/include-abi/odp/api/abi/packet.h
@@ -89,6 +89,41 @@  typedef enum {
 
 #define ODP_NUM_PACKET_COLORS 3
 
+typedef struct odp_packet_parse_result_flag_t {
+	union {
+		uint64_t all;
+
+		struct {
+			uint64_t has_error    : 1;
+			uint64_t has_l2_error : 1;
+			uint64_t has_l3_error : 1;
+			uint64_t has_l4_error : 1;
+			uint64_t has_l2 : 1;
+			uint64_t has_l3 : 1;
+			uint64_t has_l4 : 1;
+			uint64_t has_eth : 1;
+			uint64_t has_eth_bcast : 1;
+			uint64_t has_eth_mcast : 1;
+			uint64_t has_jumbo : 1;
+			uint64_t has_vlan : 1;
+			uint64_t has_vlan_qinq : 1;
+			uint64_t has_arp : 1;
+			uint64_t has_ipv4 : 1;
+			uint64_t has_ipv6 : 1;
+			uint64_t has_ip_bcast : 1;
+			uint64_t has_ip_mcast : 1;
+			uint64_t has_ipfrag : 1;
+			uint64_t has_ipopt : 1;
+			uint64_t has_ipsec : 1;
+			uint64_t has_udp : 1;
+			uint64_t has_tcp : 1;
+			uint64_t has_sctp : 1;
+			uint64_t has_icmp : 1;
+		};
+	};
+
+} odp_packet_parse_result_flag_t;
+
 #include <odp/api/plat/packet_inlines.h>
 
 /**