diff mbox

api: packet: add detailed packet error api

Message ID 1447743975-12255-1-git-send-email-bala.manoharan@linaro.org
State Superseded
Headers show

Commit Message

Balasubramanian Manoharan Nov. 17, 2015, 7:06 a.m. UTC
Adds api to get packet error flags for L2, L3 and L4 errors.

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
 include/odp/api/packet_flags.h            | 33 +++++++++++++++++++++++++++++++
 platform/linux-generic/odp_packet_flags.c | 32 ++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)

Comments

Balasubramanian Manoharan Dec. 15, 2015, 1:07 p.m. UTC | #1
PIng

On 17 November 2015 at 12:36, Balasubramanian Manoharan
<bala.manoharan@linaro.org> wrote:
> Adds api to get packet error flags for L2, L3 and L4 errors.
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
>  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
> + *
> + * @param pkt Packet handle
> + * @retval non-zero packet has L2 errors
> + * @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
> + */
> +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);
> +
> +       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);
> --
> 1.9.1
>
Bill Fischofer Dec. 17, 2015, 3:38 a.m. UTC | #2
This should be marked API-NEXT, but assuming that can be fixed during
merge...

On Tue, Nov 17, 2015 at 1:06 AM, Balasubramanian Manoharan <
bala.manoharan@linaro.org> wrote:

> Adds api to get packet error flags for L2, L3 and L4 errors.

>

> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

>


Reviewed-and-Tested-by: Bill Fischofer <bill.fischofer@linaro.org>


> ---

>  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

> + *

> + * @param pkt Packet handle

> + * @retval non-zero packet has L2 errors

> + * @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

> + */

> +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);

> +

> +       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);

> --

> 1.9.1

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>
Maxim Uvarov Dec. 17, 2015, 8:57 a.m. UTC | #3
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 <bala.manoharan@linaro.org>
> ---
>   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);
diff mbox

Patch

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
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L2 errors
+ * @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
+ */
+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);
+
+	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);