diff mbox series

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

Message ID 1486630956-12293-1-git-send-email-bala.manoharan@linaro.org
State Accepted
Commit 96f3c0362b61a415b9ecc319ee3427c8f4b7c081
Headers show
Series [PATCHv1,1/2] linux-generic: classification: implement vlan id packet matching rule | expand

Commit Message

Balasubramanian Manoharan Feb. 9, 2017, 9:02 a.m. UTC
Add implementation for outer and inner vlan ID packet matching rule

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

---
 .../include/odp_classification_inlines.h           | 41 +++++++++++++++++++---
 1 file changed, 36 insertions(+), 5 deletions(-)

-- 
1.9.1

Comments

Bill Fischofer Feb. 10, 2017, 2:22 a.m. UTC | #1
For this series:

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

On Thu, Feb 9, 2017 at 3:02 AM, Balasubramanian Manoharan
<bala.manoharan@linaro.org> wrote:
> Add implementation for outer and inner vlan ID packet matching rule

>

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

> ---

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

>  1 file changed, 36 insertions(+), 5 deletions(-)

>

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

> index e6f9be9..c9517d6 100644

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

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

> @@ -231,11 +231,26 @@ static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr,

>         return 0;

>  }

>

> -static inline int verify_pmr_vlan_id_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_vlan_id_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;

> +       const _odp_vlanhdr_t *vlan;

> +       uint16_t tci;

> +       uint16_t vlan_id;

> +

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

> +       tci = odp_be_to_cpu_16(vlan->tci);

> +       vlan_id = tci & 0x0fff;

> +

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

> +               return 1;

> +

>         return 0;

>  }

>

> @@ -243,7 +258,23 @@ static inline int verify_pmr_vlan_id_x(const uint8_t *pkt_addr ODP_UNUSED,

>                                        odp_packet_hdr_t *pkt_hdr ODP_UNUSED,

>                                        pmr_term_value_t *term_value ODP_UNUSED)

>  {

> -       ODP_UNIMPLEMENTED();

> +       const _odp_ethhdr_t *eth;

> +       const _odp_vlanhdr_t *vlan;

> +       uint16_t tci;

> +       uint16_t vlan_id;

> +

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

> +       vlan++;

> +       tci = odp_be_to_cpu_16(vlan->tci);

> +       vlan_id = tci & 0x0fff;

> +

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

> +               return 1;

> +

>         return 0;

>  }

>

> --

> 1.9.1

>
Maxim Uvarov Feb. 14, 2017, 8:52 p.m. UTC | #2
that was merged,
Closing this thread.

Maxim.

On 02/10/17 05:22, Bill Fischofer wrote:
> For this series:

> 

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

> 

> On Thu, Feb 9, 2017 at 3:02 AM, Balasubramanian Manoharan

> <bala.manoharan@linaro.org> wrote:

>> Add implementation for outer and inner vlan ID packet matching rule

>>

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

>> ---

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

>>  1 file changed, 36 insertions(+), 5 deletions(-)

>>

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

>> index e6f9be9..c9517d6 100644

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

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

>> @@ -231,11 +231,26 @@ static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr,

>>         return 0;

>>  }

>>

>> -static inline int verify_pmr_vlan_id_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_vlan_id_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;

>> +       const _odp_vlanhdr_t *vlan;

>> +       uint16_t tci;

>> +       uint16_t vlan_id;

>> +

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

>> +       tci = odp_be_to_cpu_16(vlan->tci);

>> +       vlan_id = tci & 0x0fff;

>> +

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

>> +               return 1;

>> +

>>         return 0;

>>  }

>>

>> @@ -243,7 +258,23 @@ static inline int verify_pmr_vlan_id_x(const uint8_t *pkt_addr ODP_UNUSED,

>>                                        odp_packet_hdr_t *pkt_hdr ODP_UNUSED,

>>                                        pmr_term_value_t *term_value ODP_UNUSED)

>>  {

>> -       ODP_UNIMPLEMENTED();

>> +       const _odp_ethhdr_t *eth;

>> +       const _odp_vlanhdr_t *vlan;

>> +       uint16_t tci;

>> +       uint16_t vlan_id;

>> +

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

>> +       vlan++;

>> +       tci = odp_be_to_cpu_16(vlan->tci);

>> +       vlan_id = tci & 0x0fff;

>> +

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

>> +               return 1;

>> +

>>         return 0;

>>  }

>>

>> --

>> 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 e6f9be9..c9517d6 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -231,11 +231,26 @@  static inline int verify_pmr_ipv6_daddr(const uint8_t *pkt_addr,
 	return 0;
 }
 
-static inline int verify_pmr_vlan_id_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_vlan_id_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;
+	const _odp_vlanhdr_t *vlan;
+	uint16_t tci;
+	uint16_t vlan_id;
+
+	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);
+	tci = odp_be_to_cpu_16(vlan->tci);
+	vlan_id = tci & 0x0fff;
+
+	if (term_value->match.value == (vlan_id & term_value->match.mask))
+		return 1;
+
 	return 0;
 }
 
@@ -243,7 +258,23 @@  static inline int verify_pmr_vlan_id_x(const uint8_t *pkt_addr ODP_UNUSED,
 				       odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
 				       pmr_term_value_t *term_value ODP_UNUSED)
 {
-	ODP_UNIMPLEMENTED();
+	const _odp_ethhdr_t *eth;
+	const _odp_vlanhdr_t *vlan;
+	uint16_t tci;
+	uint16_t vlan_id;
+
+	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);
+	vlan++;
+	tci = odp_be_to_cpu_16(vlan->tci);
+	vlan_id = tci & 0x0fff;
+
+	if (term_value->match.value == (vlan_id & term_value->match.mask))
+		return 1;
+
 	return 0;
 }