diff mbox

[v2,1/2] linux-generic: classification: Fix incorrect L2 qos calculation

Message ID 1422031471-30427-1-git-send-email-bala.manoharan@linaro.org
State Accepted
Commit 99f1f79a76c247688a054410988728ef406743e7
Headers show

Commit Message

Balasubramanian Manoharan Jan. 23, 2015, 4:44 p.m. UTC
From: Balasubramanian Manoharan <bala.manoharan@linaro.org>

Fixes the error in vlan qos calculation due to missing convertion of
odp_be_to_cpu_16()

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

 platform/linux-generic/odp_classification.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Bill Fischofer Jan. 23, 2015, 7:18 p.m. UTC | #1
On Fri, Jan 23, 2015 at 10:44 AM, <bala.manoharan@linaro.org> wrote:

> From: Balasubramanian Manoharan <bala.manoharan@linaro.org>
>
> Fixes the error in vlan qos calculation due to missing convertion of
> odp_be_to_cpu_16()
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
> v2: Incorporates review comments from Anders
>

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


>
>  platform/linux-generic/odp_classification.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_classification.c
> b/platform/linux-generic/odp_classification.c
> index 7d09cce..0f58836 100644
> --- a/platform/linux-generic/odp_classification.c
> +++ b/platform/linux-generic/odp_classification.c
> @@ -881,16 +881,17 @@ cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos,
> uint8_t *pkt_addr,
>  cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, uint8_t *pkt_addr,
>                         odp_packet_hdr_t *hdr)
>  {
> -       uint8_t qos;
>         cos_t *cos = NULL;
>         odph_ethhdr_t *eth;
>         odph_vlanhdr_t *vlan;
> +       uint16_t qos;
>
>         if (hdr->input_flags.l2 && hdr->input_flags.vlan &&
>             hdr->input_flags.eth) {
>                 eth = (odph_ethhdr_t *)(pkt_addr + hdr->l2_offset);
>                 vlan = (odph_vlanhdr_t *)(&eth->type);
> -               qos = ((vlan->tci >> 13) & 0xFF);
> +               qos = odp_be_to_cpu_16(vlan->tci);
> +               qos = ((qos >> 13) & 0x07);
>                 cos = l2_cos->cos[qos];
>         }
>         return cos;
> --
> 2.0.1.472.g6f92e5f
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
>
Anders Roxell Jan. 23, 2015, 7:31 p.m. UTC | #2
On 23 January 2015 at 17:44,  <bala.manoharan@linaro.org> wrote:
> From: Balasubramanian Manoharan <bala.manoharan@linaro.org>
>
> Fixes the error in vlan qos calculation due to missing convertion of
> odp_be_to_cpu_16()

Nit:
Can we also add to the description that we corrected the bit mask as well?

Maybe Maxim can do that when merging if we agree on what it should say
if it should say anything.

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

Reviewed-by: Anders Roxell <anders.roxell@linaro.org>

> ---
> v2: Incorporates review comments from Anders
>
>  platform/linux-generic/odp_classification.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
> index 7d09cce..0f58836 100644
> --- a/platform/linux-generic/odp_classification.c
> +++ b/platform/linux-generic/odp_classification.c
> @@ -881,16 +881,17 @@ cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, uint8_t *pkt_addr,
>  cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, uint8_t *pkt_addr,
>                         odp_packet_hdr_t *hdr)
>  {
> -       uint8_t qos;
>         cos_t *cos = NULL;
>         odph_ethhdr_t *eth;
>         odph_vlanhdr_t *vlan;
> +       uint16_t qos;
>
>         if (hdr->input_flags.l2 && hdr->input_flags.vlan &&
>             hdr->input_flags.eth) {
>                 eth = (odph_ethhdr_t *)(pkt_addr + hdr->l2_offset);
>                 vlan = (odph_vlanhdr_t *)(&eth->type);
> -               qos = ((vlan->tci >> 13) & 0xFF);
> +               qos = odp_be_to_cpu_16(vlan->tci);
> +               qos = ((qos >> 13) & 0x07);
>                 cos = l2_cos->cos[qos];
>         }
>         return cos;
> --
> 2.0.1.472.g6f92e5f
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> http://lists.linaro.org/mailman/listinfo/lng-odp
Maxim Uvarov Jan. 26, 2015, 4:59 p.m. UTC | #3
Merged!
Maxim.

On 01/23/2015 07:44 PM, bala.manoharan@linaro.org wrote:
> From: Balasubramanian Manoharan <bala.manoharan@linaro.org>
>
> Fixes the error in vlan qos calculation due to missing convertion of
> odp_be_to_cpu_16()
>
> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>
> ---
> v2: Incorporates review comments from Anders
>
>   platform/linux-generic/odp_classification.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
> index 7d09cce..0f58836 100644
> --- a/platform/linux-generic/odp_classification.c
> +++ b/platform/linux-generic/odp_classification.c
> @@ -881,16 +881,17 @@ cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, uint8_t *pkt_addr,
>   cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, uint8_t *pkt_addr,
>   			odp_packet_hdr_t *hdr)
>   {
> -	uint8_t qos;
>   	cos_t *cos = NULL;
>   	odph_ethhdr_t *eth;
>   	odph_vlanhdr_t *vlan;
> +	uint16_t qos;
>   
>   	if (hdr->input_flags.l2 && hdr->input_flags.vlan &&
>   	    hdr->input_flags.eth) {
>   		eth = (odph_ethhdr_t *)(pkt_addr + hdr->l2_offset);
>   		vlan = (odph_vlanhdr_t *)(&eth->type);
> -		qos = ((vlan->tci >> 13) & 0xFF);
> +		qos = odp_be_to_cpu_16(vlan->tci);
> +		qos = ((qos >> 13) & 0x07);
>   		cos = l2_cos->cos[qos];
>   	}
>   	return cos;
diff mbox

Patch

diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c
index 7d09cce..0f58836 100644
--- a/platform/linux-generic/odp_classification.c
+++ b/platform/linux-generic/odp_classification.c
@@ -881,16 +881,17 @@  cos_t *match_qos_l3_cos(pmr_l3_cos_t *l3_cos, uint8_t *pkt_addr,
 cos_t *match_qos_l2_cos(pmr_l2_cos_t *l2_cos, uint8_t *pkt_addr,
 			odp_packet_hdr_t *hdr)
 {
-	uint8_t qos;
 	cos_t *cos = NULL;
 	odph_ethhdr_t *eth;
 	odph_vlanhdr_t *vlan;
+	uint16_t qos;
 
 	if (hdr->input_flags.l2 && hdr->input_flags.vlan &&
 	    hdr->input_flags.eth) {
 		eth = (odph_ethhdr_t *)(pkt_addr + hdr->l2_offset);
 		vlan = (odph_vlanhdr_t *)(&eth->type);
-		qos = ((vlan->tci >> 13) & 0xFF);
+		qos = odp_be_to_cpu_16(vlan->tci);
+		qos = ((qos >> 13) & 0x07);
 		cos = l2_cos->cos[qos];
 	}
 	return cos;