From patchwork Thu Nov 9 12: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: 118436 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6501526qgn; Thu, 9 Nov 2017 04:04:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMZN8qc7yZ5umnjFAMQoPOr2VE2yyB3TZRx7NPd6dbALQ1SK2EL2aJL9/XOPPKWnj7eJwBAZ X-Received: by 10.200.26.216 with SMTP id h24mr317557qtk.175.1510229053724; Thu, 09 Nov 2017 04:04:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229053; cv=none; d=google.com; s=arc-20160816; b=a0CT/2UrhFeXwS1P7eB9BPjkAj6lNs2qEP5Qpi+1eHo6CHAbuABwFgXJbrYs6CKsWu 6wxbvPD3hy8wbbBmeOPuDmjBcAtTFB3how6EUrq+Nwv/lX0DPJAAClLrTfuDORHI/+EX dMffbNgx15tRW504gHknH9zlhuClQJEEePJ3Y4g6eCxdptZQS3ApJGpa60Qd59QBSzGN tFiCOTBiGuzRkjkNsOSOj5Z3BfL58glP0nvdUxJgPiLyiv1VNzuqwD+LzJsDC5rlBzHM pYJKlM6Egr6MiUxhlKjU43cKAN4/gwsZ9yyGUmYFy9fb/L4opw1pSpUx+HgmtzmT31yS rPdg== 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=t2DI2WcoJ9m1VPFSbpWa+UA4zz6AduXVxf3KrggUWyw=; b=KYGq6P4QcHGfk72Hb57WTtp00mbz/T+v2YAcZwHrBP8N/quQjpYBERItThtuUOKEa+ oZQQEJbW7LMXGA7TY3Eu6eOS4N2gqzyfLymHebY/goNi3AFMz8d1cVBsCPE8kIm7nD9B w+9yPiyCSCZ3K7Ry/gbiub8LxBE0ylKcMaTS2Z84+i1Lmm5zK51ASLN0vsY2d6SSnt7Q Vzqno7Md44Y2TRI8hOWu4gSGqshQK5QyxaPghref7uHvHI1TPXjZNnY+i9d0Ko8UM1l0 /DbpYnng58nH+snk8bG1KTej6LSQRhVqnCzc4FYOOMxuaT8NMpt3G4zXbMrpZPBGnOIW yM9A== 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 d26si6404550qte.37.2017.11.09.04.04.13; Thu, 09 Nov 2017 04:04:13 -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 6050C61022; Thu, 9 Nov 2017 12:04:13 +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 18E1460C71; Thu, 9 Nov 2017 12:02:35 +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 5FE056068B; Thu, 9 Nov 2017 12:02:16 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 3139B60B5A for ; Thu, 9 Nov 2017 12:00:20 +0000 (UTC) Received: from mxback14g.mail.yandex.net (mxback14g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:93]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 7DA361346CF7 for ; Thu, 9 Nov 2017 15:00:18 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback14g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id qkvTf1jR4C-0IBqPnHD; Thu, 09 Nov 2017 15:00:18 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bxb2c43GJ0-0GiOBBF9; Thu, 09 Nov 2017 15:00:16 +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, 9 Nov 2017 15:00:09 +0300 Message-Id: <1510228814-21692-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> References: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 273 Subject: [lng-odp] [PATCH API-NEXT v5 1/6] api: packet: add parse functions 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: Petri Savolainen Application may need help on packet parsing e.g. after decrypt or IP reassembly of a packet. Application specifies from where to start and where to stop parsing. Implementation may be vectorized (more efficient) when multiple packets are parsed together with the same parse requirements. Signed-off-by: Petri Savolainen --- /** Email created from pull request 273 (psavol:next-packet-parse) ** https://github.com/Linaro/odp/pull/273 ** Patch: https://github.com/Linaro/odp/pull/273.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 5ed52232b041f855c0e109143480b16ea467c7da **/ include/odp/api/spec/packet.h | 119 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index 3fc460641..b3f946fc0 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -72,6 +72,45 @@ extern "C" { */ /** + * Protocol + */ +typedef enum odp_proto_t { + /** No protocol defined */ + ODP_PROTO_NONE = 0, + + /** Ethernet (including VLAN) */ + ODP_PROTO_ETH, + + /** IP version 4 */ + ODP_PROTO_IPV4, + + /** IP version 6 */ + ODP_PROTO_IPV6 + +} odp_proto_t; + +/** + * Protocol layer + */ +typedef enum odp_proto_layer_t { + /** No layers */ + ODP_PROTO_LAYER_NONE = 0, + + /** Layer L2 protocols (Ethernet, VLAN, etc) */ + ODP_PROTO_LAYER_L2, + + /** Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc) */ + ODP_PROTO_LAYER_L3, + + /** Layer L4 protocols (UDP, TCP, SCTP) */ + ODP_PROTO_LAYER_L4, + + /** All layers */ + ODP_PROTO_LAYER_ALL + +} odp_proto_layer_t; + +/** * Packet API data range specifier */ typedef struct odp_packet_data_range { @@ -1140,6 +1179,86 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset, */ /** + * Packet parse parameters + */ +typedef struct odp_packet_parse_param_t { + /** Protocol header at parse starting point. Valid values for this + * field are: ODP_PROTO_ETH, ODP_PROTO_IPV4, ODP_PROTO_IPV6. */ + odp_proto_t proto; + + /** Continue parsing until this layer. Must be the same or higher + * layer than the layer of 'proto'. */ + odp_proto_layer_t layer; + + /** Flags to control payload data checks up to the selected parse + * layer. Checksum checking status can be queried for each packet with + * odp_packet_l3_chksum_status() and odp_packet_l4_chksum_status(). + */ + union { + struct { + /** Check IPv4 header checksum */ + uint32_t ipv4_chksum : 1; + + /** Check UDP checksum */ + uint32_t udp_chksum : 1; + + /** Check TCP checksum */ + uint32_t tcp_chksum : 1; + + /** Check SCTP checksum */ + uint32_t sctp_chksum : 1; + + } check; + + /** All check bits. This can be used to set/clear all flags. */ + uint32_t all_check; + }; + +} odp_packet_parse_param_t; + +/** + * Parse packet + * + * Parse protocol headers in packet data. Parsing starts at 'offset', which + * is the first header byte of protocol 'param.proto'. Parameter 'param.layer' + * defines the last layer application is interested about. + * Use ODP_PROTO_LAYER_ALL for all layers. A successful operation sets or resets + * packet metadata for all layers from the layer of 'param.proto' to the + * application defined last layer. Metadata of other layers have undefined + * values. When operation fails, metadata of all protocol layers have undefined + * values. + * + * @param pkt Packet handle + * @param offset Byte offset into the packet + * @param param Parse parameters. Proto and layer fields must be set. Clear + * all check bits that are not used. + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_packet_parse(odp_packet_t pkt, uint32_t offset, + const odp_packet_parse_param_t *param); + +/** + * Parse multiple packets + * + * Otherwise like odp_packet_parse(), but parses multiple packets. Packets may + * have unique offsets, but must start with the same protocol. Also, packets are + * parsed up to the same protocol layer. + * + * @param pkt Packet handle array + * @param offset Byte offsets into the packets + * @param num Number of packets and offsets + * @param param Parse parameters. Proto and layer fields must be set. Clear + * all check bits that are not used. + * + * @return Number of packets parsed successfully (0 ... num) + * @retval <0 on failure + */ +int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[], + int num, const odp_packet_parse_param_t *param); + +/** * Packet pool * * Returns handle to the packet pool where the packet was allocated from. From patchwork Thu Nov 9 12: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: 118435 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6500404qgn; Thu, 9 Nov 2017 04:03:28 -0800 (PST) X-Google-Smtp-Source: AGs4zMbeOeoxHsomcQncy5sH1YDPGeYqgJ3Bt1R5lY+lMNYZxUQjx8Ftyvl6DpOWyAOFsyRYvxhI X-Received: by 10.55.137.198 with SMTP id l189mr323145qkd.169.1510229007996; Thu, 09 Nov 2017 04:03:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229007; cv=none; d=google.com; s=arc-20160816; b=di4x878P0r6k4gpz9VIQszytlDJm521Esb8qACXs47GVHsOaVsZsCyH8k0raJ1uFW6 VqXmiowwva2te9FJKCiASFRgyj0OJvZW10kyZ0FwWyKGvxz+lalOBxra5r894W2puzvA 6j1sH5OotkT2Go8z6MlTa3bBtmKILvG5LWcEA5by8khZSpJ6CgKYYAjCgtJAuEc23T8g ANeoohIaarlNycKq5K4UVrTGHoqin+9lG/0RAAPxpWbGNDISOtPXQkgin6hibsbGEsyd R0DVZEwNa7mcIPf29UUy/FfsdL+55oo1L8O/YzboWBoOUk4YIcRRcG383e3HS754v2ah piYg== 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=I1YBZEcKu8hmNApzSGpBffUrXBYfQGw61qHVY696gDs=; b=B3oiwgw2vjbzWzh2TPYHTHQOaN82P/mmZ7lJXcySeoIWDLCY67d62Sx9787LLR8qJw qBinFlJ1ihxdPiqVH2p6Wc2sIKD25HRUhWRo30Za/hVKEH8WiGAcGEeGL8fF4Xhv7DWC JnqkIpthBFS7zDQJ7D5+hEDfCzq6rFnuO4TwPlOGWQpwDiokDP1N5E3K1b8z5+/z3sXJ TUeI6/qCDF1Qm8W9PMX2WLl7jEkrQ4VV1Cd0Zwz62r/+iacsPW8bXWFlpubWgd+t/Gu7 Ly4qHFsZ46yRSy2rsJVHMCuX29hFgdgc7/pdRq0vL3RoGWSH+dVeH4UN4obrCdXC9fWU ti7g== 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 x204si6060232qka.135.2017.11.09.04.03.27; Thu, 09 Nov 2017 04:03:27 -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 954DD60E25; Thu, 9 Nov 2017 12:03: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=-5.4 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 BBBFA60C1C; Thu, 9 Nov 2017 12:02:31 +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 A471960C18; Thu, 9 Nov 2017 12:02:12 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id DED8B60FFF for ; Thu, 9 Nov 2017 12:00:20 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 3E719588569C for ; Thu, 9 Nov 2017 15:00:19 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id Q5vgiyMxq3-0JLCJvYo; Thu, 09 Nov 2017 15:00:19 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bxb2c43GJ0-0IiqkMGW; Thu, 09 Nov 2017 15:00:18 +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, 9 Nov 2017 15:00:10 +0300 Message-Id: <1510228814-21692-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> References: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 273 Subject: [lng-odp] [PATCH API-NEXT v5 2/6] api: pktio: use common protocol layer enum 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: Petri Savolainen Use common values between pktio parser layer and packet protocol layer enums. Signed-off-by: Petri Savolainen --- /** Email created from pull request 273 (psavol:next-packet-parse) ** https://github.com/Linaro/odp/pull/273 ** Patch: https://github.com/Linaro/odp/pull/273.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 5ed52232b041f855c0e109143480b16ea467c7da **/ include/odp/api/spec/packet_io.h | 11 ++++++----- platform/linux-generic/include/odp/api/plat/packet_inlines.h | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h index 52af646a6..6e4f88100 100644 --- a/include/odp/api/spec/packet_io.h +++ b/include/odp/api/spec/packet_io.h @@ -23,6 +23,7 @@ extern "C" { #include #include #include +#include /** @defgroup odp_packet_io ODP PACKET IO * Operations on a packet Input/Output interface. @@ -381,19 +382,19 @@ typedef union odp_pktout_config_opt_t { */ typedef enum odp_pktio_parser_layer_t { /** No layers */ - ODP_PKTIO_PARSER_LAYER_NONE = 0, + ODP_PKTIO_PARSER_LAYER_NONE = ODP_PROTO_LAYER_NONE, /** Layer L2 protocols (Ethernet, VLAN, ARP, etc) */ - ODP_PKTIO_PARSER_LAYER_L2, + ODP_PKTIO_PARSER_LAYER_L2 = ODP_PROTO_LAYER_L2, /** Layer L3 protocols (IPv4, IPv6, ICMP, IPsec, etc) */ - ODP_PKTIO_PARSER_LAYER_L3, + ODP_PKTIO_PARSER_LAYER_L3 = ODP_PROTO_LAYER_L3, /** Layer L4 protocols (UDP, TCP, SCTP) */ - ODP_PKTIO_PARSER_LAYER_L4, + ODP_PKTIO_PARSER_LAYER_L4 = ODP_PROTO_LAYER_L4, /** All layers */ - ODP_PKTIO_PARSER_LAYER_ALL + ODP_PKTIO_PARSER_LAYER_ALL = ODP_PROTO_LAYER_ALL } odp_pktio_parser_layer_t; diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 1804fa6f2..22f5aca31 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -15,7 +15,9 @@ #include #include -#include +#include +#include +#include #include /** @internal Inline function offsets */ From patchwork Thu Nov 9 12:00:11 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: 118437 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6502507qgn; Thu, 9 Nov 2017 04:04:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMZmRmR899RVK9PTXN2u8CmRl7ANmf80yscH6AuC4pgNroVjYGbjbSpQu9cQnyKMSldQzFAV X-Received: by 10.55.129.70 with SMTP id c67mr359828qkd.230.1510229096179; Thu, 09 Nov 2017 04:04:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229096; cv=none; d=google.com; s=arc-20160816; b=Zpv3xeFlDjV7PMhEd+6yDu5YvgCteFfkdPmJx988xE0+/WYs1g9Y2SN40Od5rkuWw7 bnlzITSCj7vsQaeGTdKwu4wxHvMf6s7oDKn//RSCKlf5Yv3u7UAJX+UfZPwaoWN4cC/W 2ePcnsZZEbOhrkfaEaRml+ULpdwHKm80WAMTP7Wn2JDn0z98jbJokBt3aZyHcKC7GdVx Ly8K22HeP5bL9YxN7Amh2V1HRlz+AjKhraoa/Swb6CEk/PVvDHB8TAlq7wXqmfQ/qxdp WUN+NfgE+7S1h28FBPD2srSPyiHGnec4JA+R8DxfhEf+A8z2HSUZ26FRspHGOf+1RKHw kLRQ== 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=1W6OJiUqxoUqVRtdeZLiXZbY/jrhAChIpA2y20lthY0=; b=pT+VRUwfk9kurL9IYuWCDtNRM2Y0ewK4oD1DG5Fb32wiYaYteG2nqPAmtjmWqMgQOd jEKkSpIHaHulxuQ5OAQYAhDMsiNDka+mcwD6yR1dJ8iC44NVE9dQGiSJjSyzt4nb/WvE 4G3UK5xI9A5RvOpwLoJefqJwoiGkH2TnxMvhrmKt4ZshFEV+NWzDnNGFlqwk5VEPXpay lPmQaUkZJJ/nUgtRBSfFBBkv72WOq+DjAETAz0vLo6siPNnrjttDlMUha5PZ7eFFPJt2 boTtf5qQmTC9R09Fd91hLtQXmiwpJ/GS2CaVGRzUrHl8YNHoEz9Z+K5p13GO7KeaHgU6 a5LA== 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 i15si5743292qte.371.2017.11.09.04.04.55; Thu, 09 Nov 2017 04:04:56 -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 355B661006; Thu, 9 Nov 2017 12:04:55 +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=-5.4 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 559F060C12; Thu, 9 Nov 2017 12:02:41 +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 A497160C18; Thu, 9 Nov 2017 12:02:19 +0000 (UTC) Received: from forward105o.mail.yandex.net (forward105o.mail.yandex.net [37.140.190.183]) by lists.linaro.org (Postfix) with ESMTPS id BA3F760C12 for ; Thu, 9 Nov 2017 12:00:21 +0000 (UTC) Received: from mxback20j.mail.yandex.net (mxback20j.mail.yandex.net [IPv6:2a02:6b8:0:1619::114]) by forward105o.mail.yandex.net (Yandex) with ESMTP id E8E824444BAE for ; Thu, 9 Nov 2017 15:00:19 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback20j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id KIyCpDlBr2-0Ji04IEQ; Thu, 09 Nov 2017 15:00:19 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bxb2c43GJ0-0JiSU4Xi; Thu, 09 Nov 2017 15:00:19 +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, 9 Nov 2017 15:00:11 +0300 Message-Id: <1510228814-21692-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> References: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 273 Subject: [lng-odp] [PATCH API-NEXT v5 3/6] api: ipsec: use common protocol layer enum 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: Petri Savolainen Use common values between ipsec parse and packet protocol layer enums. Signed-off-by: Petri Savolainen --- /** Email created from pull request 273 (psavol:next-packet-parse) ** https://github.com/Linaro/odp/pull/273 ** Patch: https://github.com/Linaro/odp/pull/273.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 5ed52232b041f855c0e109143480b16ea467c7da **/ include/odp/api/spec/ipsec.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h index 26e852fca..4a33af8ea 100644 --- a/include/odp/api/spec/ipsec.h +++ b/include/odp/api/spec/ipsec.h @@ -74,19 +74,19 @@ typedef enum odp_ipsec_op_mode_t { */ typedef enum odp_ipsec_proto_layer_t { /** No layers */ - ODP_IPSEC_LAYER_NONE = 0, + ODP_IPSEC_LAYER_NONE = ODP_PROTO_LAYER_NONE, /** Layer L2 protocols (Ethernet, VLAN, etc) */ - ODP_IPSEC_LAYER_L2, + ODP_IPSEC_LAYER_L2 = ODP_PROTO_LAYER_L2, /** Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc) */ - ODP_IPSEC_LAYER_L3, + ODP_IPSEC_LAYER_L3 = ODP_PROTO_LAYER_L3, /** Layer L4 protocols (UDP, TCP, SCTP) */ - ODP_IPSEC_LAYER_L4, + ODP_IPSEC_LAYER_L4 = ODP_PROTO_LAYER_L4, /** All layers */ - ODP_IPSEC_LAYER_ALL + ODP_IPSEC_LAYER_ALL = ODP_PROTO_LAYER_ALL } odp_ipsec_proto_layer_t; From patchwork Thu Nov 9 12:00:12 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: 118441 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6505518qgn; Thu, 9 Nov 2017 04:07:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMbWh7peGet9mKuE/UKM3KIgPOKrf0TuE0Ef+6gaZ/jQFYVtsw3Z4uJg9xbNCMhXq2g+dcge X-Received: by 10.200.33.199 with SMTP id 7mr347251qtz.35.1510229238874; Thu, 09 Nov 2017 04:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229238; cv=none; d=google.com; s=arc-20160816; b=h2UknLSF5UCxxxGm9v0vYU44547heattCoIFztuPmNcxhfiuIlW0r+eGuzQXVGn3Kk ei0pTDTsSDjX/MBrb66KroQtpGIEQ+qPlt1F4ac7Oo5KQR362Hel5FsOM6s0W/B0RMJd iWQ0hqNfI+C+AeCEzAmLLJfqDkxOzS1NzNKEYFjvnnCDuG7mJ2l0Qay/2W93EwgLSZtv R910B0c+qc4FQAR1RBWfz4eFvSA+Nj66SU6J4Pb4YdfVSKzOKEJH+z08D2BfmgZBrh15 ZIEfdBk1uEFyWX/c5CEKJoYnuurpOjsOZQt3+MKToyhE9AWXlEiJ7WBhbCeqYM1T9/Ed NSNw== 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=8kMOoQpf2EvEup3dRCrKMKpJKlc6g9CzLdOGFcuT3jY=; b=dv0xXgrJ99jo1Il67wktFUShXEBbVTNI7g1gfNjW17IY/jeLka5vVTsHP34zdSjAIZ WekWtuO2FUQ4ft0CrvFApfGhHTmG5RN5z/rZwdjR/ZiTElW1NPUeYUKfXnCmO7KiOb4K sL0en4wanIops3QY/YPzRSiFawSD8XmEv0ANL4EB4uciP/oP0/f6cCXdo36KdinIOyjt F3Yy2XrkHcdXR/WT6818WbEQl2fsSctbI8EDYntWz2tExgieEGkUWlbp5iS2r9Xogndw 5srij0X8v3XpEWI7WoTj2CesSpOSBMGBJQp1jeFLKd6wdyLNxs6NM8tHrqH3o+eqGmg/ pbVA== 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 w31si6239904qtb.74.2017.11.09.04.07.18; Thu, 09 Nov 2017 04:07:18 -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 8111260D77; Thu, 9 Nov 2017 12:07:18 +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=-5.4 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 38E6C6100A; Thu, 9 Nov 2017 12:02:56 +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 F41EE60CCA; Thu, 9 Nov 2017 12:02:26 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 2FA6D60FFD for ; Thu, 9 Nov 2017 12:00:22 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward106p.mail.yandex.net (Yandex) with ESMTP id ADB972D84C8F for ; Thu, 9 Nov 2017 15:00:20 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 4sHIrXqs6R-0KgKGLkP; Thu, 09 Nov 2017 15:00:20 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bxb2c43GJ0-0JiCDXVj; Thu, 09 Nov 2017 15:00:20 +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, 9 Nov 2017 15:00:12 +0300 Message-Id: <1510228814-21692-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> References: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 273 Subject: [lng-odp] [PATCH API-NEXT v5 4/6] linux-gen: packet: add parse API 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: Petri Savolainen Implemented new API functions for packet parsing. Signed-off-by: Petri Savolainen --- /** Email created from pull request 273 (psavol:next-packet-parse) ** https://github.com/Linaro/odp/pull/273 ** Patch: https://github.com/Linaro/odp/pull/273.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 5ed52232b041f855c0e109143480b16ea467c7da **/ .../linux-generic/include/odp_packet_internal.h | 3 +- platform/linux-generic/odp_packet.c | 62 ++++++++++++++++++++-- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index fed562aa3..97efcec4b 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -322,8 +322,7 @@ 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, - odp_pktio_parser_layer_t layer); + uint32_t pkt_len, uint32_t seg_len, int layer); int _odp_cls_parse(odp_packet_hdr_t *pkt_hdr, const uint8_t *parseptr); diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 3b2fac212..0bba30986 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2098,8 +2098,7 @@ static inline int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, uint32_t offset, uint32_t frame_len, uint32_t seg_len, - odp_pktio_parser_layer_t layer, - uint16_t ethtype) + int layer, uint16_t ethtype) { uint8_t ip_proto; @@ -2199,7 +2198,7 @@ int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr, */ 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 layer) { uint32_t offset; uint16_t ethtype; @@ -2252,6 +2251,63 @@ int packet_parse_l3_l4(odp_packet_hdr_t *pkt_hdr, layer, ethtype); } +int odp_packet_parse(odp_packet_t pkt, uint32_t offset, + const odp_packet_parse_param_t *param) +{ + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); + void *data; + uint32_t seg_len; + uint32_t packet_len = pkt_hdr->frame_len; + odp_proto_t proto = param->proto; + odp_proto_layer_t layer = param->layer; + int ret; + uint16_t ethtype; + + if (proto == ODP_PROTO_NONE || layer == ODP_PROTO_LAYER_NONE) + return -1; + + data = packet_map(pkt_hdr, offset, &seg_len, NULL); + + if (data == NULL) + return -1; + + packet_parse_reset(pkt_hdr); + + if (proto == ODP_PROTO_ETH) { + ret = packet_parse_common(&pkt_hdr->p, data, packet_len, + seg_len, layer); + + if (ret) + return -1; + } else { + if (proto == ODP_PROTO_IPV4) + ethtype = _ODP_ETHTYPE_IPV4; + else + ethtype = _ODP_ETHTYPE_IPV6; + + ret = packet_parse_common_l3_l4(&pkt_hdr->p, data, offset, + packet_len, seg_len, + layer, ethtype); + + if (ret) + return -1; + } + + return 0; +} + +int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[], + int num, const odp_packet_parse_param_t *param) +{ + int i; + + for (i = 0; i < num; i++) + if (odp_packet_parse(pkt[i], offset[i], param)) + return i; + + return num; +} + uint64_t odp_packet_to_u64(odp_packet_t hdl) { return _odp_pri(hdl); From patchwork Thu Nov 9 12:00:13 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: 118438 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6503539qgn; Thu, 9 Nov 2017 04:05:42 -0800 (PST) X-Google-Smtp-Source: AGs4zMbVBSfwZfJV8Acgt/u22gvh6JiP8I+e6iWOwEBQjwjBtjGNRsSvx6wFMPurGw31V1h0xyib X-Received: by 10.200.0.81 with SMTP id i17mr336726qtg.308.1510229142185; Thu, 09 Nov 2017 04:05:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229142; cv=none; d=google.com; s=arc-20160816; b=GBzLWJw8xjfnHUTilDwLxMvfzLwJ654NpgD5X8RtaP2Ly7oLtkLbGuC6VVbEMCO4Cd vEiO2Ud9xjprcapWgf3DXHgg587fGc6FPW2ftT8qisxf9QY0DYU9/1lVCZwDFzwie76R UTIEcvcegA1tz1EZKUQn4TT5+x/iYMKaKHUP+M8BObkgU231djWWXgVCp6jAVfQe06pJ Zb3Zg7a8WMRt4uQRjo71HeFF8fJi5BGtHuXCFPcF9zjJnSwJoDpRGyiCjlsoUoABBCHV 0tLsAn1hHXNPMkpDn+HNq1EJ9MuqK0PvZGmJV+o/jA1SoVKBwwIvue/st4X1wp+P/m81 jScA== 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=gERa+ceC8X+o7JbXTEHUlUh39Nez/V+/if2jZ5+neaM=; b=bGA3M30kEpftDrCdFxjR3URy9actvqqDKuWNgDrEN0vKYkOr55VqDMZarK0gEDfQfU tdOHA0jEU4q9uDpJI05H/Frlnpy/EJGj8SxNtyJ3STNHLWUxM3Sn/tJca31iXha8tvNp o7kA/O1aYUNScokNfx+HFtU6ZSddvbI0fB5AxFmMVJqawqKcDLv/wDEPplBHrC4lyRz2 84je+j4u/J+40kCOgtwcDiEO26wqrYhHrqqH9ObL5WLYD1ByR/r9wwACts25+o9zVbfX QlkHW3e2Nq6opZVXwS4UXMiwVOVbsateiRf7SVQWyaL+Cca62PDYkEzKVo5XwbHzrcrj rx7Q== 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 89si1904116qtf.286.2017.11.09.04.05.41; Thu, 09 Nov 2017 04:05:42 -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 A5C3060B18; Thu, 9 Nov 2017 12:05:41 +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=-5.4 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 9CC1660D77; Thu, 9 Nov 2017 12:02:47 +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 9AF5760CCA; Thu, 9 Nov 2017 12:02:24 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 7F02461001 for ; Thu, 9 Nov 2017 12:00:22 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 6DF6F2D852B5 for ; Thu, 9 Nov 2017 15:00:21 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 1WHMddLEBP-0Lg8FMZl; Thu, 09 Nov 2017 15:00:21 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bxb2c43GJ0-0KiSDp8D; Thu, 09 Nov 2017 15:00:20 +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, 9 Nov 2017 15:00:13 +0300 Message-Id: <1510228814-21692-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> References: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 273 Subject: [lng-odp] [PATCH API-NEXT v5 5/6] validation: pktio: add parser test packet header 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: Petri Savolainen Moved parser test packet definitions into a new, common header file. The same test packets can be used in various test suites. Signed-off-by: Petri Savolainen --- /** Email created from pull request 273 (psavol:next-packet-parse) ** https://github.com/Linaro/odp/pull/273 ** Patch: https://github.com/Linaro/odp/pull/273.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 5ed52232b041f855c0e109143480b16ea467c7da **/ test/common/Makefile.am | 2 +- test/common/test_packet_parser.h | 175 +++++++++++++++++++++++++++++++++++++ test/validation/api/pktio/parser.c | 1 + test/validation/api/pktio/parser.h | 149 ------------------------------- 4 files changed, 177 insertions(+), 150 deletions(-) create mode 100644 test/common/test_packet_parser.h diff --git a/test/common/Makefile.am b/test/common/Makefile.am index a3419e0f5..fbd5d52f4 100644 --- a/test/common/Makefile.am +++ b/test/common/Makefile.am @@ -14,5 +14,5 @@ libthrmask_common_la_CFLAGS = $(AM_CFLAGS) -DTEST_THRMASK endif -noinst_HEADERS = test_debug.h +noinst_HEADERS = test_debug.h test_packet_parser.h dist_test_SCRIPTS = run-test.sh diff --git a/test/common/test_packet_parser.h b/test/common/test_packet_parser.h new file mode 100644 index 000000000..918e0ad65 --- /dev/null +++ b/test/common/test_packet_parser.h @@ -0,0 +1,175 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Test packets for parser tests + */ + +#ifndef TEST_PACKET_PARSER_H_ +#define TEST_PACKET_PARSER_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Test packets without CRC */ + +/** + * ARP request + */ +static const uint8_t test_packet_arp[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x08, 0x06, 0x00, 0x01, + 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0xC0, 0xA8, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, + 0x01, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x10, 0x11 +}; + +/** + * ICMPv4 echo reply + */ +static const uint8_t test_packet_ipv4_icmp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, + 0xF3, 0x7B, 0xC0, 0xA8, 0x01, 0x01, 0xC4, 0xA8, + 0x01, 0x02, 0x00, 0x00, 0xB7, 0xAB, 0x00, 0x01, + 0x00, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x10, 0x11 +}; + +/** + * IPv4 TCP + */ +static const uint8_t test_packet_ipv4_tcp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x06, + 0xF3, 0x76, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, + 0x01, 0x01, 0x04, 0xD2, 0x10, 0xE1, 0x00, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x50, 0x00, + 0x00, 0x00, 0x0C, 0xCC, 0x00, 0x00, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05 +}; + +/** + * IPv4 UDP + */ +static const uint8_t test_packet_ipv4_udp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xF3, 0x6B, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, + 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1A, + 0x2F, 0x97, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, + 0x0E, 0x0F, 0x10, 0x11 +}; + +/** + * VLAN IPv4 UDP + * - ID: 23 + */ +static const uint8_t test_packet_vlan_ipv4_udp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x17, + 0x08, 0x00, 0x45, 0x00, 0x00, 0x2A, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x11, 0xF3, 0x6F, 0xC0, 0xA8, + 0x01, 0x02, 0xC4, 0xA8, 0x01, 0x01, 0x00, 0x3F, + 0x00, 0x3F, 0x00, 0x16, 0x4D, 0xBF, 0x00, 0x01, + 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, + 0x0A, 0x0B, 0x0C, 0x0D +}; + +/** + * VLAN Q-in-Q IPv4 UDP + * - Outer: Tag Protocol ID 0x88a8, VLAN ID 1 + * - Inner: Tag Protocol ID 0x8100, VLAN ID 2 + */ +static const uint8_t test_packet_vlan_qinq_ipv4_udp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x88, 0xA8, 0x00, 0x01, + 0x81, 0x00, 0x00, 0x02, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, + 0xF3, 0x73, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, + 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x12, + 0x63, 0xDF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09 +}; + +/** + * ICMPv6 echo request + */ +static const uint8_t test_packet_ipv6_icmp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, + 0x00, 0x00, 0x00, 0x08, 0x3A, 0xFF, 0xFE, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, + 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, + 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x80, 0x00, + 0x1B, 0xC2, 0x00, 0x01, 0x00, 0x02 +}; + +/** + * IPv6 TCP + */ +static const uint8_t test_packet_ipv6_tcp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, + 0x00, 0x00, 0x00, 0x14, 0x06, 0xFF, 0xFE, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, + 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, + 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x04, 0xD2, + 0x10, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x02, 0x50, 0x00, 0x00, 0x00, 0x36, 0x37, + 0x00, 0x00 +}; + +/** + * IPv6 UDP + */ +static const uint8_t test_packet_ipv6_udp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, + 0x00, 0x00, 0x00, 0x08, 0x11, 0xFF, 0xFE, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, + 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, + 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x00, 0x3F, + 0x00, 0x3F, 0x00, 0x08, 0x9B, 0x68 +}; + +/** + * VLAN IPv6 + * - ID: 23 + */ +static const uint8_t test_packet_vlan_ipv6_udp[] = { + 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x17, + 0x86, 0xDD, 0x60, 0x30, 0x00, 0x00, 0x00, 0x08, + 0x11, 0xFF, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x09, 0xFF, 0xFE, 0x00, + 0x04, 0x00, 0x35, 0x55, 0x55, 0x55, 0x66, 0x66, + 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x88, 0x88, + 0x88, 0x88, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x08, + 0x9B, 0x68 +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/test/validation/api/pktio/parser.c b/test/validation/api/pktio/parser.c index dd293a447..66e726d09 100644 --- a/test/validation/api/pktio/parser.c +++ b/test/validation/api/pktio/parser.c @@ -8,6 +8,7 @@ #include #include +#include #include diff --git a/test/validation/api/pktio/parser.h b/test/validation/api/pktio/parser.h index 5cc2b988c..d95ecca14 100644 --- a/test/validation/api/pktio/parser.h +++ b/test/validation/api/pktio/parser.h @@ -28,153 +28,4 @@ int parser_suite_init(void); /* test arrays: */ extern odp_testinfo_t parser_suite[]; -/* Test packets without CRC */ - -/** - * ARP request - */ -static const uint8_t test_packet_arp[] = { - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x06, 0x00, 0x01, - 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0xC0, 0xA8, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, - 0x01, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x10, 0x11 -}; - -/** - * ICMPv4 echo reply - */ -static const uint8_t test_packet_ipv4_icmp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01, - 0xF3, 0x7B, 0xC0, 0xA8, 0x01, 0x01, 0xC4, 0xA8, - 0x01, 0x02, 0x00, 0x00, 0xB7, 0xAB, 0x00, 0x01, - 0x00, 0x02, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x10, 0x11 -}; - -/** - * IPv4 TCP - */ -static const uint8_t test_packet_ipv4_tcp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x06, - 0xF3, 0x76, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, - 0x01, 0x01, 0x04, 0xD2, 0x10, 0xE1, 0x00, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x50, 0x00, - 0x00, 0x00, 0x0C, 0xCC, 0x00, 0x00, 0x00, 0x01, - 0x02, 0x03, 0x04, 0x05 -}; - -/** - * IPv4 UDP - */ -static const uint8_t test_packet_ipv4_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, - 0xF3, 0x6B, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, - 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1A, - 0x2F, 0x97, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, - 0x0E, 0x0F, 0x10, 0x11 -}; - -/** - * VLAN IPv4 UDP - * - ID: 23 - */ -static const uint8_t test_packet_vlan_ipv4_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x17, - 0x08, 0x00, 0x45, 0x00, 0x00, 0x2A, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x11, 0xF3, 0x6F, 0xC0, 0xA8, - 0x01, 0x02, 0xC4, 0xA8, 0x01, 0x01, 0x00, 0x3F, - 0x00, 0x3F, 0x00, 0x16, 0x4D, 0xBF, 0x00, 0x01, - 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, - 0x0A, 0x0B, 0x0C, 0x0D -}; - -/** - * VLAN Q-in-Q IPv4 UDP - * - Outer: Tag Protocol ID 0x88a8, VLAN ID 1 - * - Inner: Tag Protocol ID 0x8100, VLAN ID 2 - */ -static const uint8_t test_packet_vlan_qinq_ipv4_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x88, 0xA8, 0x00, 0x01, - 0x81, 0x00, 0x00, 0x02, 0x08, 0x00, 0x45, 0x00, - 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x40, 0x11, - 0xF3, 0x73, 0xC0, 0xA8, 0x01, 0x02, 0xC4, 0xA8, - 0x01, 0x01, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x12, - 0x63, 0xDF, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09 -}; - -/** - * ICMPv6 echo request - */ -static const uint8_t test_packet_ipv6_icmp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, - 0x00, 0x00, 0x00, 0x08, 0x3A, 0xFF, 0xFE, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, - 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, - 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x80, 0x00, - 0x1B, 0xC2, 0x00, 0x01, 0x00, 0x02 -}; - -/** - * IPv6 TCP - */ -static const uint8_t test_packet_ipv6_tcp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, - 0x00, 0x00, 0x00, 0x14, 0x06, 0xFF, 0xFE, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, - 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, - 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x04, 0xD2, - 0x10, 0xE1, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, - 0x00, 0x02, 0x50, 0x00, 0x00, 0x00, 0x36, 0x37, - 0x00, 0x00 -}; - -/** - * IPv6 UDP - */ -static const uint8_t test_packet_ipv6_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x86, 0xDD, 0x60, 0x30, - 0x00, 0x00, 0x00, 0x08, 0x11, 0xFF, 0xFE, 0x80, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, - 0x09, 0xFF, 0xFE, 0x00, 0x04, 0x00, 0x35, 0x55, - 0x55, 0x55, 0x66, 0x66, 0x66, 0x66, 0x77, 0x77, - 0x77, 0x77, 0x88, 0x88, 0x88, 0x88, 0x00, 0x3F, - 0x00, 0x3F, 0x00, 0x08, 0x9B, 0x68 -}; - -/** - * VLAN IPv6 - * - ID: 23 - */ -static const uint8_t test_packet_vlan_ipv6_udp[] = { - 0x00, 0x00, 0x09, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x17, - 0x86, 0xDD, 0x60, 0x30, 0x00, 0x00, 0x00, 0x08, - 0x11, 0xFF, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x02, 0x00, 0x09, 0xFF, 0xFE, 0x00, - 0x04, 0x00, 0x35, 0x55, 0x55, 0x55, 0x66, 0x66, - 0x66, 0x66, 0x77, 0x77, 0x77, 0x77, 0x88, 0x88, - 0x88, 0x88, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x08, - 0x9B, 0x68 -}; - #endif From patchwork Thu Nov 9 12:00:14 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: 118442 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6506718qgn; Thu, 9 Nov 2017 04:08:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMYDjKgzhlDBgmhvmqf4bVTHK6FaFsBlwJ3zwRerpT8iVM2cdcE1weA8RNsTFeY3tpYM1Bkz X-Received: by 10.200.23.196 with SMTP id r4mr376330qtk.158.1510229301442; Thu, 09 Nov 2017 04:08:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510229301; cv=none; d=google.com; s=arc-20160816; b=iZ7wCB9F36WnnwQ0mBHER41CABp2ZPqFMxfiLd+e5jxV0xQrqvRCEy1z7DCJBU20xm wXkdO2LVI6TEr4p7wfaqsc2m9NLhaWyMuRPNSejZEqcv+tYMLYfcKWJvAnFfKsR+Di6y ih+Pyx+4joGe5B9MixFHqkV3gXxIYj0s2c0/OGLk52CpHrPsiZE/TA4OLs7esyEb7KXG htKb4DldVLafYZU5pgURVOmBsoYYj0d7To78fsn8WldnpgyZIpenmHM+yfIXE177GUu2 BXv7OgsN+li81NNmByPvvc32/6jPk1T/XBT/n8cBReI4sy3HkwmbZ5OBMtZxrKa91w49 siMg== 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=ggxE1xJ2xffo8iqvsgPxtwXr5gd4u5coKUxU48BqWtQ=; b=mIBqy5RvfR6bcU2j0ct7+IwmSyTu8twqvoLhipGTeWHgO38aJMmBZ1XQff4ibKFadw 7qgvVGIM6DT31bcIZ02ctsOVxmsCmJXXThqCMPlGKgG3cYNdeZm6LB4nQE0V5cai1IYS vD5szQei7Q0mYzClCoeL+a15bDz6Wsgp2uaEuBiBrjW8hKcmuZR+58W3gYyPFfEPv1zk B96ts2MAh1JO9oT3spLzbWI0enUnF73jaXgrOJ39nUEwWdN+K20Ya0wE+byzA7ErnOCG BDb2bEuHFsa1Y8KLcBw1rJaiXg4RYiTSDKO+/5Crxjrx3rCUZ13hL16sWKBX5mkmO7Yz JdeQ== 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 r27si4270081qtj.352.2017.11.09.04.08.20; Thu, 09 Nov 2017 04:08:21 -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 BF0A060746; Thu, 9 Nov 2017 12:08:20 +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 7481561007; Thu, 9 Nov 2017 12:02:58 +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 946A760CCA; Thu, 9 Nov 2017 12:02:27 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id B43DF61002 for ; Thu, 9 Nov 2017 12:00:23 +0000 (UTC) Received: from mxback10o.mail.yandex.net (mxback10o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::24]) by forward100o.mail.yandex.net (Yandex) with ESMTP id EA5282A23781 for ; Thu, 9 Nov 2017 15:00:21 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback10o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id QJ2dj3fvWQ-0LJC8oxN; Thu, 09 Nov 2017 15:00:21 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id bxb2c43GJ0-0Li0cIwx; Thu, 09 Nov 2017 15:00:21 +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, 9 Nov 2017 15:00:14 +0300 Message-Id: <1510228814-21692-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> References: <1510228814-21692-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 273 Subject: [lng-odp] [PATCH API-NEXT v5 6/6] validation: packet: add parse tests 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: Petri Savolainen Added validation tests for the new packet parse APIs. Signed-off-by: Petri Savolainen --- /** Email created from pull request 273 (psavol:next-packet-parse) ** https://github.com/Linaro/odp/pull/273 ** Patch: https://github.com/Linaro/odp/pull/273.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 5ed52232b041f855c0e109143480b16ea467c7da **/ test/validation/api/packet/packet.c | 197 ++++++++++++++++++++++++++++++++++++ test/validation/api/packet/packet.h | 1 + 2 files changed, 198 insertions(+) diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index 37550a2f5..f96347b55 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -10,6 +10,7 @@ #include #include +#include #include "packet.h" /* Reserve some tailroom for tests */ @@ -2390,6 +2391,201 @@ void packet_test_ref(void) odp_packet_free(ref_pkt[1]); } +void packet_test_parse(void) +{ + odp_pool_t pool; + odp_pool_param_t param; + odp_packet_parse_param_t parse; + int ret, num_test_pkt, i; + uint32_t len, max_len; + int num_pkt = 10; + odp_packet_t pkt[num_pkt]; + uint32_t offset[num_pkt]; + uint32_t test_pkt_len[] = {sizeof(test_packet_arp), + sizeof(test_packet_ipv4_icmp), + sizeof(test_packet_ipv4_tcp), + sizeof(test_packet_ipv4_udp), + sizeof(test_packet_vlan_ipv4_udp), + sizeof(test_packet_vlan_qinq_ipv4_udp), + sizeof(test_packet_ipv6_icmp), + sizeof(test_packet_ipv6_tcp), + sizeof(test_packet_ipv6_udp), + sizeof(test_packet_vlan_ipv6_udp) }; + + num_test_pkt = sizeof(test_pkt_len) / sizeof(uint32_t); + max_len = 0; + + for (i = 0; i < num_test_pkt; i++) { + if (max_len < test_pkt_len[i]) + max_len = test_pkt_len[i]; + } + + odp_pool_param_init(¶m); + + param.type = ODP_POOL_PACKET; + param.pkt.seg_len = max_len; + param.pkt.len = max_len; + param.pkt.num = 100; + + pool = odp_pool_create("test_parse_pool", ¶m); + CU_ASSERT_FATAL(pool != ODP_POOL_INVALID); + + /* Ethernet/IPv4/UDP */ + len = sizeof(test_packet_ipv4_udp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv4_udp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_ALL; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* IPv4/UDP */ + len = sizeof(test_packet_ipv4_udp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv4_udp); + CU_ASSERT(ret == 0); + + offset[i] = 14; + } + + parse.proto = ODP_PROTO_IPV4; + parse.layer = ODP_PROTO_LAYER_L4; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* Ethernet/IPv4/TCP */ + len = sizeof(test_packet_ipv4_tcp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv4_tcp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_L4; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* Ethernet/IPv6/UDP */ + len = sizeof(test_packet_ipv6_udp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv6_udp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_L4; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + /* Ethernet/IPv6/TCP */ + len = sizeof(test_packet_ipv6_tcp); + ret = odp_packet_alloc_multi(pool, len, pkt, num_pkt); + CU_ASSERT_FATAL(ret == num_pkt); + + for (i = 0; i < num_pkt; i++) { + ret = odp_packet_copy_from_mem(pkt[i], 0, len, + test_packet_ipv6_tcp); + CU_ASSERT(ret == 0); + + offset[i] = 0; + } + + parse.proto = ODP_PROTO_ETH; + parse.layer = ODP_PROTO_LAYER_ALL; + parse.all_check = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], offset[0], &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], &offset[1], + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); + + odp_pool_destroy(pool); +} + odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_alloc_free), ODP_TEST_INFO(packet_test_alloc_free_multi), @@ -2420,6 +2616,7 @@ odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_align), ODP_TEST_INFO(packet_test_offset), ODP_TEST_INFO(packet_test_ref), + ODP_TEST_INFO(packet_test_parse), ODP_TEST_INFO_NULL, }; diff --git a/test/validation/api/packet/packet.h b/test/validation/api/packet/packet.h index 783b7a117..4e99679ed 100644 --- a/test/validation/api/packet/packet.h +++ b/test/validation/api/packet/packet.h @@ -39,6 +39,7 @@ void packet_test_extend_ref(void); void packet_test_align(void); void packet_test_offset(void); void packet_test_ref(void); +void packet_test_parse(void); /* test arrays: */ extern odp_testinfo_t packet_suite[];