diff mbox

[API-NEXT,PATCHv2] api: packet: add detailed packet error flags

Message ID 1451983867-7025-1-git-send-email-bala.manoharan@linaro.org
State Accepted
Commit 23cdfbd1b93ceaf4cadacf849e6536056a2d2368
Headers show

Commit Message

Balasubramanian Manoharan Jan. 5, 2016, 8:51 a.m. UTC
Additional APIs to get packet error flags for L2, L3 and L4 errors.

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
---
v2: Incorporates review comments from Petri

 include/odp/api/packet_flags.h            | 33 +++++++++++++++++++++++++++++++
 platform/linux-generic/odp_packet_flags.c | 30 ++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)

Comments

Mike Holmes Jan. 6, 2016, 1:23 p.m. UTC | #1
Merged.

Bala, are you planning on sending validation tests and user-guide
documentation shortly or should we generate a story to do that ?

Mike

On 5 January 2016 at 06:06, Savolainen, Petri (Nokia - FI/Espoo) <
petri.savolainen@nokia.com> wrote:

> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>

>

>

> > -----Original Message-----

> > From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of EXT

> > Balasubramanian Manoharan

> > Sent: Tuesday, January 05, 2016 10:51 AM

> > To: lng-odp@lists.linaro.org

> > Subject: [lng-odp] [API-NEXT PATCHv2] api: packet: add detailed packet

> > error flags

> >

> > Additional APIs to get packet error flags for L2, L3 and L4 errors.

> >

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

> > ---

> > v2: Incorporates review comments from Petri

> >

> >  include/odp/api/packet_flags.h            | 33

> > +++++++++++++++++++++++++++++++

> >  platform/linux-generic/odp_packet_flags.c | 30

> > ++++++++++++++++++++++++++++

> >  2 files changed, 63 insertions(+)

> >

> > diff --git a/include/odp/api/packet_flags.h

> > b/include/odp/api/packet_flags.h

> > index 7c3b247..8de0c82 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 errors

> > + *

> > + * check 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 errors

> > + *

> > + * check 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 errors

> > + *

> > + * check for all L4 errors

> > + *

> > + * @param pkt Packet handle

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

> > + * @retval 0 packet has no L4 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 3537aa9..ae9a9ed 100644

> > --- a/platform/linux-generic/odp_packet_flags.c

> > +++ b/platform/linux-generic/odp_packet_flags.c

> > @@ -38,16 +38,46 @@ 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);

> > +     /* L2 parsing is always done by default and hence

> > +     no additional check is required */

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

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

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

>




-- 
Mike Holmes
Technical Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
Balasubramanian Manoharan Jan. 6, 2016, 2:03 p.m. UTC | #2
Hi Mike,

Thanks for Merging the patch.
I will send them soon.

Regards,
Bala
Regards,
Bala


On 6 January 2016 at 18:53, Mike Holmes <mike.holmes@linaro.org> wrote:
> Merged.
>
> Bala, are you planning on sending validation tests and user-guide
> documentation shortly or should we generate a story to do that ?
>
> Mike
>
> On 5 January 2016 at 06:06, Savolainen, Petri (Nokia - FI/Espoo)
> <petri.savolainen@nokia.com> wrote:
>>
>> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com>
>>
>>
>> > -----Original Message-----
>> > From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of EXT
>> > Balasubramanian Manoharan
>> > Sent: Tuesday, January 05, 2016 10:51 AM
>> > To: lng-odp@lists.linaro.org
>> > Subject: [lng-odp] [API-NEXT PATCHv2] api: packet: add detailed packet
>> > error flags
>> >
>> > Additional APIs to get packet error flags for L2, L3 and L4 errors.
>> >
>> > Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
>> > ---
>> > v2: Incorporates review comments from Petri
>> >
>> >  include/odp/api/packet_flags.h            | 33
>> > +++++++++++++++++++++++++++++++
>> >  platform/linux-generic/odp_packet_flags.c | 30
>> > ++++++++++++++++++++++++++++
>> >  2 files changed, 63 insertions(+)
>> >
>> > diff --git a/include/odp/api/packet_flags.h
>> > b/include/odp/api/packet_flags.h
>> > index 7c3b247..8de0c82 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 errors
>> > + *
>> > + * check 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 errors
>> > + *
>> > + * check 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 errors
>> > + *
>> > + * check for all L4 errors
>> > + *
>> > + * @param pkt Packet handle
>> > + * @retval non-zero packet has L4 errors
>> > + * @retval 0 packet has no L4 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 3537aa9..ae9a9ed 100644
>> > --- a/platform/linux-generic/odp_packet_flags.c
>> > +++ b/platform/linux-generic/odp_packet_flags.c
>> > @@ -38,16 +38,46 @@ 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);
>> > +     /* L2 parsing is always done by default and hence
>> > +     no additional check is required */
>> > +     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
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> --
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org │ Open source software for ARM SoCs
>
>
diff mbox

Patch

diff --git a/include/odp/api/packet_flags.h b/include/odp/api/packet_flags.h
index 7c3b247..8de0c82 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 errors
+ *
+ * check 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 errors
+ *
+ * check 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 errors
+ *
+ * check for all L4 errors
+ *
+ * @param pkt Packet handle
+ * @retval non-zero packet has L4 errors
+ * @retval 0 packet has no L4 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 3537aa9..ae9a9ed 100644
--- a/platform/linux-generic/odp_packet_flags.c
+++ b/platform/linux-generic/odp_packet_flags.c
@@ -38,16 +38,46 @@  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);
+	/* L2 parsing is always done by default and hence
+	no additional check is required */
+	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);