diff mbox series

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

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

Commit Message

Github ODP bot Aug. 10, 2018, 1 p.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: 9b2b5a9695ad66977c964c83691cd2fef4c45b85
 ** Merge commit sha: 2f50c6c282fb183ddbc4628815da441de53deea0
 **/
 include/odp/api/spec/packet.h | 120 ++++++++++++++++++++++++++++++++++
 1 file changed, 120 insertions(+)
diff mbox series

Patch

diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h
index 66665e121..fe341bd4f 100644
--- a/include/odp/api/spec/packet.h
+++ b/include/odp/api/spec/packet.h
@@ -1415,6 +1415,126 @@  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);
 
+/** 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;
+
+/** 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
  *