diff mbox series

[PATCHv1,1/2] linux-generic: classification: implement eth type packet matching rule

Message ID 1487319110-2842-1-git-send-email-bala.manoharan@linaro.org
State New
Headers show
Series [PATCHv1,1/2] linux-generic: classification: implement eth type packet matching rule | expand

Commit Message

Balasubramanian Manoharan Feb. 17, 2017, 8:11 a.m. UTC
Adds implementation for outer and inner ethernet type packet matching rule

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

---
 .../include/odp_classification_inlines.h           | 40 +++++++++++++++++-----
 1 file changed, 32 insertions(+), 8 deletions(-)

-- 
1.9.1

Comments

Bill Fischofer Feb. 17, 2017, 1:01 p.m. UTC | #1
For this series:

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

On Fri, Feb 17, 2017 at 2:11 AM, Balasubramanian Manoharan
<bala.manoharan@linaro.org> wrote:
> Adds implementation for outer and inner ethernet type packet matching rule

>

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

> ---

>  .../include/odp_classification_inlines.h           | 40 +++++++++++++++++-----

>  1 file changed, 32 insertions(+), 8 deletions(-)

>

> diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h

> index c9517d6..2747db8 100644

> --- a/platform/linux-generic/include/odp_classification_inlines.h

> +++ b/platform/linux-generic/include/odp_classification_inlines.h

> @@ -332,19 +332,43 @@ static inline int verify_pmr_custom_frame(const uint8_t *pkt_addr,

>         return 0;

>  }

>

> -static inline int verify_pmr_eth_type_0(const uint8_t *pkt_addr ODP_UNUSED,

> -                                       odp_packet_hdr_t *pkt_hdr ODP_UNUSED,

> -                                       pmr_term_value_t *term_value ODP_UNUSED)

> +static inline int verify_pmr_eth_type_0(const uint8_t *pkt_addr,

> +                                       odp_packet_hdr_t *pkt_hdr,

> +                                       pmr_term_value_t *term_value)

>  {

> -       ODP_UNIMPLEMENTED();

> +       const _odp_ethhdr_t *eth;

> +       uint16_t ethtype;

> +

> +       if (!pkt_hdr->p.input_flags.vlan_qinq)

> +               return 0;

> +

> +       eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);

> +       ethtype = odp_be_to_cpu_16(eth->type);

> +

> +       if (term_value->match.value == (ethtype & term_value->match.mask))

> +               return 1;

> +

>         return 0;

>  }

>

> -static inline int verify_pmr_eth_type_x(const uint8_t *pkt_addr ODP_UNUSED,

> -                                       odp_packet_hdr_t *pkt_hdr ODP_UNUSED,

> -                                       pmr_term_value_t *term_value ODP_UNUSED)

> +static inline int verify_pmr_eth_type_x(const uint8_t *pkt_addr,

> +                                       odp_packet_hdr_t *pkt_hdr,

> +                                       pmr_term_value_t *term_value)

>  {

> -       ODP_UNIMPLEMENTED();

> +       const _odp_ethhdr_t *eth;

> +       uint16_t ethtype;

> +       const _odp_vlanhdr_t *vlan;

> +

> +       if (!pkt_hdr->p.input_flags.vlan_qinq)

> +               return 0;

> +

> +       eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);

> +       vlan = (const _odp_vlanhdr_t *)(eth + 1);

> +       ethtype = odp_be_to_cpu_16(vlan->type);

> +

> +       if (term_value->match.value == (ethtype & term_value->match.mask))

> +               return 1;

> +

>         return 0;

>  }

>  #ifdef __cplusplus

> --

> 1.9.1

>
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h
index c9517d6..2747db8 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -332,19 +332,43 @@  static inline int verify_pmr_custom_frame(const uint8_t *pkt_addr,
 	return 0;
 }
 
-static inline int verify_pmr_eth_type_0(const uint8_t *pkt_addr ODP_UNUSED,
-					odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-					pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_eth_type_0(const uint8_t *pkt_addr,
+					odp_packet_hdr_t *pkt_hdr,
+					pmr_term_value_t *term_value)
 {
-	ODP_UNIMPLEMENTED();
+	const _odp_ethhdr_t *eth;
+	uint16_t ethtype;
+
+	if (!pkt_hdr->p.input_flags.vlan_qinq)
+		return 0;
+
+	eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);
+	ethtype = odp_be_to_cpu_16(eth->type);
+
+	if (term_value->match.value == (ethtype & term_value->match.mask))
+		return 1;
+
 	return 0;
 }
 
-static inline int verify_pmr_eth_type_x(const uint8_t *pkt_addr ODP_UNUSED,
-					odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
-					pmr_term_value_t *term_value ODP_UNUSED)
+static inline int verify_pmr_eth_type_x(const uint8_t *pkt_addr,
+					odp_packet_hdr_t *pkt_hdr,
+					pmr_term_value_t *term_value)
 {
-	ODP_UNIMPLEMENTED();
+	const _odp_ethhdr_t *eth;
+	uint16_t ethtype;
+	const _odp_vlanhdr_t *vlan;
+
+	if (!pkt_hdr->p.input_flags.vlan_qinq)
+		return 0;
+
+	eth = (const _odp_ethhdr_t *)(pkt_addr + pkt_hdr->p.l2_offset);
+	vlan = (const _odp_vlanhdr_t *)(eth + 1);
+	ethtype = odp_be_to_cpu_16(vlan->type);
+
+	if (term_value->match.value == (ethtype & term_value->match.mask))
+		return 1;
+
 	return 0;
 }
 #ifdef __cplusplus