From patchwork Thu Dec 14 17:00:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121990 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7060864qgn; Thu, 14 Dec 2017 09:00:28 -0800 (PST) X-Google-Smtp-Source: ACJfBotS8iycxApLJchIFTb2PqNpjQWeJEfMn/dpb1+O7iIlF6htz6PpB+3klhTzxc7Tp3zE08tO X-Received: by 10.200.63.107 with SMTP id w40mr17150890qtk.24.1513270828231; Thu, 14 Dec 2017 09:00:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513270828; cv=none; d=google.com; s=arc-20160816; b=fkYkyxUM0eOrkUdeTqmBoD4sVAYJjwfbj2AQXHeekefOT7CDbhhaF+U1Q7k50d5V33 DSIYjV2re1WmQC89mAVOAP2FqbFeWfDqArk8ShEQn1S5qK3jGQFHBqnalrSv2uv9MOHN hvpxBo+MZYDIDTSdMpMoG6PRE/BboRxx7Pju5qDo25VUImVmadE9gB7NOXsRA1he0Lk1 qd4XxquOaZGpHGsfOW+90dF+HwNQRqBCWLa3paSMMAVbaVMThiqBHgkzyuwAvPzOIJNk rDDaTYCUw6EpmXr22lEidEAha4wRQtKIdGZ9M5gNXp8BBSUg9gcp/F8WdK2E42zT42Es SY8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=RLU0xj+GfkQIJVMfw+N6ek+IlUyywPAxCD+b7bCqqBw=; b=msBxMByeEggdhy8bnnky2oQ8/3zO83GpW0ji2IoqT7fAt+urnJ8JkFJd9OyiaGSRmX FLhUkf8VxZudX3Rhbf8d6deQETV6IMfdAw3nmAzuErR1Z2CGgzDqy7Q08ilpiWkEH/jO awRyFeARsRThXTC8OiiFSL+rrKwMTAA9our3TbYtiUfeN1jo/S82ENF5yYdV4Ilc0f34 xF4Y0FzAR27rXTIJnKSfPkDr3Ut4zjbOpU7zNzeeuuZgBxAqzBfUpZhXgJpeid9rkbOV hACJRiI8+aiGmwMa0MQIYli91ALsF9Oo7Y00LTbqxZIY9xHlXxyp3JnDM8SNdsxap1KO PZQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id w19si554003qka.243.2017.12.14.09.00.27; Thu, 14 Dec 2017 09:00:28 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id A543B60970; Thu, 14 Dec 2017 17:00:27 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, 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 C6C0660926; Thu, 14 Dec 2017 17:00:22 +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 2FCA060933; Thu, 14 Dec 2017 17:00:15 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id 887FC6084F for ; Thu, 14 Dec 2017 17:00:13 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward102o.mail.yandex.net (Yandex) with ESMTP id E62D65A0269E for ; Thu, 14 Dec 2017 20:00:11 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 7qNKxPniUQ-0BtmXRM0; Thu, 14 Dec 2017 20:00:11 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id P3vbKkCfK1-0BrOrZ8q; Thu, 14 Dec 2017 20:00:11 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 20:00:07 +0300 Message-Id: <1513270810-29728-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> References: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 345 Subject: [lng-odp] [PATCH v2 1/4] helper: add vxlan protocol header structure 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" From: Balasubramanian Manoharan adds vxlan header protocol structure Signed-off-by: Balasubramanian Manoharan --- /** Email created from pull request 345 (bala-manoharan:BUG2903) ** https://github.com/Linaro/odp/pull/345 ** Patch: https://github.com/Linaro/odp/pull/345.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 65c561d30ea4c8c5f8ae17c2b407df9c6cc35f3d **/ helper/include/odp/helper/odph_api.h | 2 +- helper/include/odp/helper/vxlan.h | 58 ++++++++++++++++++++++++ platform/linux-generic/include/protocols/vxlan.h | 56 +++++++++++++++++++++++ 3 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 helper/include/odp/helper/vxlan.h create mode 100644 platform/linux-generic/include/protocols/vxlan.h diff --git a/helper/include/odp/helper/odph_api.h b/helper/include/odp/helper/odph_api.h index 7ed0e7786..4f38c58e7 100644 --- a/helper/include/odp/helper/odph_api.h +++ b/helper/include/odp/helper/odph_api.h @@ -32,7 +32,7 @@ extern "C" { #include #include #include - +#include #ifdef __cplusplus } #endif diff --git a/helper/include/odp/helper/vxlan.h b/helper/include/odp/helper/vxlan.h new file mode 100644 index 000000000..cfe0a9aa4 --- /dev/null +++ b/helper/include/odp/helper/vxlan.h @@ -0,0 +1,58 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODPH VxLAN header + */ + +#ifndef ODPH_VXLAN_H_ +#define ODPH_VXLAN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @addtogroup odp_header ODP HEADER + * @{ + */ + +/** VXLAN header length */ +#define ODPH_VXLANHDR_LEN 8 + +/** VNI from VXLAN header format */ +#define ODPH_VXLAN_VNI(vxlan_vni) ((vxlan_vni & 0xffffff00) >> 8) + +/** UDP VXLAN destination port */ +#define ODPH_UDP_VXLAN_PORT 4789 + +/** VNI to VXLAN header format */ +#define ODPH_VNI_VXLAN(vxlan_vni) (vxlan_vni << 8) + +/** VXLAN header */ +typedef struct ODP_PACKED { + uint8_t flags; /**< Vxlan flags */ + uint8_t reserve1; /**< reserved bits */ + uint16_t reseve2; /**< reserved bits */ + odp_u32be_t vni; /**< VNI Identifier */ +} odph_vxlanhdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(odph_vxlanhdr_t) == ODPH_VXLANHDR_LEN, + "ODPH_VXLANHDR_T__SIZE_ERROR"); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/protocols/vxlan.h b/platform/linux-generic/include/protocols/vxlan.h new file mode 100644 index 000000000..b42e79097 --- /dev/null +++ b/platform/linux-generic/include/protocols/vxlan.h @@ -0,0 +1,56 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP VxLAN header + */ + +#ifndef ODP_VXLAN_H_ +#define ODP_VXLAN_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @addtogroup odp_header ODP HEADER + * @{ + */ + +/** VXLAN header length */ +#define _ODP_VXLANHDR_LEN 8 + +/** VXLAN UDP destination port */ +#define _ODP_UDP_VXLAN_PORT 4789 + +#define ODPH_VXLAN_VNI(vxlan_vni) ((vxlan_vni & 0xffffff00) >> 8) + +#define ODPH_VXLAN_BIT(vxlan_flag) (vxlan_flag & 0x08) + +/** UDP header */ +typedef struct ODP_PACKED { + uint8_t flags; /**< Vxlan flags */ + uint8_t reserve1; /**< reserved bits */ + uint16_t reseve2; /**< reserved bits */ + odp_u32be_t vni; /**< VNI Identifier */ +} _odp_vxlanhdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(_odp_vxlanhdr_t) == _ODP_VXLANHDR_LEN, + "_ODP_VXLANHDR_T__SIZE_ERROR"); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif From patchwork Thu Dec 14 17:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121991 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7062094qgn; Thu, 14 Dec 2017 09:01:12 -0800 (PST) X-Google-Smtp-Source: ACJfBouayz0aRG91lYS//QWHPJqfTln035dJbUkWW/Bxz3KRFJjGGD0LcIwvzUYdvqGfCRT6R1f3 X-Received: by 10.200.44.243 with SMTP id 48mr16171341qtx.99.1513270872523; Thu, 14 Dec 2017 09:01:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513270872; cv=none; d=google.com; s=arc-20160816; b=oaudCV+F+E1RuJT81SVAaaAmQSWIK0W/8BYheHi84tbw7yjjHGn04i6uF3wbRB0Odv WKROmMbtli7KCV185DVT1W5DyyE4CIW+vWO4PsbyH/MX60uVEXZRX/RkdDWoEPkVeUpg eqtwjikALgXEQxx7UKsbqk/5gRVXFV0GGDs00apK2XRas0UlrKHskak+1vCOVJmgOJKm MeVn6lKGMM1Yz+qq5rkiwQ5h+BA/A7AoCk7pueGv2g/sIFzzw712A1mfaXttgHaAkYDE KFAl3kWsMG7+9qiTWHUbzhl4g9kcPke9bxTTQdFn0hlkd8OCgO7p6dg+lbNreUQCEwGO ETDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=J0OgpzzGOCx3KRnVUJVu/AI3cH3fG4ubkALlw3QKGQ0=; b=GbuL1yBGqPXFKEQ671VBtQGUnOq72ehY61SqQHTwKsWbjDKK+k8SBdFK/Qk8htqJVM D4BXvqtYzSjNxrlDDwXwixkin/2JCtD9jrorHnzWMnxL9ocRg5fH0THY9O87emrTjLbW C7OdNEUh5hojwABDoxVA7xqcCMQRBAaIwj8KbPybx398/rOU6AXxg/IO3OvuchoeSNBD Rumxw1D5jQcbw4XQ+uZZT6IR6lt2QFSTr87VT6lxvd4S6eFGJMdDugK/s8YMHOD2UMB/ 4QQMlBtNp4Sqv2zvkor6lrFPUBtEV5YahTLxyhhlNmp+lP53rYr6+AQrvlHjoxKrRgxL oZ+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id n66si4899264qkh.382.2017.12.14.09.01.12; Thu, 14 Dec 2017 09:01:12 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 33B326098C; Thu, 14 Dec 2017 17:01:12 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,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 26D3E60966; Thu, 14 Dec 2017 17:00:24 +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 633FC60926; Thu, 14 Dec 2017 17:00:15 +0000 (UTC) Received: from forward104o.mail.yandex.net (forward104o.mail.yandex.net [37.140.190.179]) by lists.linaro.org (Postfix) with ESMTPS id 1978860918 for ; Thu, 14 Dec 2017 17:00:14 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward104o.mail.yandex.net (Yandex) with ESMTP id A7975703907 for ; Thu, 14 Dec 2017 20:00:12 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id qmkXS7kgFc-0C0CPWDI; Thu, 14 Dec 2017 20:00:12 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id P3vbKkCfK1-0BrSHE4t; Thu, 14 Dec 2017 20:00:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 20:00:08 +0300 Message-Id: <1513270810-29728-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> References: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 345 Subject: [lng-odp] [PATCH v2 2/4] api: packet: vxlan packet flag access function 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" From: Balasubramanian Manoharan adds odp_packet_has_vxlan() and odp_packet_has_vxlan_set() functions Signed-off-by: Balasubramanian Manoharan --- /** Email created from pull request 345 (bala-manoharan:BUG2903) ** https://github.com/Linaro/odp/pull/345 ** Patch: https://github.com/Linaro/odp/pull/345.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 65c561d30ea4c8c5f8ae17c2b407df9c6cc35f3d **/ include/odp/api/spec/packet_flags.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/odp/api/spec/packet_flags.h b/include/odp/api/spec/packet_flags.h index 377b75ba0..0954b9349 100644 --- a/include/odp/api/spec/packet_flags.h +++ b/include/odp/api/spec/packet_flags.h @@ -249,6 +249,14 @@ int odp_packet_has_ipsec(odp_packet_t pkt); */ int odp_packet_has_udp(odp_packet_t pkt); +/** Check for VxLAN + * + * @param pkt Packet handle + * @retval non-zero if packet contains VxLAN header + * @retval 0 if packet does not contain a VxLAN header + */ +int odp_packet_has_vxlan(odp_packet_t pkt); + /** * Check for TCP * @@ -441,6 +449,14 @@ void odp_packet_has_ipsec_set(odp_packet_t pkt, int val); */ void odp_packet_has_udp_set(odp_packet_t pkt, int val); +/** + * Set flag for VxLAN + * + * @param pkt Packet handle + * @param val Value + */ +void odp_packet_has_vxlan_set(odp_packet_t pkt, int val); + /** * Set flag for TCP * From patchwork Thu Dec 14 17:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121992 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7063398qgn; Thu, 14 Dec 2017 09:01:55 -0800 (PST) X-Google-Smtp-Source: ACJfBouXwN/YQl759nfnXZRHGknMwq3qEgmUvzncyewAdUj8SDUsSmR3e0wMqKezwgNhBgVP8ma4 X-Received: by 10.98.71.144 with SMTP id p16mr10163453pfi.15.1513270915390; Thu, 14 Dec 2017 09:01:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513270914; cv=none; d=google.com; s=arc-20160816; b=JkAZYV559iGXgcgmaT3aiOP/7djAF7mdB6QAuAuoOmSr7b0cL35q0XrKTWw0DWpIXB F0wRGFg4fY31bFCJFykRBL9SioVtFXVaJqUh02a/443nxm/pFlcSVt/44uuD90f7pCMZ P1CSf+Qc/cBcqPT1NuKNoxBupk6uo28c8GK1nkTK+e8pdRHhfEBjpIIm5vRhfGN0J4bf JQiES947fLDBkXiCBuESxXRo5YYf+k/rhoQl0XPpbH991E7SKJhYQ1OlGEXw4+FdOquo rWYcMDO/qI0z19sPb4FEh43UJBdrJhZJNHzkmVJSmQab66koLVefixhzSG2dSuN6XiWe B0aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=B+84Degwx4GaPdTtULklXr7UAYRHgmyB2bFYqMCHX+I=; b=diifrs2G4XozhO3HT+pQfUFa67/i/cnHwu1fO6iSN2mlq7e7IrI2skoLi+MfeFcVcl 7fJzT2Mn2N1h97ut/vUHP3KkmEkhVn/v93heleFpc5D8XkbDhvbckPyZRumbHzFUqWeJ CMlFvlnTpQoWV5LhnzlF2kYRtUykCFYGwll4K2uPAy33ZosMQZs1e8CMvh6f6420L08h Bod2lItazWKw+mzXRrn2HnRpW0PNuP9pLVHoja5ft8uwofCN52yIZd6R0HDcEoojT22k MnS456iR1aksp6G7oOReh2e/gtpNq1a5MYWe7OD6++xIhU9RLz+jVTbKugmlCigiol/M MNXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id t65si4678500qke.95.2017.12.14.09.01.54; Thu, 14 Dec 2017 09:01:54 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 9D28560918; Thu, 14 Dec 2017 17:01:54 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, 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 77FED60970; Thu, 14 Dec 2017 17:00:28 +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 287D660926; Thu, 14 Dec 2017 17:00:18 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id EC13D6091D for ; Thu, 14 Dec 2017 17:00:14 +0000 (UTC) Received: from mxback9j.mail.yandex.net (mxback9j.mail.yandex.net [IPv6:2a02:6b8:0:1619::112]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 7E57E408346B for ; Thu, 14 Dec 2017 20:00:13 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback9j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id wA206Vfm0I-0Dr8X9uv; Thu, 14 Dec 2017 20:00:13 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id P3vbKkCfK1-0CrS6nH4; Thu, 14 Dec 2017 20:00:12 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 20:00:09 +0300 Message-Id: <1513270810-29728-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> References: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 345 Subject: [lng-odp] [PATCH v2 3/4] linux-gen: cls: LD_VNI pmr term implementation 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" From: Balasubramanian Manoharan Update packet parsing function to handle inner header packet parsing for vxlan packets. Add classification verification function for pmr term ODP_PMR_TERM_LD_VNI. Signed-off-by: Balasubramanian Manoharan --- /** Email created from pull request 345 (bala-manoharan:BUG2903) ** https://github.com/Linaro/odp/pull/345 ** Patch: https://github.com/Linaro/odp/pull/345.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 65c561d30ea4c8c5f8ae17c2b407df9c6cc35f3d **/ .../include/odp/api/plat/packet_types.h | 1 + .../include/odp_classification_inlines.h | 23 +++++++++--- .../linux-generic/include/odp_packet_internal.h | 5 +-- platform/linux-generic/odp_classification.c | 4 +-- platform/linux-generic/odp_packet.c | 41 +++++++++++++++++----- platform/linux-generic/odp_packet_flags.c | 10 ++++++ 6 files changed, 67 insertions(+), 17 deletions(-) diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h index 009a3aa7c..89eff1b70 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -146,6 +146,7 @@ typedef union { uint64_t sctp:1; /**< SCTP */ uint64_t icmp:1; /**< ICMP */ + uint64_t vxlan:1; /**< VXLAN */ uint64_t color:2; /**< Packet color for traffic mgmt */ uint64_t nodrop:1; /**< Drop eligibility status */ }; diff --git a/platform/linux-generic/include/odp_classification_inlines.h b/platform/linux-generic/include/odp_classification_inlines.h index 2747db8cc..f48bbf514 100644 --- a/platform/linux-generic/include/odp_classification_inlines.h +++ b/platform/linux-generic/include/odp_classification_inlines.h @@ -24,6 +24,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -304,11 +305,25 @@ static inline int verify_pmr_ipsec_spi(const uint8_t *pkt_addr, return 0; } -static inline int verify_pmr_ld_vni(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_ld_vni(const uint8_t *pkt_addr, + odp_packet_hdr_t *pkt_hdr, + pmr_term_value_t *term_value) { - ODP_UNIMPLEMENTED(); + uint32_t vni; + uint32_t vni_be; + const _odp_vxlanhdr_t *vxlan; + + if (!pkt_hdr->p.input_flags.vxlan) + return 0; + + pkt_addr += pkt_hdr->p.l4_offset; + pkt_addr += _ODP_UDPHDR_LEN; + vxlan = (const _odp_vxlanhdr_t *)pkt_addr; + vni = odp_be_to_cpu_32(vxlan->vni); + vni_be = ODPH_VXLAN_VNI(vni); + if (term_value->match.value == (vni_be & term_value->match.mask)) + return 1; + return 0; } diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index fb3d44498..94cca9aa3 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -120,6 +120,7 @@ typedef struct { */ packet_parser_t p; + packet_parser_t inner_p; odp_pktio_t input; @@ -310,8 +311,8 @@ static inline void packet_set_ts(odp_packet_hdr_t *pkt_hdr, odp_time_t *ts) } } -int packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr, - uint32_t pkt_len, uint32_t seg_len, +int packet_parse_common(packet_parser_t *pkt_hdr, packet_parser_t *innner_prs, + const uint8_t *ptr, uint32_t pkt_len, uint32_t seg_len, odp_pktio_parser_layer_t layer); int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr); diff --git a/platform/linux-generic/odp_classification.c b/platform/linux-generic/odp_classification.c index 3dabb3873..cab74e159 100644 --- a/platform/linux-generic/odp_classification.c +++ b/platform/linux-generic/odp_classification.c @@ -856,8 +856,8 @@ int cls_classify_packet(pktio_entry_t *entry, const uint8_t *base, packet_parse_reset(pkt_hdr); packet_set_len(pkt_hdr, pkt_len); - packet_parse_common(&pkt_hdr->p, base, pkt_len, seg_len, - ODP_PKTIO_PARSER_LAYER_ALL); + packet_parse_common(&pkt_hdr->p, &pkt_hdr->inner_p, base, pkt_len, + seg_len, ODP_PKTIO_PARSER_LAYER_ALL); cos = cls_select_cos(entry, base, pkt_hdr); if (cos == NULL) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 04f1f33bb..d2cbf5b46 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -1982,12 +1983,31 @@ static inline void parse_tcp(packet_parser_t *prs, *parseptr += (uint32_t)tcp->hl * 4; } +static inline void parse_vxlan(packet_parser_t *prs, packet_parser_t *in_prs, + const uint8_t **parseptr, uint32_t *offset, + uint32_t frame_len, uint32_t seg_len) +{ + const _odp_vxlanhdr_t *vxlan = (const _odp_vxlanhdr_t *)*parseptr; + + if (ODPH_VXLAN_BIT(vxlan->flags)) + prs->input_flags.vxlan = 1; + + if (offset) + *offset += sizeof(_odp_vxlanhdr_t); + + *parseptr += sizeof(_odp_vxlanhdr_t); + packet_parse_common(in_prs, prs, *parseptr, frame_len, seg_len, + ODP_PKTIO_PARSER_LAYER_L4); +} + /** * Parser helper function for UDP */ -static inline void parse_udp(packet_parser_t *prs, - const uint8_t **parseptr, uint32_t *offset) +static inline void parse_udp(packet_parser_t *prs, packet_parser_t *in_p, + const uint8_t **parseptr, uint32_t *offset, + uint32_t frame_len, uint32_t seg_len) { + uint16_t dport; const _odp_udphdr_t *udp = (const _odp_udphdr_t *)*parseptr; uint32_t udplen = odp_be_to_cpu_16(udp->length); @@ -1996,7 +2016,10 @@ static inline void parse_udp(packet_parser_t *prs, if (offset) *offset += sizeof(_odp_udphdr_t); - *parseptr += sizeof(_odp_udphdr_t); + *parseptr += _ODP_UDPHDR_LEN; + dport = odp_be_to_cpu_16(udp->dst_port); + if (dport == _ODP_UDP_VXLAN_PORT) + parse_vxlan(prs, in_p, parseptr, offset, frame_len, seg_len); } /** @@ -2005,9 +2028,9 @@ static inline void parse_udp(packet_parser_t *prs, * The function expects at least PACKET_PARSE_SEG_LEN bytes of data to be * available from the ptr. */ -int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, - uint32_t frame_len, uint32_t seg_len, - odp_pktio_parser_layer_t layer) +int packet_parse_common(packet_parser_t *prs, packet_parser_t *inner_prs, + const uint8_t *ptr, uint32_t frame_len, + uint32_t seg_len, odp_pktio_parser_layer_t layer) { uint32_t offset; uint16_t ethtype; @@ -2142,7 +2165,7 @@ int packet_parse_common(packet_parser_t *prs, const uint8_t *ptr, if (odp_unlikely(offset + _ODP_UDPHDR_LEN > seg_len)) return -1; prs->input_flags.udp = 1; - parse_udp(prs, &parseptr, NULL); + parse_udp(prs, inner_prs, &parseptr, NULL, frame_len, seg_len); break; case _ODP_IPPROTO_AH: @@ -2177,8 +2200,8 @@ int packet_parse_layer(odp_packet_hdr_t *pkt_hdr, uint32_t seg_len = packet_first_seg_len(pkt_hdr); void *base = packet_data(pkt_hdr); - return packet_parse_common(&pkt_hdr->p, base, pkt_hdr->frame_len, - seg_len, layer); + return packet_parse_common(&pkt_hdr->p, &pkt_hdr->inner_p, base, + pkt_hdr->frame_len, seg_len, layer); } uint64_t odp_packet_to_u64(odp_packet_t hdl) diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index 2e26ad601..e58850431 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -78,6 +78,11 @@ int odp_packet_has_vlan(odp_packet_t pkt) retflag(pkt, input_flags.vlan); } +int odp_packet_has_vxlan(odp_packet_t pkt) +{ + retflag(pkt, input_flags.vxlan); +} + int odp_packet_has_vlan_qinq(odp_packet_t pkt) { retflag(pkt, input_flags.vlan_qinq); @@ -271,6 +276,11 @@ void odp_packet_has_udp_set(odp_packet_t pkt, int val) setflag(pkt, input_flags.udp, val); } +void odp_packet_has_vxlan_set(odp_packet_t pkt, int val) +{ + setflag(pkt, input_flags.vxlan, val); +} + void odp_packet_has_tcp_set(odp_packet_t pkt, int val) { setflag(pkt, input_flags.tcp, val); From patchwork Thu Dec 14 17:00:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 121993 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7065215qgn; Thu, 14 Dec 2017 09:03:00 -0800 (PST) X-Google-Smtp-Source: ACJfBovzLVhmTD5jFJ4VrI9UN1NLFdaTS/Czhgm3VfnYY+MkGA7ulWZRYJ1tizDbbP+S+fwD8UKt X-Received: by 10.200.51.107 with SMTP id u40mr17691572qta.152.1513270980518; Thu, 14 Dec 2017 09:03:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513270980; cv=none; d=google.com; s=arc-20160816; b=0fm/62GlZ3mV3gBe6ehN6HXb7U7jKWGVLuyj2lOyyZPwTDIQCaNJjUmOB/6nnfbTjy abJ+cEo1DFjQqAx0GS6kM6w9szrobXY171dUvIcX8aDHnojRZLfbJSsFTR5EssgrSQH0 YvhZKE3Suhxq4PJp49FGCuF/J92QFeaZjh0czWLaIW7OpkK3XONbL3ZS60GVubw2UPpu QZPyGbtAzId95rg8xH+UKktGJS5lpPbdnt3GRpIkPHDg8FnsICa0DjOF+Bata6Rn3bW5 Fn9rMSqIQ//n1sQxeimzMSZJYgqbNTGIHuKwM+/LLzfuoAKg9v9zpniYh46aZ8r3L6dM gCcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=mGoWE7ohYCANIqvzpYax2mHTwxFXA+2zJMKRmiqFY6w=; b=uEI5Gfo7jIpf+lX80RWQB1Rd923iEYaKKIbTS2ZthJuVWe0/7oGHERi+9ECcttQ1Rb FeglHYdD+sf7d90jtK9V+bBW4Wm8b7cS/X5BVbDN0QNn16T3TxF/fq5q/yqMGO6aBDiJ Jj2Hoty9omueGQEPZobqY9nUA8zFpBI71CQ/szJ1sehj77iJo0xaQn8vIxsM/iAjGSpr mq94ycRzFs7ZfO1onFXXUv+NDS7Z0eBx/62/qibQUQYl5/e7kBk5ddMafwWQkzwqMPRx bk47ANWomYxqiNiV5EyqRT4uS95qlysLExnBAqNGJmQAsI4bLEzaYMlcP56047zBpufP UJBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id d55si766996qte.83.2017.12.14.09.03.00; Thu, 14 Dec 2017 09:03:00 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id E43B860973; Thu, 14 Dec 2017 17:02:59 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 BC66E6097B; Thu, 14 Dec 2017 17:00:32 +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 861D960926; Thu, 14 Dec 2017 17:00:19 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id BDC9E6084F for ; Thu, 14 Dec 2017 17:00:15 +0000 (UTC) Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 3CD141344024 for ; Thu, 14 Dec 2017 20:00:14 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 3a3jRRdRik-0EYagj6b; Thu, 14 Dec 2017 20:00:14 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id P3vbKkCfK1-0DrGKkia; Thu, 14 Dec 2017 20:00:13 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 20:00:10 +0300 Message-Id: <1513270810-29728-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> References: <1513270810-29728-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 345 Subject: [lng-odp] [PATCH v2 4/4] validation: cls: add test case for LD_VNI pmr term 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" From: Balasubramanian Manoharan Add test case for ODP_PMR_TERM_LD_VNI. Signed-off-by: Balasubramanian Manoharan --- /** Email created from pull request 345 (bala-manoharan:BUG2903) ** https://github.com/Linaro/odp/pull/345 ** Patch: https://github.com/Linaro/odp/pull/345.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 65c561d30ea4c8c5f8ae17c2b407df9c6cc35f3d **/ .../validation/api/classification/classification.h | 1 + .../api/classification/odp_classification_common.c | 98 ++++++++++++++++-- .../classification/odp_classification_test_pmr.c | 114 +++++++++++++++++++++ .../classification/odp_classification_testsuites.h | 1 + 4 files changed, 206 insertions(+), 8 deletions(-) diff --git a/test/validation/api/classification/classification.h b/test/validation/api/classification/classification.h index 326177ad8..8d1f174b6 100644 --- a/test/validation/api/classification/classification.h +++ b/test/validation/api/classification/classification.h @@ -100,6 +100,7 @@ void classification_test_pmr_term_dmac(void); void classification_test_pmr_term_packet_len(void); void classification_test_pmr_term_vlan_id_0(void); void classification_test_pmr_term_vlan_id_x(void); +void classification_test_pmr_term_ld_vni(void); void classification_test_pmr_term_eth_type_0(void); void classification_test_pmr_term_eth_type_x(void); void classification_test_pktin_classifier_flag(void); diff --git a/test/validation/api/classification/odp_classification_common.c b/test/validation/api/classification/odp_classification_common.c index 60e20ea87..314843675 100644 --- a/test/validation/api/classification/odp_classification_common.c +++ b/test/validation/api/classification/odp_classification_common.c @@ -107,8 +107,23 @@ int cls_pkt_set_seq(odp_packet_t pkt) CU_ASSERT_FATAL(offset != ODP_PACKET_OFFSET_INVALID); if (ip->proto == ODPH_IPPROTO_UDP) - status = odp_packet_copy_from_mem(pkt, offset + ODPH_UDPHDR_LEN, - sizeof(data), &data); + if (odp_packet_has_vxlan(pkt)) { + /* TODO: Inner header parsing is not supported + * in this ODP release. Hence the packet parsing + * is skipped. This code has to be modifies once + * inner header parsing support is added */ + + /* skipping inner header for Vxlan */ + offset += ODPH_UDPHDR_LEN; + offset += ODPH_ETHADDR_LEN; + offset += ODPH_IPV4HDR_LEN; + offset += ODPH_TCPHDR_LEN; + status = odp_packet_copy_from_mem(pkt, offset, + sizeof(data), &data); + } else + status = odp_packet_copy_from_mem(pkt, offset + + ODPH_UDPHDR_LEN, + sizeof(data), &data); else { tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL); status = odp_packet_copy_from_mem(pkt, offset + tcp->hl * 4, @@ -132,8 +147,19 @@ uint32_t cls_pkt_get_seq(odp_packet_t pkt) return TEST_SEQ_INVALID; if (ip->proto == ODPH_IPPROTO_UDP) - odp_packet_copy_to_mem(pkt, offset + ODPH_UDPHDR_LEN, - sizeof(data), &data); + /* get packet magic from inner header */ + if (odp_packet_has_vxlan(pkt)) { + /* skipping inner header for Vxlan */ + offset += ODPH_UDPHDR_LEN; + offset += ODPH_ETHADDR_LEN; + offset += ODPH_IPV4HDR_LEN; + offset += ODPH_TCPHDR_LEN; + odp_packet_copy_to_mem(pkt, offset, + sizeof(data), &data); + } else { + odp_packet_copy_to_mem(pkt, offset + ODPH_UDPHDR_LEN, + sizeof(data), &data); + } else { tcp = (odph_tcphdr_t *)odp_packet_l4_ptr(pkt, NULL); odp_packet_copy_to_mem(pkt, offset + tcp->hl * 4, @@ -249,9 +275,11 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) uint16_t l2_hdr_len = 0; uint16_t l3_hdr_len = 0; uint16_t l4_hdr_len = 0; + uint16_t vxlan_len; uint16_t eth_type; odp_u16be_t *vlan_type; odph_vlanhdr_t *vlan_hdr; + uint16_t inner_hdr_len; /* 48 bit ethernet address needs to be left shifted for proper value after changing to be*/ @@ -262,14 +290,16 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) payload_len = sizeof(cls_test_packet_t) + pkt_info.len; seqno = odp_atomic_fetch_inc_u32(pkt_info.seq); + inner_hdr_len = ODPH_ETHADDR_LEN + ODPH_IPV4HDR_LEN + ODPH_TCPHDR_LEN; vlan_hdr_len = pkt_info.vlan ? ODPH_VLANHDR_LEN : 0; vlan_hdr_len = pkt_info.vlan_qinq ? 2 * vlan_hdr_len : vlan_hdr_len; l3_hdr_len = pkt_info.ipv6 ? ODPH_IPV6HDR_LEN : ODPH_IPV4HDR_LEN; l4_hdr_len = pkt_info.udp ? ODPH_UDPHDR_LEN : ODPH_TCPHDR_LEN; eth_type = pkt_info.ipv6 ? ODPH_ETHTYPE_IPV6 : ODPH_ETHTYPE_IPV4; next_hdr = pkt_info.udp ? ODPH_IPPROTO_UDP : ODPH_IPPROTO_TCP; + vxlan_len = pkt_info.vxlan ? ODPH_VXLANHDR_LEN + inner_hdr_len : 0; l2_hdr_len = ODPH_ETHHDR_LEN + vlan_hdr_len; - l4_len = l4_hdr_len + payload_len; + l4_len = l4_hdr_len + payload_len + vxlan_len; l3_len = l3_hdr_len + l4_len; l2_len = l2_hdr_len + l3_len; packet_len = l2_len; @@ -351,9 +381,61 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) udp->length = odp_cpu_to_be_16(payload_len + ODPH_UDPHDR_LEN); udp->chksum = 0; odp_packet_has_udp_set(pkt, 1); - if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, NULL) != 0) { - LOG_ERR("odph_udp_tcp_chksum failed\n"); - return ODP_PACKET_INVALID; + + /* vxlan */ + if (pkt_info.vxlan) { + odph_vxlanhdr_t *vxlan; + uint32_t vni; + odph_ethhdr_t *eth; + odph_ipv4hdr_t *ipv4; + odph_tcphdr_t *tcp; + uint8_t *ptr; + + /* Outer header UDP chksum set to zero */ + udp->chksum = 0; + odp_packet_has_vxlan_set(pkt, 1); + vxlan = (odph_vxlanhdr_t *)(buf + l4_offset + + ODPH_UDPHDR_LEN); + ptr = (uint8_t *)vxlan; + vxlan->flags = 0x08; + vni = 1000 << 8; + vxlan->vni = odp_cpu_to_be_32(vni); + + /* inner header L2 */ + eth = (odph_ethhdr_t *)(ptr + ODPH_VXLANHDR_LEN); + ptr += ODPH_VXLANHDR_LEN; + memcpy(eth->src.addr, &src_mac, ODPH_ETHADDR_LEN); + memcpy(eth->dst.addr, &dst_mac_be, ODPH_ETHADDR_LEN); + eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4); + + /* inner header L3 */ + ipv4 = (odph_ipv4hdr_t *)(ptr + ODPH_ETHADDR_LEN); + parse_ipv4_string(CLS_DEFAULT_DADDR, &addr, &mask); + ipv4->dst_addr = odp_cpu_to_be_32(addr); + + parse_ipv4_string(CLS_DEFAULT_SADDR, &addr, &mask); + ipv4->src_addr = odp_cpu_to_be_32(addr); + ipv4->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN; + ipv4->id = odp_cpu_to_be_16(seqno); + ipv4->proto = next_hdr; + ipv4->tot_len = odp_cpu_to_be_16(l3_len); + ipv4->ttl = DEFAULT_TTL; + ptr += ODPH_IPV4HDR_LEN; + + /* inner header L4 */ + tcp = (odph_tcphdr_t *)(ptr + ODPH_IPV4HDR_LEN); + tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT); + tcp->dst_port = odp_cpu_to_be_16(CLS_DEFAULT_DPORT); + tcp->hl = ODPH_TCPHDR_LEN / 4; + tcp->cksm = 0; + odp_packet_has_tcp_set(pkt, 1); + ptr += ODPH_TCPHDR_LEN; + } else { + if (odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_GENERATE, + NULL) != 0) { + LOG_ERR("odph_udp_tcp_chksum failed\n"); + return ODP_PACKET_INVALID; + } } } else { tcp->src_port = odp_cpu_to_be_16(CLS_DEFAULT_SPORT); diff --git a/test/validation/api/classification/odp_classification_test_pmr.c b/test/validation/api/classification/odp_classification_test_pmr.c index 87d04b6be..4ae5bb628 100644 --- a/test/validation/api/classification/odp_classification_test_pmr.c +++ b/test/validation/api/classification/odp_classification_test_pmr.c @@ -1195,6 +1195,119 @@ void classification_test_pmr_term_vlan_id_x(void) odp_pktio_close(pktio); } +void classification_test_pmr_term_ld_vni(void) +{ + odp_packet_t pkt; + uint32_t seqno; + uint32_t val; + uint32_t mask; + int retval; + odp_pktio_t pktio; + odp_queue_t queue; + odp_queue_t retqueue; + odp_queue_t default_queue; + odp_cos_t default_cos; + odp_pool_t default_pool; + odp_pool_t pool; + odp_pool_t recvpool; + odp_pmr_t pmr; + odp_cos_t cos; + char cosname[ODP_COS_NAME_LEN]; + odp_cls_cos_param_t cls_param; + odp_pmr_param_t pmr_param; + odph_ethhdr_t *eth; + odph_udphdr_t *udp; + cls_packet_info_t pkt_info; + + val = 1000; + mask = 0xffff; + seqno = 0; + + pktio = create_pktio(ODP_QUEUE_TYPE_SCHED, pkt_pool, true); + CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID); + retval = start_pktio(pktio); + CU_ASSERT(retval == 0); + + configure_default_cos(pktio, &default_cos, + &default_queue, &default_pool); + + queue = queue_create("ld_vni", true); + CU_ASSERT_FATAL(queue != ODP_QUEUE_INVALID); + + pool = pool_create("ld_vni"); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + sprintf(cosname, "ld_vni"); + odp_cls_cos_param_init(&cls_param); + cls_param.pool = pool; + cls_param.queue = queue; + cls_param.drop_policy = ODP_COS_DROP_POOL; + + cos = odp_cls_cos_create(cosname, &cls_param); + CU_ASSERT_FATAL(cos != ODP_COS_INVALID); + + odp_cls_pmr_param_init(&pmr_param); + pmr_param.term = ODP_PMR_LD_VNI; + pmr_param.match.value = &val; + pmr_param.match.mask = &mask; + pmr_param.val_sz = sizeof(val); + + pmr = odp_cls_pmr_create(&pmr_param, 1, default_cos, cos); + CU_ASSERT(pmr != ODP_PMR_INVAL); + + pkt_info = default_pkt_info; + pkt_info.vlan = true; + pkt_info.udp = true; + pkt_info.vxlan = true; + pkt = create_packet(pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN); + odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); + udp = (odph_udphdr_t *)odp_packet_l4_ptr(pkt, NULL); + udp->dst_port = odp_cpu_to_be_16(ODPH_UDP_VXLAN_PORT); + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == pool); + CU_ASSERT(retqueue == queue); + odp_packet_free(pkt); + + /* Other packets delivered to default queue */ + pkt = create_packet(default_pkt_info); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + seqno = cls_pkt_get_seq(pkt); + CU_ASSERT(seqno != TEST_SEQ_INVALID); + eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, NULL); + odp_pktio_mac_addr(pktio, eth->src.addr, ODPH_ETHADDR_LEN); + odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); + + enqueue_pktio_interface(pkt, pktio); + + pkt = receive_packet(&retqueue, ODP_TIME_SEC_IN_NS); + CU_ASSERT_FATAL(pkt != ODP_PACKET_INVALID); + CU_ASSERT(seqno == cls_pkt_get_seq(pkt)); + recvpool = odp_packet_pool(pkt); + CU_ASSERT(recvpool == default_pool); + CU_ASSERT(retqueue == default_queue); + + odp_cos_destroy(cos); + odp_cos_destroy(default_cos); + odp_cls_pmr_destroy(pmr); + odp_packet_free(pkt); + stop_pktio(pktio); + odp_pool_destroy(default_pool); + odp_pool_destroy(pool); + odp_queue_destroy(queue); + odp_queue_destroy(default_queue); + odp_pktio_close(pktio); +} + void classification_test_pmr_term_eth_type_0(void) { odp_packet_t pkt; @@ -1956,6 +2069,7 @@ odp_testinfo_t classification_suite_pmr[] = { ODP_TEST_INFO(classification_test_pmr_term_packet_len), ODP_TEST_INFO(classification_test_pmr_term_vlan_id_0), ODP_TEST_INFO(classification_test_pmr_term_vlan_id_x), + ODP_TEST_INFO(classification_test_pmr_term_ld_vni), ODP_TEST_INFO(classification_test_pmr_term_eth_type_0), ODP_TEST_INFO(classification_test_pmr_term_eth_type_x), ODP_TEST_INFO(classification_test_pktin_classifier_flag), diff --git a/test/validation/api/classification/odp_classification_testsuites.h b/test/validation/api/classification/odp_classification_testsuites.h index e1624162f..6b449b40e 100644 --- a/test/validation/api/classification/odp_classification_testsuites.h +++ b/test/validation/api/classification/odp_classification_testsuites.h @@ -18,6 +18,7 @@ typedef struct cls_packet_info { bool vlan_qinq; odp_atomic_u32_t *seq; bool udp; + bool vxlan; bool ipv6; uint32_t len; } cls_packet_info_t;