Petri,

Please also review API change.

On 11/17/2015 10:06, Balasubramanian Manoharan wrote:
Adds api to get packet error flags for L2, L3 and L4 errors.

Signed-off-by: Balasubramanian Manoharan <[email protected]>
---
  include/odp/api/packet_flags.h            | 33 +++++++++++++++++++++++++++++++
  platform/linux-generic/odp_packet_flags.c | 32 ++++++++++++++++++++++++++++++
  2 files changed, 65 insertions(+)

diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h
index 7c3b247..c4a6832 100644
--- a/include/odp/api/packet_flags.h
+++ b/include/odp/api/packet_flags.h
@@ -38,6 +38,17 @@ extern "C" {
  int odp_packet_has_error(odp_packet_t pkt);
/**
+ * check for packet L2 error
+ *
+ * checks for all L2 errors
I think no need to duplicated description.
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L2 errors
<0 ?
+ * @retval 0 packet has no L2 error
+ */
+int odp_packet_has_l2_error(odp_packet_t pkt);
+
+/**
   * Check for L2 header, e.g. ethernet
   *
   * @param pkt Packet handle
@@ -47,6 +58,17 @@ int odp_packet_has_error(odp_packet_t pkt);
  int odp_packet_has_l2(odp_packet_t pkt);
/**
+ * check for packet L3 error
+ *
+ * checks for all L3 errors
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L3 errors
+ * @retval 0 packet has no L3 error
+ */
+int odp_packet_has_l3_error(odp_packet_t pkt);
+
+/**
   * Check for L3 header, e.g. IPv4, IPv6
   *
   * @param pkt Packet handle
@@ -56,6 +78,17 @@ int odp_packet_has_l2(odp_packet_t pkt);
  int odp_packet_has_l3(odp_packet_t pkt);
/**
+ * check for packet L4 error
+ *
+ * checks for all L4 errors
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L4 errors
+ * @retval 0 packet has no L2 error
L4
+ */
+int odp_packet_has_l4_error(odp_packet_t pkt);
+
+/**
   * Check for L4 header, e.g. UDP, TCP, SCTP (also ICMP)
   *
   * @param pkt Packet handle
diff --git a/platform/linux-generic/odp_packet_flags.c 
b/platform/linux-generic/odp_packet_flags.c
index dbc3137..68a79bc 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -38,16 +38,48 @@ int odp_packet_has_l2(odp_packet_t pkt)
        return pkt_hdr->input_flags.l2;
  }
+int odp_packet_has_l2_error(odp_packet_t pkt)
+{
+       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+       if (packet_parse_not_complete(pkt_hdr))
+               packet_parse_full(pkt_hdr);
+

why not packet_parse_l2()?

+       return pkt_hdr->error_flags.frame_len
+               | pkt_hdr->error_flags.snap_len
+               | pkt_hdr->error_flags.l2_chksum;
+}
+
  int odp_packet_has_l3(odp_packet_t pkt)
  {
        retflag(pkt, input_flags.l3);
  }
+int odp_packet_has_l3_error(odp_packet_t pkt)
+{
+       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+       if (packet_parse_not_complete(pkt_hdr))
+               packet_parse_full(pkt_hdr);
+
+       return pkt_hdr->error_flags.ip_err;
+}
+
  int odp_packet_has_l4(odp_packet_t pkt)
  {
        retflag(pkt, input_flags.l4);
  }
+int odp_packet_has_l4_error(odp_packet_t pkt)
+{
+       odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);
+
+       if (packet_parse_not_complete(pkt_hdr))
+               packet_parse_full(pkt_hdr);
+
+       return pkt_hdr->error_flags.tcp_err | pkt_hdr->error_flags.udp_err;
+}
+
  int odp_packet_has_eth(odp_packet_t pkt)
  {
        odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt);

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to