Re: [lng-odp] [PATCH 1/3] linux-gen: packet: enable parsing only selected packet header layers

2016-10-24 Thread Maxim Uvarov

Merged,
Maxim.

On 10/24/16 14:48, Elo, Matias (Nokia - FI/Espoo) wrote:

Ping. This patch set has been reviewed and tested.

-Matias


On 21 Sep 2016, at 22.36, Bill Fischofer 
> wrote:

For this series:

Reviewed-and-tested-by: Bill Fischofer 
>

On Tue, Sep 13, 2016 at 9:30 AM, Matias Elo 
> wrote:
Enable parsing packet headers up to a given protocol layer.

Signed-off-by: Matias Elo >
---
  .../linux-generic/include/odp_packet_internal.h|  24 +-
  platform/linux-generic/odp_classification.c|   2 +-
  platform/linux-generic/odp_packet.c| 293 -
  3 files changed, 193 insertions(+), 126 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index 392d670..9b4f59e 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -41,7 +41,6 @@ typedef union {

 struct {
 uint64_t parsed_l2:1; /**< L2 parsed */
-   uint64_t parsed_all:1;/**< Parsing complete */
 uint64_t dst_queue:1; /**< Dst queue present */

 uint64_t flow_hash:1; /**< Flow hash present */
@@ -131,6 +130,18 @@ ODP_STATIC_ASSERT(sizeof(output_flags_t) == 
sizeof(uint32_t),
   "OUTPUT_FLAGS_SIZE_ERROR");

  /**
+ * Protocol stack layers
+ */
+typedef enum {
+   LAYER_NONE = 0,
+   LAYER_L1,
+   LAYER_L2,
+   LAYER_L3,
+   LAYER_L4,
+   LAYER_ALL
+} layer_t;
+
+/**
   * Packet parser metadata
   */
  typedef struct {
@@ -145,6 +156,10 @@ typedef struct {
 uint32_t l3_len;/**< Layer 3 length */
 uint32_t l4_len;/**< Layer 4 length */

+   layer_t parsed_layers;  /**< Highest parsed protocol stack layer */
+   uint16_t ethtype;   /**< EtherType */
+   uint8_t ip_proto;   /**< IP protocol */
+
  } packet_parser_t;

  /**
@@ -300,7 +315,7 @@ static inline int packet_parse_l2_not_done(packet_parser_t 
*prs)

  static inline int packet_parse_not_complete(odp_packet_hdr_t *pkt_hdr)
  {
-   return !pkt_hdr->p.input_flags.parsed_all;
+   return pkt_hdr->p.parsed_layers != LAYER_ALL;
  }

  /* Forward declarations */
@@ -316,6 +331,9 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t 
frame_len);
  /* Perform full packet parse */
  int packet_parse_full(odp_packet_hdr_t *pkt_hdr);

+/* Perform packet parse up to a given protocol layer */
+int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, layer_t layer);
+
  /* Reset parser metadata for a new parse */
  void packet_parse_reset(odp_packet_hdr_t *pkt_hdr);

@@ -349,7 +367,7 @@ static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, 
odp_time_t *ts)
  }

  int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr,
-   uint32_t pkt_len, uint32_t seg_len);
+   uint32_t pkt_len, uint32_t seg_len, layer_t layer);

  int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);

diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index ea223bf..868058d 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -821,7 +821,7 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t 
*base,
 packet_parse_reset(pkt_hdr);
 packet_set_len(pkt_hdr, pkt_len);

-   packet_parse_common(_hdr->p, base, pkt_len, seg_len);
+   packet_parse_common(_hdr->p, base, pkt_len, seg_len, LAYER_ALL);
 cos = cls_select_cos(entry, base, pkt_hdr);

 if (cos == NULL)
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index c4cf324..5f84869 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -30,12 +30,13 @@
  static inline void packet_parse_disable(odp_packet_hdr_t *pkt_hdr)
  {
 pkt_hdr->p.input_flags.parsed_l2  = 1;
-   pkt_hdr->p.input_flags.parsed_all = 1;
+   pkt_hdr->p.parsed_layers = LAYER_ALL;
  }

  void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
  {
 /* Reset parser metadata before new parse */
+   pkt_hdr->p.parsed_layers= LAYER_NONE;
 pkt_hdr->p.error_flags.all  = 0;
 pkt_hdr->p.input_flags.all  = 0;
 pkt_hdr->p.output_flags.all = 0;
@@ -50,6 +51,8 @@ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
  static void packet_init(pool_entry_t *pool, odp_packet_hdr_t *pkt_hdr,
 size_t size, int parse)
  {
+   pkt_hdr->p.parsed_layers= LAYER_NONE;
+
 pkt_hdr->p.input_flags.all  = 0;
 pkt_hdr->p.output_flags.all = 0;
 pkt_hdr->p.error_flags.all  = 0;
@@ -1166,151 

Re: [lng-odp] [PATCH 1/3] linux-gen: packet: enable parsing only selected packet header layers

2016-10-24 Thread Elo, Matias (Nokia - FI/Espoo)
Ping. This patch set has been reviewed and tested.

-Matias


On 21 Sep 2016, at 22.36, Bill Fischofer 
> wrote:

For this series:

Reviewed-and-tested-by: Bill Fischofer 
>

On Tue, Sep 13, 2016 at 9:30 AM, Matias Elo 
> wrote:
Enable parsing packet headers up to a given protocol layer.

Signed-off-by: Matias Elo >
---
 .../linux-generic/include/odp_packet_internal.h|  24 +-
 platform/linux-generic/odp_classification.c|   2 +-
 platform/linux-generic/odp_packet.c| 293 -
 3 files changed, 193 insertions(+), 126 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index 392d670..9b4f59e 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -41,7 +41,6 @@ typedef union {

struct {
uint64_t parsed_l2:1; /**< L2 parsed */
-   uint64_t parsed_all:1;/**< Parsing complete */
uint64_t dst_queue:1; /**< Dst queue present */

uint64_t flow_hash:1; /**< Flow hash present */
@@ -131,6 +130,18 @@ ODP_STATIC_ASSERT(sizeof(output_flags_t) == 
sizeof(uint32_t),
  "OUTPUT_FLAGS_SIZE_ERROR");

 /**
+ * Protocol stack layers
+ */
+typedef enum {
+   LAYER_NONE = 0,
+   LAYER_L1,
+   LAYER_L2,
+   LAYER_L3,
+   LAYER_L4,
+   LAYER_ALL
+} layer_t;
+
+/**
  * Packet parser metadata
  */
 typedef struct {
@@ -145,6 +156,10 @@ typedef struct {
uint32_t l3_len;/**< Layer 3 length */
uint32_t l4_len;/**< Layer 4 length */

+   layer_t parsed_layers;  /**< Highest parsed protocol stack layer */
+   uint16_t ethtype;   /**< EtherType */
+   uint8_t ip_proto;   /**< IP protocol */
+
 } packet_parser_t;

 /**
@@ -300,7 +315,7 @@ static inline int packet_parse_l2_not_done(packet_parser_t 
*prs)

 static inline int packet_parse_not_complete(odp_packet_hdr_t *pkt_hdr)
 {
-   return !pkt_hdr->p.input_flags.parsed_all;
+   return pkt_hdr->p.parsed_layers != LAYER_ALL;
 }

 /* Forward declarations */
@@ -316,6 +331,9 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t 
frame_len);
 /* Perform full packet parse */
 int packet_parse_full(odp_packet_hdr_t *pkt_hdr);

+/* Perform packet parse up to a given protocol layer */
+int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, layer_t layer);
+
 /* Reset parser metadata for a new parse */
 void packet_parse_reset(odp_packet_hdr_t *pkt_hdr);

@@ -349,7 +367,7 @@ static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, 
odp_time_t *ts)
 }

 int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr,
-   uint32_t pkt_len, uint32_t seg_len);
+   uint32_t pkt_len, uint32_t seg_len, layer_t layer);

 int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);

diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index ea223bf..868058d 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -821,7 +821,7 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t 
*base,
packet_parse_reset(pkt_hdr);
packet_set_len(pkt_hdr, pkt_len);

-   packet_parse_common(_hdr->p, base, pkt_len, seg_len);
+   packet_parse_common(_hdr->p, base, pkt_len, seg_len, LAYER_ALL);
cos = cls_select_cos(entry, base, pkt_hdr);

if (cos == NULL)
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index c4cf324..5f84869 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -30,12 +30,13 @@
 static inline void packet_parse_disable(odp_packet_hdr_t *pkt_hdr)
 {
pkt_hdr->p.input_flags.parsed_l2  = 1;
-   pkt_hdr->p.input_flags.parsed_all = 1;
+   pkt_hdr->p.parsed_layers = LAYER_ALL;
 }

 void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
 {
/* Reset parser metadata before new parse */
+   pkt_hdr->p.parsed_layers= LAYER_NONE;
pkt_hdr->p.error_flags.all  = 0;
pkt_hdr->p.input_flags.all  = 0;
pkt_hdr->p.output_flags.all = 0;
@@ -50,6 +51,8 @@ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
 static void packet_init(pool_entry_t *pool, odp_packet_hdr_t *pkt_hdr,
size_t size, int parse)
 {
+   pkt_hdr->p.parsed_layers= LAYER_NONE;
+
pkt_hdr->p.input_flags.all  = 0;
pkt_hdr->p.output_flags.all = 0;
pkt_hdr->p.error_flags.all  = 0;
@@ -1166,151 +1169,185 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t 
frame_len)
 }

 /**
- * Parse common packet headers
+ * 

Re: [lng-odp] [PATCH 1/3] linux-gen: packet: enable parsing only selected packet header layers

2016-10-11 Thread Elo, Matias (Nokia - FI/Espoo)
Ping.

-Matias

For this series:

Reviewed-and-tested-by: Bill Fischofer 
>

On Tue, Sep 13, 2016 at 9:30 AM, Matias Elo 
> wrote:
Enable parsing packet headers up to a given protocol layer.

Signed-off-by: Matias Elo >
---
 .../linux-generic/include/odp_packet_internal.h|  24 +-
 platform/linux-generic/odp_classification.c|   2 +-
 platform/linux-generic/odp_packet.c| 293 -
 3 files changed, 193 insertions(+), 126 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_internal.h 
b/platform/linux-generic/include/odp_packet_internal.h
index 392d670..9b4f59e 100644
--- a/platform/linux-generic/include/odp_packet_internal.h
+++ b/platform/linux-generic/include/odp_packet_internal.h
@@ -41,7 +41,6 @@ typedef union {

struct {
uint64_t parsed_l2:1; /**< L2 parsed */
-   uint64_t parsed_all:1;/**< Parsing complete */
uint64_t dst_queue:1; /**< Dst queue present */

uint64_t flow_hash:1; /**< Flow hash present */
@@ -131,6 +130,18 @@ ODP_STATIC_ASSERT(sizeof(output_flags_t) == 
sizeof(uint32_t),
  "OUTPUT_FLAGS_SIZE_ERROR");

 /**
+ * Protocol stack layers
+ */
+typedef enum {
+   LAYER_NONE = 0,
+   LAYER_L1,
+   LAYER_L2,
+   LAYER_L3,
+   LAYER_L4,
+   LAYER_ALL
+} layer_t;
+
+/**
  * Packet parser metadata
  */
 typedef struct {
@@ -145,6 +156,10 @@ typedef struct {
uint32_t l3_len;/**< Layer 3 length */
uint32_t l4_len;/**< Layer 4 length */

+   layer_t parsed_layers;  /**< Highest parsed protocol stack layer */
+   uint16_t ethtype;   /**< EtherType */
+   uint8_t ip_proto;   /**< IP protocol */
+
 } packet_parser_t;

 /**
@@ -300,7 +315,7 @@ static inline int packet_parse_l2_not_done(packet_parser_t 
*prs)

 static inline int packet_parse_not_complete(odp_packet_hdr_t *pkt_hdr)
 {
-   return !pkt_hdr->p.input_flags.parsed_all;
+   return pkt_hdr->p.parsed_layers != LAYER_ALL;
 }

 /* Forward declarations */
@@ -316,6 +331,9 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t 
frame_len);
 /* Perform full packet parse */
 int packet_parse_full(odp_packet_hdr_t *pkt_hdr);

+/* Perform packet parse up to a given protocol layer */
+int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, layer_t layer);
+
 /* Reset parser metadata for a new parse */
 void packet_parse_reset(odp_packet_hdr_t *pkt_hdr);

@@ -349,7 +367,7 @@ static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, 
odp_time_t *ts)
 }

 int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr,
-   uint32_t pkt_len, uint32_t seg_len);
+   uint32_t pkt_len, uint32_t seg_len, layer_t layer);

 int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);

diff --git a/platform/linux-generic/odp_classification.c 
b/platform/linux-generic/odp_classification.c
index ea223bf..868058d 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -821,7 +821,7 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t 
*base,
packet_parse_reset(pkt_hdr);
packet_set_len(pkt_hdr, pkt_len);

-   packet_parse_common(_hdr->p, base, pkt_len, seg_len);
+   packet_parse_common(_hdr->p, base, pkt_len, seg_len, LAYER_ALL);
cos = cls_select_cos(entry, base, pkt_hdr);

if (cos == NULL)
diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index c4cf324..5f84869 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -30,12 +30,13 @@
 static inline void packet_parse_disable(odp_packet_hdr_t *pkt_hdr)
 {
pkt_hdr->p.input_flags.parsed_l2  = 1;
-   pkt_hdr->p.input_flags.parsed_all = 1;
+   pkt_hdr->p.parsed_layers = LAYER_ALL;
 }

 void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
 {
/* Reset parser metadata before new parse */
+   pkt_hdr->p.parsed_layers= LAYER_NONE;
pkt_hdr->p.error_flags.all  = 0;
pkt_hdr->p.input_flags.all  = 0;
pkt_hdr->p.output_flags.all = 0;
@@ -50,6 +51,8 @@ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
 static void packet_init(pool_entry_t *pool, odp_packet_hdr_t *pkt_hdr,
size_t size, int parse)
 {
+   pkt_hdr->p.parsed_layers= LAYER_NONE;
+
pkt_hdr->p.input_flags.all  = 0;
pkt_hdr->p.output_flags.all = 0;
pkt_hdr->p.error_flags.all  = 0;
@@ -1166,151 +1169,185 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t 
frame_len)
 }

 /**
- * Parse common packet headers
+ * Parse common packet headers up to given layer
  *
  * The function expects at least PACKET_PARSE_SEG_LEN bytes of data to be
  * available from the ptr.
  */
 

Re: [lng-odp] [PATCH 1/3] linux-gen: packet: enable parsing only selected packet header layers

2016-09-21 Thread Bill Fischofer
For this series:

Reviewed-and-tested-by: Bill Fischofer 

On Tue, Sep 13, 2016 at 9:30 AM, Matias Elo  wrote:

> Enable parsing packet headers up to a given protocol layer.
>
> Signed-off-by: Matias Elo 
> ---
>  .../linux-generic/include/odp_packet_internal.h|  24 +-
>  platform/linux-generic/odp_classification.c|   2 +-
>  platform/linux-generic/odp_packet.c| 293
> -
>  3 files changed, 193 insertions(+), 126 deletions(-)
>
> diff --git a/platform/linux-generic/include/odp_packet_internal.h
> b/platform/linux-generic/include/odp_packet_internal.h
> index 392d670..9b4f59e 100644
> --- a/platform/linux-generic/include/odp_packet_internal.h
> +++ b/platform/linux-generic/include/odp_packet_internal.h
> @@ -41,7 +41,6 @@ typedef union {
>
> struct {
> uint64_t parsed_l2:1; /**< L2 parsed */
> -   uint64_t parsed_all:1;/**< Parsing complete */
> uint64_t dst_queue:1; /**< Dst queue present */
>
> uint64_t flow_hash:1; /**< Flow hash present */
> @@ -131,6 +130,18 @@ ODP_STATIC_ASSERT(sizeof(output_flags_t) ==
> sizeof(uint32_t),
>   "OUTPUT_FLAGS_SIZE_ERROR");
>
>  /**
> + * Protocol stack layers
> + */
> +typedef enum {
> +   LAYER_NONE = 0,
> +   LAYER_L1,
> +   LAYER_L2,
> +   LAYER_L3,
> +   LAYER_L4,
> +   LAYER_ALL
> +} layer_t;
> +
> +/**
>   * Packet parser metadata
>   */
>  typedef struct {
> @@ -145,6 +156,10 @@ typedef struct {
> uint32_t l3_len;/**< Layer 3 length */
> uint32_t l4_len;/**< Layer 4 length */
>
> +   layer_t parsed_layers;  /**< Highest parsed protocol stack layer */
> +   uint16_t ethtype;   /**< EtherType */
> +   uint8_t ip_proto;   /**< IP protocol */
> +
>  } packet_parser_t;
>
>  /**
> @@ -300,7 +315,7 @@ static inline int packet_parse_l2_not_done(packet_parser_t
> *prs)
>
>  static inline int packet_parse_not_complete(odp_packet_hdr_t *pkt_hdr)
>  {
> -   return !pkt_hdr->p.input_flags.parsed_all;
> +   return pkt_hdr->p.parsed_layers != LAYER_ALL;
>  }
>
>  /* Forward declarations */
> @@ -316,6 +331,9 @@ void packet_parse_l2(packet_parser_t *prs, uint32_t
> frame_len);
>  /* Perform full packet parse */
>  int packet_parse_full(odp_packet_hdr_t *pkt_hdr);
>
> +/* Perform packet parse up to a given protocol layer */
> +int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, layer_t layer);
> +
>  /* Reset parser metadata for a new parse */
>  void packet_parse_reset(odp_packet_hdr_t *pkt_hdr);
>
> @@ -349,7 +367,7 @@ static inline void packet_set_ts(odp_packet_hdr_t
> *pkt_hdr, odp_time_t *ts)
>  }
>
>  int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr,
> -   uint32_t pkt_len, uint32_t seg_len);
> +   uint32_t pkt_len, uint32_t seg_len, layer_t layer);
>
>  int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr);
>
> diff --git a/platform/linux-generic/odp_classification.c
> b/platform/linux-generic/odp_classification.c
> index ea223bf..868058d 100644
> --- a/platform/linux-generic/odp_classification.c
> +++ b/platform/linux-generic/odp_classification.c
> @@ -821,7 +821,7 @@ int cls_classify_packet(pktio_entry_t *entry, const
> uint8_t *base,
> packet_parse_reset(pkt_hdr);
> packet_set_len(pkt_hdr, pkt_len);
>
> -   packet_parse_common(_hdr->p, base, pkt_len, seg_len);
> +   packet_parse_common(_hdr->p, base, pkt_len, seg_len,
> LAYER_ALL);
> cos = cls_select_cos(entry, base, pkt_hdr);
>
> if (cos == NULL)
> diff --git a/platform/linux-generic/odp_packet.c
> b/platform/linux-generic/odp_packet.c
> index c4cf324..5f84869 100644
> --- a/platform/linux-generic/odp_packet.c
> +++ b/platform/linux-generic/odp_packet.c
> @@ -30,12 +30,13 @@
>  static inline void packet_parse_disable(odp_packet_hdr_t *pkt_hdr)
>  {
> pkt_hdr->p.input_flags.parsed_l2  = 1;
> -   pkt_hdr->p.input_flags.parsed_all = 1;
> +   pkt_hdr->p.parsed_layers = LAYER_ALL;
>  }
>
>  void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
>  {
> /* Reset parser metadata before new parse */
> +   pkt_hdr->p.parsed_layers= LAYER_NONE;
> pkt_hdr->p.error_flags.all  = 0;
> pkt_hdr->p.input_flags.all  = 0;
> pkt_hdr->p.output_flags.all = 0;
> @@ -50,6 +51,8 @@ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr)
>  static void packet_init(pool_entry_t *pool, odp_packet_hdr_t *pkt_hdr,
> size_t size, int parse)
>  {
> +   pkt_hdr->p.parsed_layers= LAYER_NONE;
> +
> pkt_hdr->p.input_flags.all  = 0;
> pkt_hdr->p.output_flags.all = 0;
> pkt_hdr->p.error_flags.all  = 0;
> @@ -1166,151 +1169,185 @@ void packet_parse_l2(packet_parser_t *prs,
> uint32_t frame_len)
>  }
>
>  /**
> - * Parse common packet headers
> + * Parse common packet