From patchwork Fri Jul 17 15:22:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stuart Haslam X-Patchwork-Id: 51242 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3BA7222A28 for ; Fri, 17 Jul 2015 15:23:01 +0000 (UTC) Received: by lbbvz8 with SMTP id vz8sf26346459lbb.2 for ; Fri, 17 Jul 2015 08:23:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=5FZIAz0ineIWM/lvg98J1av7djmR7vX5lJkxdmRMCh0=; b=CqLiI0+Od4opTVBVCz6mu0yr9xv+OIHdRGzCMFB+4+H2ok70reGXQ4qo0OqoN/P5+p KX7UhxkevHEExs1oQ4cUCPgHV4DyQCBJvTrlkAObr2GIV3aGFrmkQCP1JZsjaHILWF+o Nz83ezpnp3Uim5Cx86rKjD2L7Ue1g85lc2feXN0PdT0+WuP8IzBiuCi/S27k3nS3p/xz 2Yre6ByBcchnJOnj7qi6LxVUbihen4k0NnT7O98EUHkPnMRSzUBTGGicKpPwS06t0xxH Ea816DJDgzTFjarJG189ODPEvEiazE3HmfGSh4W+h+HJ7x0nM+EIV+tH6XWi7AFmxIRS 3hKg== X-Gm-Message-State: ALoCoQn2W5y8f+OR6lDL1hl5Ufw312Wdg8KoHK0jbAEFlNlinlo36vWp66Q/zYDpGQtPZuickUj4 X-Received: by 10.180.35.162 with SMTP id i2mr4392417wij.6.1437146580157; Fri, 17 Jul 2015 08:23:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.138 with SMTP id am10ls458123lac.67.gmail; Fri, 17 Jul 2015 08:23:00 -0700 (PDT) X-Received: by 10.112.145.132 with SMTP id su4mr14520881lbb.85.1437146579991; Fri, 17 Jul 2015 08:22:59 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id i6si10143918lai.30.2015.07.17.08.22.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jul 2015 08:22:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lahe2 with SMTP id e2so605369lah.1 for ; Fri, 17 Jul 2015 08:22:59 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr15354565lbc.32.1437146579565; Fri, 17 Jul 2015 08:22:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1008153lbb; Fri, 17 Jul 2015 08:22:58 -0700 (PDT) X-Received: by 10.107.17.170 with SMTP id 42mr21318246ior.21.1437146577810; Fri, 17 Jul 2015 08:22:57 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g36si2706271iod.32.2015.07.17.08.22.56; Fri, 17 Jul 2015 08:22:57 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: by lists.linaro.org (Postfix, from userid 109) id A15ED62192; Fri, 17 Jul 2015 15:22:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 6E24A62183; Fri, 17 Jul 2015 15:22:52 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 87A4762186; Fri, 17 Jul 2015 15:22:50 +0000 (UTC) Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by lists.linaro.org (Postfix) with ESMTPS id 9E24762181 for ; Fri, 17 Jul 2015 15:22:49 +0000 (UTC) Received: by wibud3 with SMTP id ud3so45649114wib.0 for ; Fri, 17 Jul 2015 08:22:49 -0700 (PDT) X-Received: by 10.181.13.195 with SMTP id fa3mr17846305wid.7.1437146568900; Fri, 17 Jul 2015 08:22:48 -0700 (PDT) Received: from e106441.cambridge.arm.com ([2001:41d0:a:3cb4::abcd]) by smtp.gmail.com with ESMTPSA id bq7sm18802785wjc.31.2015.07.17.08.22.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Jul 2015 08:22:47 -0700 (PDT) From: Stuart Haslam To: lng-odp@lists.linaro.org Date: Fri, 17 Jul 2015 16:22:34 +0100 Message-Id: <1437146554-16717-1-git-send-email-stuart.haslam@linaro.org> X-Mailer: git-send-email 2.1.1 X-Topics: Classification patch Subject: [lng-odp] [PATCH] linux-generic: classification: fix support for ODP_PMR_IPSEC_SPI X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: stuart.haslam@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Use the packed helper structures to avoid alignment issues. Signed-off-by: Stuart Haslam --- .../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 #include #include +#include #include #include @@ -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)