diff mbox

linux-generic: classification: fix support for ODP_PMR_IPSEC_SPI

Message ID 1437146554-16717-1-git-send-email-stuart.haslam@linaro.org
State Accepted
Commit 99ba15f45a35cf57357c6673ea9b29cdf3681106
Headers show

Commit Message

Stuart Haslam July 17, 2015, 3:22 p.m. UTC
Use the packed helper structures to avoid alignment issues.

Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
---
 .../include/odp_classification_inlines.h           | 29 ++++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)

Comments

Maxim Uvarov July 20, 2015, 10:37 a.m. UTC | #1
Merged.

That patch fixes arm build compilation.

Maxim.

On 07/17/15 18:22, Stuart Haslam wrote:
> Use the packed helper structures to avoid alignment issues.
>
> Signed-off-by: Stuart Haslam <stuart.haslam@linaro.org>
> ---
>   .../include/odp_classification_inlines.h           | 29 ++++++++++++++++------
>   1 file changed, 21 insertions(+), 8 deletions(-)
>
> diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h
> index 560104e..a093211 100644
> --- a/platform/linux-generic/include/odp_classification_inlines.h
> +++ b/platform/linux-generic/include/odp_classification_inlines.h
> @@ -21,6 +21,7 @@ extern "C" {
>   #include <odp/debug.h>
>   #include <odp/helper/eth.h>
>   #include <odp/helper/ip.h>
> +#include <odp/helper/ipsec.h>
>   #include <odp/helper/udp.h>
>   #include <odp/helper/tcp.h>
>   
> @@ -185,24 +186,36 @@ static inline int verify_pmr_vlan_id_x(uint8_t *pkt_addr ODP_UNUSED,
>   	ODP_UNIMPLEMENTED();
>   	return 0;
>   }
> -static inline int verify_pmr_ipsec_spi(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_ipsec_spi(uint8_t *pkt_addr,
> +				       odp_packet_hdr_t *pkt_hdr,
> +				       pmr_term_value_t *term_value)
>   {
> -	uint32_t *spi;
> +	uint32_t spi;
>   
>   	if (!pkt_hdr->input_flags.ipsec)
>   		return 0;
>   
> -	spi = (uint32_t *)(pkt_addr + pkt_hdr->l4_offset);
> -	if (pkt_hdr->l4_protocol == ODPH_IPPROTO_AH)
> -		spi++;
> +	pkt_addr += pkt_hdr->l4_offset;
>   
> -	if (term_value->val == (odp_be_to_cpu_32(*spi) & term_value->mask))
> +	if (pkt_hdr->l4_protocol == ODPH_IPPROTO_AH) {
> +		odph_ahhdr_t *ahhdr = (odph_ahhdr_t *)pkt_addr;
> +
> +		spi = odp_be_to_cpu_32(ahhdr->spi);
> +	} else if (pkt_hdr->l4_protocol == ODPH_IPPROTO_ESP) {
> +		odph_esphdr_t *esphdr = (odph_esphdr_t *)pkt_addr;
> +
> +		spi = odp_be_to_cpu_32(esphdr->spi);
> +	} else {
> +		return 0;
> +	}
> +
> +	if (term_value->val == (spi & term_value->mask))
>   		return 1;
>   
>   	return 0;
>   }
> +
>   static inline int verify_pmr_ld_vni(uint8_t *pkt_addr ODP_UNUSED,
>   				    odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
>   				    pmr_term_value_t *term_value ODP_UNUSED)
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h
index 560104e..a093211 100644
--- a/platform/linux-generic/include/odp_classification_inlines.h
+++ b/platform/linux-generic/include/odp_classification_inlines.h
@@ -21,6 +21,7 @@  extern "C" {
 #include <odp/debug.h>
 #include <odp/helper/eth.h>
 #include <odp/helper/ip.h>
+#include <odp/helper/ipsec.h>
 #include <odp/helper/udp.h>
 #include <odp/helper/tcp.h>
 
@@ -185,24 +186,36 @@  static inline int verify_pmr_vlan_id_x(uint8_t *pkt_addr ODP_UNUSED,
 	ODP_UNIMPLEMENTED();
 	return 0;
 }
-static inline int verify_pmr_ipsec_spi(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_ipsec_spi(uint8_t *pkt_addr,
+				       odp_packet_hdr_t *pkt_hdr,
+				       pmr_term_value_t *term_value)
 {
-	uint32_t *spi;
+	uint32_t spi;
 
 	if (!pkt_hdr->input_flags.ipsec)
 		return 0;
 
-	spi = (uint32_t *)(pkt_addr + pkt_hdr->l4_offset);
-	if (pkt_hdr->l4_protocol == ODPH_IPPROTO_AH)
-		spi++;
+	pkt_addr += pkt_hdr->l4_offset;
 
-	if (term_value->val == (odp_be_to_cpu_32(*spi) & term_value->mask))
+	if (pkt_hdr->l4_protocol == ODPH_IPPROTO_AH) {
+		odph_ahhdr_t *ahhdr = (odph_ahhdr_t *)pkt_addr;
+
+		spi = odp_be_to_cpu_32(ahhdr->spi);
+	} else if (pkt_hdr->l4_protocol == ODPH_IPPROTO_ESP) {
+		odph_esphdr_t *esphdr = (odph_esphdr_t *)pkt_addr;
+
+		spi = odp_be_to_cpu_32(esphdr->spi);
+	} else {
+		return 0;
+	}
+
+	if (term_value->val == (spi & term_value->mask))
 		return 1;
 
 	return 0;
 }
+
 static inline int verify_pmr_ld_vni(uint8_t *pkt_addr ODP_UNUSED,
 				    odp_packet_hdr_t *pkt_hdr ODP_UNUSED,
 				    pmr_term_value_t *term_value ODP_UNUSED)