From patchwork Thu Feb 9 09:02:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balasubramanian Manoharan X-Patchwork-Id: 93674 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp150516qgi; Thu, 9 Feb 2017 01:03:09 -0800 (PST) X-Received: by 10.200.41.175 with SMTP id 44mr1889603qts.53.1486630989890; Thu, 09 Feb 2017 01:03:09 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n4si7554463qtb.99.2017.02.09.01.03.09; Thu, 09 Feb 2017 01:03:09 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3FDB262EB3; Thu, 9 Feb 2017 09:03:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 2287A60D2A; Thu, 9 Feb 2017 09:03:04 +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 5AD8960D2E; Thu, 9 Feb 2017 09:02:59 +0000 (UTC) Received: from mail-pf0-f171.google.com (mail-pf0-f171.google.com [209.85.192.171]) by lists.linaro.org (Postfix) with ESMTPS id 4833A60C3A for ; Thu, 9 Feb 2017 09:02:58 +0000 (UTC) Received: by mail-pf0-f171.google.com with SMTP id f144so49055714pfa.2 for ; Thu, 09 Feb 2017 01:02:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=3vzvlGPjLUy3Bu0J7f2F2kIyIw4PQfZ7dHZxiVl5vHw=; b=mAcuPd6UyAdpHYutuJYq+N/L/PyYkMu5XxebBc876ZDLG9T2DgJ1s6cz/kv6alx+Yk 9I0v0xZE1TXJ4pf3hevFU4dowJAQdaCHLxFySKoE4cAN5dMq5L6r2tXX1g7dV0X6xTg6 5yQVj7yIViMuqTUSKh+IsD86i7QScX4r5Qh+RPXWEC6+bUTu8JYzSjp08YUqbFcA/wMr EhbtnxAS9IgjRNWuhyo9PGZ5RrZ/CO/qwcO4nzkjMV+Yc+dcEIorTGo1EtFvo9n5m515 eTrt9DywMafMWbIVI2d+8f4tVGXntcpl548LFL16AIu5MLMk2HQswpXIwAJcm1d4zBtr 8OMQ== X-Gm-Message-State: AMke39kGePFHe5FRapSWden8KdUGryZGeKuHhY412YvBBzKJ/gHG4c20knhDp93ScVLp07vJqzo= X-Received: by 10.98.80.146 with SMTP id g18mr2518258pfj.74.1486630977369; Thu, 09 Feb 2017 01:02:57 -0800 (PST) Received: from localhost.localdomain ([122.171.225.13]) by smtp.gmail.com with ESMTPSA id c64sm26773093pfa.45.2017.02.09.01.02.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Feb 2017 01:02:56 -0800 (PST) From: Balasubramanian Manoharan To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 14:32:35 +0530 Message-Id: <1486630956-12293-1-git-send-email-bala.manoharan@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [PATCHv1 1/2] linux-generic: classification: implement vlan id packet matching rule X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Add implementation for outer and inner vlan ID packet matching rule Signed-off-by: Balasubramanian Manoharan --- .../include/odp_classification_inlines.h | 41 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) -- 1.9.1 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; }