Re: [lng-odp] [PATCH 1/2] linux-gen: packet: remove unnecessary packet reparsing

2017-02-27 Thread Elo, Matias (Nokia - FI/Espoo)
Ping.

> On 15 Feb 2017, at 18:01, Matias Elo  wrote:
> 
> Previously the highest already parsed layer was unnecessarily reparsed on
> the following packet_parse_common() calls.
> 
> Signed-off-by: Matias Elo 
> ---
> platform/linux-generic/odp_packet.c | 22 +++---
> 1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/platform/linux-generic/odp_packet.c 
> b/platform/linux-generic/odp_packet.c
> index 024f694..a6cf4cd 100644
> --- a/platform/linux-generic/odp_packet.c
> +++ b/platform/linux-generic/odp_packet.c
> @@ -2022,12 +2022,15 @@ int packet_parse_common(packet_parser_t *prs, const 
> uint8_t *ptr,
>   case LAYER_NONE:
>   /* Fall through */
> 
> - case LAYER_L2:
> + case LAYER_L1:
>   {
>   const _odp_ethhdr_t *eth;
>   uint16_t macaddr0, macaddr2, macaddr4;
>   const _odp_vlanhdr_t *vlan;
> 
> + if (layer <= LAYER_L1)
> + return prs->error_flags.all != 0;
> +
>   offset = sizeof(_odp_ethhdr_t);
>   if (packet_parse_l2_not_done(prs))
>   packet_parse_l2(prs, frame_len);
> @@ -2091,13 +2094,14 @@ int packet_parse_common(packet_parser_t *prs, const 
> uint8_t *ptr,
> 
>   prs->l3_offset = offset;
>   prs->parsed_layers = LAYER_L2;
> - if (layer == LAYER_L2)
> - return prs->error_flags.all != 0;
>   }
>   /* Fall through */
> 
> - case LAYER_L3:
> + case LAYER_L2:
>   {
> + if (layer <= LAYER_L2)
> + return prs->error_flags.all != 0;
> +
>   offset = prs->l3_offset;
>   parseptr = (const uint8_t *)(ptr + offset);
>   /* Set l3_offset+flag only for known ethtypes */
> @@ -2131,13 +2135,14 @@ int packet_parse_common(packet_parser_t *prs, const 
> uint8_t *ptr,
>   /* Set l4_offset+flag only for known ip_proto */
>   prs->l4_offset = offset;
>   prs->parsed_layers = LAYER_L3;
> - if (layer == LAYER_L3)
> - return prs->error_flags.all != 0;
>   }
>   /* Fall through */
> 
> - case LAYER_L4:
> + case LAYER_L3:
>   {
> + if (layer <= LAYER_L3)
> + return prs->error_flags.all != 0;
> +
>   offset = prs->l4_offset;
>   parseptr = (const uint8_t *)(ptr + offset);
>   prs->input_flags.l4 = 1;
> @@ -2186,6 +2191,9 @@ int packet_parse_common(packet_parser_t *prs, const 
> uint8_t *ptr,
>   break;
>   }
> 
> + case LAYER_L4:
> + break;
> +
>   case LAYER_ALL:
>   break;
> 
> -- 
> 2.7.4
> 



[lng-odp] [PATCH 1/2] linux-gen: packet: remove unnecessary packet reparsing

2017-02-15 Thread Matias Elo
Previously the highest already parsed layer was unnecessarily reparsed on
the following packet_parse_common() calls.

Signed-off-by: Matias Elo 
---
 platform/linux-generic/odp_packet.c | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/platform/linux-generic/odp_packet.c 
b/platform/linux-generic/odp_packet.c
index 024f694..a6cf4cd 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2022,12 +2022,15 @@ int packet_parse_common(packet_parser_t *prs, const 
uint8_t *ptr,
case LAYER_NONE:
/* Fall through */
 
-   case LAYER_L2:
+   case LAYER_L1:
{
const _odp_ethhdr_t *eth;
uint16_t macaddr0, macaddr2, macaddr4;
const _odp_vlanhdr_t *vlan;
 
+   if (layer <= LAYER_L1)
+   return prs->error_flags.all != 0;
+
offset = sizeof(_odp_ethhdr_t);
if (packet_parse_l2_not_done(prs))
packet_parse_l2(prs, frame_len);
@@ -2091,13 +2094,14 @@ int packet_parse_common(packet_parser_t *prs, const 
uint8_t *ptr,
 
prs->l3_offset = offset;
prs->parsed_layers = LAYER_L2;
-   if (layer == LAYER_L2)
-   return prs->error_flags.all != 0;
}
/* Fall through */
 
-   case LAYER_L3:
+   case LAYER_L2:
{
+   if (layer <= LAYER_L2)
+   return prs->error_flags.all != 0;
+
offset = prs->l3_offset;
parseptr = (const uint8_t *)(ptr + offset);
/* Set l3_offset+flag only for known ethtypes */
@@ -2131,13 +2135,14 @@ int packet_parse_common(packet_parser_t *prs, const 
uint8_t *ptr,
/* Set l4_offset+flag only for known ip_proto */
prs->l4_offset = offset;
prs->parsed_layers = LAYER_L3;
-   if (layer == LAYER_L3)
-   return prs->error_flags.all != 0;
}
/* Fall through */
 
-   case LAYER_L4:
+   case LAYER_L3:
{
+   if (layer <= LAYER_L3)
+   return prs->error_flags.all != 0;
+
offset = prs->l4_offset;
parseptr = (const uint8_t *)(ptr + offset);
prs->input_flags.l4 = 1;
@@ -2186,6 +2191,9 @@ int packet_parse_common(packet_parser_t *prs, const 
uint8_t *ptr,
break;
}
 
+   case LAYER_L4:
+   break;
+
case LAYER_ALL:
break;
 
-- 
2.7.4