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.