From patchwork Wed Feb 15 12:29:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 93997 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2005035qgi; Wed, 15 Feb 2017 04:30:32 -0800 (PST) X-Received: by 10.237.39.5 with SMTP id n5mr30246096qtd.38.1487161832295; Wed, 15 Feb 2017 04:30:32 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n46si2717642qtf.182.2017.02.15.04.30.31; Wed, 15 Feb 2017 04:30:32 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BCE4560BE4; Wed, 15 Feb 2017 12:30:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 3658960C1E; Wed, 15 Feb 2017 12:29: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 E668960BDC; Wed, 15 Feb 2017 12:29:52 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10127.outbound.protection.outlook.com [40.107.1.127]) by lists.linaro.org (Postfix) with ESMTPS id 689676094D for ; Wed, 15 Feb 2017 12:29:50 +0000 (UTC) Received: from AMXPR07CA0029.eurprd07.prod.outlook.com (10.242.64.29) by DB6PR0701MB1735.eurprd07.prod.outlook.com (10.168.10.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10; Wed, 15 Feb 2017 12:29:48 +0000 Received: from DB5EUR03FT027.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::207) by AMXPR07CA0029.outlook.office365.com (2a01:111:e400:1000::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10 via Frontend Transport; Wed, 15 Feb 2017 12:29:48 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.38 as permitted sender) Received: from hybrid2.ext.net.nokia.com (131.228.2.38) by DB5EUR03FT027.mail.protection.outlook.com (10.152.20.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.904.16 via Frontend Transport; Wed, 15 Feb 2017 12:29:47 +0000 Received: from fihe3nok1349.nsn-intra.net (10.158.36.137) by fihe3nok1349.nsn-intra.net (10.158.36.137) with Microsoft SMTP Server (TLS) id 15.1.466.34; Wed, 15 Feb 2017 14:29:46 +0200 Received: from mailrelay.int.nokia.com (10.130.128.30) by fihe3nok1349.nsn-intra.net (10.158.36.137) with Microsoft SMTP Server (TLS) id 15.1.466.34 via Frontend Transport; Wed, 15 Feb 2017 14:29:46 +0200 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWSM002931 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWsn002922 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Wed, 15 Feb 2017 14:29:29 +0200 Message-ID: <1487161772-632-2-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> References: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.38; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39850400002)(39410400002)(39840400002)(39450400003)(39860400002)(2980300002)(189002)(199003)(76176999)(36756003)(48376002)(5660300001)(50466002)(50986999)(2950100002)(6666003)(6916009)(106466001)(450100001)(110136004)(92566002)(47776003)(68736007)(389900002)(38730400002)(105596002)(5003940100001)(53936002)(189998001)(22756006)(33646002)(77096006)(2351001)(356003)(50226002)(8676002)(86362001)(626004)(97736004)(8936002)(2906002)(81166006)(305945005)(81156014)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0701MB1735; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB5EUR03FT027; 1:drCQMCQegJLdNdATtGQWzNFJqQa3gW6b7Rju+ElpxHQhs/obZadJZAhJbfAsbHEb1ZhqaAWlLisjgsqdJgu/oLTlAOLO4RsULOFFA2UH7/9qYj2z2QtA2U+rdatDjfMff51Q0jn1+y9fqnuN8lAnNIEWxtIBa+c4sT++5sRKzdpN3sVig56BKyEQR7MF2gFCRiwO8y/t/LOHEXEvvKU+9VI0t4Zpn4UOUjoab+k+yfw6aEr7dk3m0TYP9B/6Rsf+dSVV87xyh4X21E7NEgW6DqdKaguodpHMCkJFapU/WI4I7Xm/JfTscDyWARx7DboMcaYW4mL3mqUonQ8HSn+37lwAlugdiFXtMIc0Qlrf544G9hfGzVfvgA9hL3rfSc6xwMSzRSdB+x/TtuNy8+ylcBNUEnwC9DFIopEDYk3TYSjHFRXok++TcfiUZUTvEDWbthd8OT74NVbN8aVpbwqVwg== X-MS-Office365-Filtering-Correlation-Id: 9c1ae7de-4b84-4a4d-691b-08d4559e54b8 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB6PR0701MB1735; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1735; 3:csY7fWefVLK9F2bE2k6BmMUKx+s5jQZTtcL7k8/AvbA9dIFc3xQLQxmL9DNXxK8QSK6ldKtAN5SJ+BkmvwfyFfFYYjEqze97m/RGYGW6WjmNxPbcX52mMGHB0RlHy5xgflsQrkWlX8txz2cubis8Lx3dJNP+DSOd/wmr083jxqGTRHTZQM31X2WnHSVZCeX7wPi4jzuaa1PLHpvRMbAqqHsmXjGiMZkEgNjFX6Vl+zCLNqHZBaPmz1ddAEskC5zcL00r4nSXJX2mGTITOo11kx77NjZ6URiGE5cQfkq4RYT21Ot0IUsl9MnxOPbTKXG+aUGtuXTfw49xig/wu9OHtRRuq95/bVV8K7j07l5itlIlVAooQ2Cwb6sy5+/fooBc; 25:Ehod3rL2wR3r2TIFWJHZv2KD28Bfv+AP2Zdv3suUDXt1f/hpRziKksLMNq1Qew6vahj+HZ9HMU53zot+n+dDf0aSCsjfjcOxwo7TqsoAEEc6IW8A5iT3oT1xOiL+xH8WD9BnTWdVLT5HDRqC8/1+bpLSYFfLx/S+FDJD4zqtXr8SH3pQyhxWYppPbB+Je8lOqVRRyCSVUVKX5ZYiKPMj+2eIfGg5eoSXAm+KxXu0Z43b9kuJx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q4FiLzkfHQTvCDE8gWqbcvvE2bnN2CQt9r9adEc5oQZEyXDdP2MclC96+YQ5LhGeUBPyR4+k5uAuCpBuab/ZcL/IU= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13016025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123558025)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(6072148); SRVR:DB6PR0701MB1735; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0701MB1735; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1735; 4:AIAd/5kl+Nz8To6p6eSIcV+pXMpncLjBGLj3FcESbS7z/pq/2nBIwokIEbAZYFGTZyKK4FUhNoHD7p2XcUEQUQcGVqzMtHe0nqCalznYfdGj6Gy8fKq1kN0lMWAIWLk4GjKc5ijTQSokjOPwSr0izBm4TGbRTAM2uUuqPCwZyYuYdEqqBeRRdx+Us6iQUfPzFUZ2FW/pJFeBnH8CKPlueS+O+hHhO6m6rbE7LfvFVgIamhAsQPoAbzln+P8J/Er5Uacvk3KEDWavgnnkqUDDpjqqUNEmb3xgrKIAyUYOc80Z64zpuQAgm1Ofz6+l2Ky2i3vYQxzVeNgEn2X9LxHqQkGtarakVBinOJVcFJAKDi9Utr6ClA3sq6wKjG7Kc9k8TOG9aVqu/mI3/I6VAtLKrZatzfigAu5qJCeBL4WKrcoyH+6LbuTbLMZVMgqqqkwIua347q9427IQ/UaVj7RGM44zQXbL69yL5JCFcWf84bwb4MueJaqAGTm6qe9hvc8zeSfSF4fA4CnH6k3MBw0hAlI6qbi3/iLZlQr9t2uYKXsnCUXQCl1C5F5/ezhuGtPYAmtyJzH9LKJHzmhgbZYneV7mwN/BwHPniudg8T+t0JtNqQBWyd6A6nKI2HoOc6Fv+7gt+JuTfVGtTyjHnhGnu48lLjj5HnQ1wx1GGWMSDdQ= X-Forefront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xAbAOIfrmerqBmYhCPyXYqLvVPljaNTogthiAFPY3qB9U1tyvtXflLw7tN0CUhR90RgquT6PrSqal0f2GY/1oV5jrr/fpn9l0qpbYoS3KSnpwuzS5EbiIhA6fFpupWouezf86yJJ90RCrJzVbwFWENkb0ZxVpsQKsk1Bax/IRj+1c6jalpJ1o2FmvaBEH9ZgXl3HUwjiPN/IVi6jRYFA1KdpOUmKOmkIaTiNcMZLk0D96RuMit9Td4sGz3MC87eM+j363tGTlk5gadeQYyAf+TJMy7kZ3vQMq+xwv//e/XvKUgLzgl3+L0QsU8cf+bvp9+W2God7OEc7zklt5tmyfMruHL1j5RDIIVwOWwMX0BXEFVPYj2DIoLlXpnt9/4yElrt2Lbn41WG4ZUikmBlvY6J9rB4mD7DEZ27kIaamSGxb4Y8rw== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2017 12:29:47.9397 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.38]; Helo=[hybrid2.ext.net.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0701MB1735 Subject: [lng-odp] [API-NEXT PATCH v2 1/4] api: packet: references may be implemented as copy 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" Some implementations may implement new references as packet copy. odp_packet_has_ref() will return 0 for copies, since those are unique packets. Signed-off-by: Petri Savolainen --- include/odp/api/spec/packet.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- 2.8.1 diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index b6450c1..92c35ae 100644 --- a/include/odp/api/spec/packet.h +++ b/include/odp/api/spec/packet.h @@ -892,9 +892,6 @@ odp_packet_t odp_packet_ref_static(odp_packet_t pkt); * dynamic references must not be mixed. Results are undefined if these * restrictions are not observed. * - * odp_packet_unshared_len() may be used to determine the number of bytes - * starting at offset zero that are unique to a packet handle. - * * The packet handle 'pkt' may itself by a (dynamic) reference to a packet. * * If the caller does not intend to modify either the packet or the new @@ -952,8 +949,9 @@ odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset, * When a packet has multiple references, packet data is divided into two * parts: unshared and shared. The unshared part always precedes the shared * part. This call returns number of bytes in the unshared part. When a - * packet has only a single reference, all packet data is unshared and - * unshared length equals the packet length (odp_packet_len()). + * packet has only a single reference (see odp_packet_has_ref()), all packet + * data is unshared and unshared length equals the packet length + * (odp_packet_len()). * * Application may modify only the unshared part, the rest of the packet data * must be treated as read only. @@ -967,8 +965,17 @@ uint32_t odp_packet_unshared_len(odp_packet_t pkt); /** * Test if packet has multiple references * - * A packet that has multiple references shares data and possibly metadata - * with other packets. Shared part must be treated as read only. + * A packet that has multiple references share data with other packets. In case + * of a static reference it also shares metadata. Shared parts must be treated + * as read only. + * + * New references are created with odp_packet_ref_static(), odp_packet_ref() and + * odp_packet_ref_pkt() calls. The intent of multiple references is to avoid + * packet copies, however some implementations may do a packet copy for some of + * the calls. If a copy is done, the new reference is actually a new, unique + * packet and this function returns '0' for it. When a real reference is + * created (instead of a copy), this function returns '1' for both packets + * (the original packet and the new reference). * * @param pkt Packet handle * From patchwork Wed Feb 15 12:29:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 94001 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2005690qgi; Wed, 15 Feb 2017 04:32:01 -0800 (PST) X-Received: by 10.200.0.213 with SMTP id d21mr30841642qtg.44.1487161921859; Wed, 15 Feb 2017 04:32:01 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 20si2717430qtt.174.2017.02.15.04.32.01; Wed, 15 Feb 2017 04:32:01 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 77B3760977; Wed, 15 Feb 2017 12:32:01 +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.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 897AC60670; Wed, 15 Feb 2017 12:30:34 +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 8142760BDC; Wed, 15 Feb 2017 12:30:26 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0096.outbound.protection.outlook.com [104.47.1.96]) by lists.linaro.org (Postfix) with ESMTPS id 3741A60BE4 for ; Wed, 15 Feb 2017 12:29:55 +0000 (UTC) Received: from HE1PR0701CA0051.eurprd07.prod.outlook.com (10.168.191.19) by VI1PR0701MB1744.eurprd07.prod.outlook.com (10.167.196.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10; Wed, 15 Feb 2017 12:29:52 +0000 Received: from VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::205) by HE1PR0701CA0051.outlook.office365.com (2603:10a6:3:9e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10 via Frontend Transport; Wed, 15 Feb 2017 12:29:52 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.35 as permitted sender) Received: from hybrid2.ext.net.nokia.com (131.228.2.35) by VE1EUR03FT048.mail.protection.outlook.com (10.152.19.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.904.16 via Frontend Transport; Wed, 15 Feb 2017 12:29:52 +0000 Received: from fihe3nok1348.nsn-intra.net (10.158.36.136) by fihe3nok1346.nsn-intra.net (10.158.36.134) with Microsoft SMTP Server (TLS) id 15.1.466.34; Wed, 15 Feb 2017 14:29:51 +0200 Received: from mailrelay.int.nokia.com (10.130.128.30) by fihe3nok1348.nsn-intra.net (10.158.36.136) with Microsoft SMTP Server (TLS) id 15.1.466.34 via Frontend Transport; Wed, 15 Feb 2017 14:29:51 +0200 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWRD002934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWso002922 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Wed, 15 Feb 2017 14:29:30 +0200 Message-ID: <1487161772-632-3-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> References: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.35; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39860400002)(39450400003)(39850400002)(39410400002)(39840400002)(2980300002)(189002)(199003)(50986999)(76176999)(36756003)(86362001)(92566002)(81156014)(8936002)(81166006)(50226002)(8676002)(97736004)(189998001)(33646002)(356003)(53936002)(305945005)(5003940100001)(450100001)(5660300001)(2950100002)(6916009)(389900002)(77096006)(22756006)(2906002)(626004)(48376002)(38730400002)(110136004)(68736007)(50466002)(105596002)(106466001)(2351001)(47776003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0701MB1744; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; VE1EUR03FT048; 1:wd8XwDaJ5tQNLqbl3uDdQ7Q0Lbu/ysHMm+tWjqPJReqCvM3iFSETc3ItcAaBusIrT3sWblzGblzaI8rTtvvJ4nyj0s9/xZYlMGHt3La6VrYiiW/HDwgJikNnoqK+YnhR36TSao6m4QSIaxgq0XtEea5OFnmgwqHrKj/2K7/GCTDsgGuHNauP7ItI/AmbJe8HGyizmceq5bsaBYDgNt+OkK2nqhbdIPZxmrEgkKVxdKCzwKaXbs+P8ZXdGNMCdgZpu9C6nrim0O4j9yLa1Ua0LWK8me79CN7oM75dWvoRNC8+/1tJxMGNPerBgflHo0o3gigwktgvF/vmD/Gv/A+Nz8XDRUJP3LfhbrtTSgGraTgDsAkEVxcgo7MHByspGimYdRmCuBXcgoNYO/fTFNbpPwn0Mzate87QHJSnKD3iW7sDS6p2GQpZi0ALjXMl2FVOkHLhePHhgXa0C9skOuv4nA== X-MS-Office365-Filtering-Correlation-Id: c03eafb7-a19e-4cc7-b3fe-08d4559e5781 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:VI1PR0701MB1744; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0701MB1744; 3:CK5tGsVvDpwuhcw5EsS7pFU7KvwzEASMI5H3uLROjlvZTn4+xFCSg6PAJKT1VkAbZEpY7sAb0Ni+baM0yowNzHO14698YltirRvsmsA5V/PQ2s6/U4tbrSFDGwio54iDI7WhwqmmgXhdbI9XGkgAA3Aj3f5og4fwnymUAAedzp4DZTiOIZmapW9l5QYkvCfE44yVAobhOypkYl89QBGZKBYNhU7UK/I9Pn9MigSaKjzF1i1DgzKz/EJ5qKZ+qS4SzucE4y4AMgpGCiTJaonMnDM8tItqXpRiP+EPRG7f8+uPrAx11neD50GUpO/3+p8mu7Y2ETRsfhFfKXxwaBOSQBhSKkYnd93tk/PNp3dAHbkjY0jkL9CoFjBd6xzfUmRC; 25:UZqAkjRq9iQ1H/csMf41rhxR1ri1TYcyX5lJ4vhzG9DlieUiJFJQI/J29EqiD5itXvEZF8gmXFlL1VYFeNbxsv+Aq5HlzvWTQwXKdhQezpqUxkQPoKqiJFBgLq1DYzVR8eXix8oGP8GjlpJR466mhauk2ymd1CiVCNLzblRtKXfi0Yf3OkS9XF6/IQl1vbstAAfqee11Wul3R3C+7a/VZLckFdYCuyeFQJ8uNW2noj1Z4eEo47WcdLJJ3uoiVgmthn18F0JX0skn2bF6aUxpp/DKQe4kkbk3NiZkZdTY6swojMO3KCXVW6IjLR1gmPUGOZSv9ne8LygSMgkIgB6EB4nOLv3DRZfOM4XDPNc0S1dCaI/Xx52QSPK9iXd1LEWhuMB/CYGK3AX3paM6qA9K8zWASSSzD0Qt4rTkdbn+Bl33w58CnUbY0FeFsK5Jc410Igr20SIaIGd3K1+3as3NzA== X-Microsoft-Exchange-Diagnostics: 1; VI1PR0701MB1744; 31:5ygnNqiw04AZxl9dBpxP88xwZMXYnpZgvXxH6yQfRSldFNx83twuVZ84Nv9T/V+JjLtpgQRKq06tf4bq0HsVjJDneZJXX63Vh0mTUKOumNpbXZW2rOZfFw91ZSjyvwqiD9s1v4l3uVTY+YxQeB17nLdW13PaHam6HHQi8o733dzHZeH0bDTaEaIh2/dL+JwNFBNcAClTfyuJBbvIIL6lKq1KK8SZ2v9ZUdk6gLwotNHXHfnhcG7SWWh0pm6sn0YhsxjMwcDg2faLJyS37FK+xLsawMmpBZQd3FO3vd98Ixg=; 20:JK147KFQGqsms08nlBLRaFo1ZRfvZzuw/vxK4aeN7gHojO/sQJ7RkDm8Ftf1RJmT6qJk9MPG4O7bqZG9NlszJs47gs1eGZN5hIZJRKjgFw/dUzSzlqFo+AL7UsjnL12iqYhqPUGgFl9jrf1e5JdHnRCxlzH1nSO2Y7XsIg2JE+lZ5/K9oCv9J3uZMMelkVTZd/wBvyoITkyIJfDfR978n5uXbYKUZmtPXD27W8TeYaJq3Um5BrLRIK4zYhO55AzMzqicRfIY0v7azWsYnHbdlrgUtXUF6XgZc602enBElPYUdKHzJfgAMwlJ4kNr2JkUvUgm/EzuDHvlckjnFn0wtI/js84pQqMMokP1qkoboXZ4Sfe4hIgfL7HdVyRMgcsW6pIfNVUQVTj+Ww8DcmgEeaaF0QSXHBWD22gytlAY+GhmWcISZ3uQQHH7td18Y4okgKRgurSDy5bj0F2+M3XnpzldkdcML8xtpsovDPSxx19LbE+3lIlk9mniZJUB9ypWLNnuVKvm0LXd0SPt2Hlp6HUn9ARG2GD7O/Z05Dg0I6+NCTTpA2HO81k9uLmXqDJx05J0EJfnx9STY+IBH1034/n3XLTTBgowKUcszX6eQc4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(13016025)(13018025)(10201501046)(3002001)(6055026)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(20161123558025)(6072148); SRVR:VI1PR0701MB1744; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0701MB1744; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0701MB1744; 4:YD2IvuJjzQolqbvZbXCuSxh1eLguyI3WAkkPp4JEzWZLlTG8c5r2XVRMXFjMPr9M9NwcNGD9t5tB76A2Rx4pPbAgRb1sUQLy33+cJZaOrM3e/MD7MB8Uh1m4CFRtoqY55g8J2Do1iUXtT+dWb2amP3RfesRvNtNHc/W7p2jdwfDbLEeugceSCXWqa0UpjjxvPKql9s7nvL0AVu5qlBPlF7BBktLQ3BKVF8Vj+z+e/bKMKXs4pKJXND2EE3vaXzQNZj7Y1zPNY/8Fg7PpUjwg31xLN4FxZla2jsOjmJk1RgzK8uxkqqh2ZR8djVctbnL/+RPqJoKDP/2G9U/w90NVhl9xGsusQMKM4P4UN2wVkvJG0UkUABhcBzdA4r/0hgxH7MXl+90K9CK+cpmAmD6OPl5+ZRkGbJtfpF7HYCLiYiWpkRl/rZO8qNfcBJgXGpcWI2tdO4+td6b2z4FR4hX6dfW1C9jNp2oGMlTk2VFNUB6E34vni2IcnAzoYI2rrvZkoddKvzXn6159Kv1RLZvSbMcV1+FzIkKpOSeDgS2a8ugH/q75ymbQcbGmolrJiW6KEJimLh7AOQLn5WDMgFC4W9UEc/Gq+NFM2NjnXcK/ENXN1bwRUQgaXqw6JoCPZNEc8g+YWMFgOsTrMvHPz4+siCT4d2lmNPg9our3GxchgD8= X-Forefront-PRVS: 021975AE46 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0701MB1744; 23:FRLzrACYlF1xqseSge5Qe87emBTe0e0UGHswnMv?= i0IRLP1/nrywmaxAU0F3Gzw9JwkvI5g+v8hA3hZQ2FwlnQ0kfvQ1b3H5hnZoOta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DcfLp8WMieRGKb/HIHsDP7cfpZDZeRHA3A3lwh+JJkW8No80Nb+bPYy83+A8hnZNcmrHhxgkjh3B8xbcbnEHtcE8VYZs1CFfuSZm9V/S7j3dfDghW2Apq43vsf7rroBAZczgO/kiH6Q9s0gGb1+qTrioC3Oedv9TUFd8WwEiQ1D+uJ1Q7NdK9mwLED8krlBQUoxt7VJLlE6Y3lAJaZwOYokNuJ7lK4oA2v31tKjKnU1qtLEa+Lfs/muAlEVFthw== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2017 12:29:52.6456 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.35]; Helo=[hybrid2.ext.net.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0701MB1744 Subject: [lng-odp] [API-NEXT PATCH v2 2/4] validation: packet: remove non compatible 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" Tests for bad inputs are not compatible to the spec. Out-of-range values cause undefined results and must not be tested in validation suite. Remove reference checks that do not comply anymore to the new odp_packet_has_ref() specification. Signed-off-by: Petri Savolainen --- test/common_plat/validation/api/packet/packet.c | 241 ++++++++++++++++-------- 1 file changed, 161 insertions(+), 80 deletions(-) -- 2.8.1 diff --git a/test/common_plat/validation/api/packet/packet.c b/test/common_plat/validation/api/packet/packet.c index f64c599..900c426 100644 --- a/test/common_plat/validation/api/packet/packet.c +++ b/test/common_plat/validation/api/packet/packet.c @@ -1877,46 +1877,70 @@ void packet_test_extend_ref(void) /* Verify ref lengths */ CU_ASSERT(ref != ODP_PACKET_INVALID); CU_ASSERT(odp_packet_len(ref) == max_len - 200); - CU_ASSERT(odp_packet_unshared_len(ref) == 0); + if (odp_packet_has_ref(ref) == 1) { + CU_ASSERT(odp_packet_unshared_len(ref) == 0); - /* And ref's affect on max_pkt */ - CU_ASSERT(odp_packet_has_ref(max_pkt) == 1); - CU_ASSERT(odp_packet_unshared_len(max_pkt) == 100); + /* And ref's affect on max_pkt */ + CU_ASSERT(odp_packet_has_ref(max_pkt) == 1); + CU_ASSERT(odp_packet_unshared_len(max_pkt) == 100); + } else { + CU_ASSERT(odp_packet_unshared_len(ref) == odp_packet_len(ref)); + CU_ASSERT(odp_packet_unshared_len(max_pkt) == + odp_packet_len(max_pkt)); + } /* Now extend max_pkt and verify effect */ CU_ASSERT(odp_packet_extend_head(&max_pkt, 10, NULL, NULL) >= 0); CU_ASSERT(odp_packet_len(max_pkt) == max_len - 90); - CU_ASSERT(odp_packet_unshared_len(max_pkt) == 110); - CU_ASSERT(odp_packet_has_ref(max_pkt) == 1); + + if (odp_packet_has_ref(max_pkt) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(max_pkt) == 110); + } /* Extend on max_pkt should not affect ref */ - CU_ASSERT(odp_packet_has_ref(ref) == 1); CU_ASSERT(odp_packet_len(ref) == max_len - 200); - CU_ASSERT(odp_packet_unshared_len(ref) == 0); + + if (odp_packet_has_ref(ref) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref) == 0); + } /* Now extend ref and verify effect*/ CU_ASSERT(odp_packet_extend_head(&ref, 20, NULL, NULL) >= 0); CU_ASSERT(odp_packet_len(ref) == max_len - 180); - CU_ASSERT(odp_packet_unshared_len(ref) == 20); + + if (odp_packet_has_ref(ref) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref) == 20); + } /* Extend on ref should not affect max_pkt */ CU_ASSERT(odp_packet_len(max_pkt) == max_len - 90); - CU_ASSERT(odp_packet_unshared_len(max_pkt) == 110); - CU_ASSERT(odp_packet_has_ref(max_pkt) == 1); + + if (odp_packet_has_ref(max_pkt) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(max_pkt) == 110); + } /* Trunc max_pkt of all unshared len */ - CU_ASSERT(odp_packet_trunc_head(&max_pkt, - odp_packet_unshared_len(max_pkt), - NULL, NULL) >= 0); + CU_ASSERT(odp_packet_trunc_head(&max_pkt, 110, NULL, NULL) >= 0); /* Verify effect on max_pkt */ CU_ASSERT(odp_packet_len(max_pkt) == max_len - 200); - CU_ASSERT(odp_packet_unshared_len(max_pkt) == 0); - CU_ASSERT(odp_packet_has_ref(max_pkt) == 1); + + if (odp_packet_has_ref(max_pkt) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(max_pkt) == 0); + } /* Verify that ref is unchanged */ CU_ASSERT(odp_packet_len(ref) == max_len - 180); - CU_ASSERT(odp_packet_unshared_len(ref) == 20); + + if (odp_packet_has_ref(ref) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref) == 20); + } /* Free ref and verify that max_pkt is back to being unreferenced */ odp_packet_free(ref); @@ -2089,37 +2113,42 @@ void packet_test_ref(void) odp_packet_unshared_len(hdr_pkt[i])); } - /* Attempt an invalid ref */ - refhdr_pkt[0] = odp_packet_ref_pkt(base_pkt, pkt_len, hdr_pkt[0]); - CU_ASSERT(refhdr_pkt[0] == ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_has_ref(hdr_pkt[0]) == 0); - CU_ASSERT(odp_packet_has_ref(base_pkt) == 0); - - /* We can't ref to ourselves */ - refhdr_pkt[0] = odp_packet_ref_pkt(hdr_pkt[0], 0, hdr_pkt[0]); - CU_ASSERT(refhdr_pkt[0] == ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_has_ref(hdr_pkt[0]) == 0); - - /* Now create a couple of valid refs */ + /* Create a couple of refs */ refhdr_pkt[0] = odp_packet_ref_pkt(base_pkt, offset[0], hdr_pkt[0]); refhdr_pkt[1] = odp_packet_ref_pkt(base_pkt, offset[1], hdr_pkt[1]); CU_ASSERT(refhdr_pkt[0] != ODP_PACKET_INVALID); CU_ASSERT(refhdr_pkt[1] != ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_has_ref(refhdr_pkt[0]) == 1); - CU_ASSERT(odp_packet_has_ref(refhdr_pkt[1]) == 1); - CU_ASSERT(odp_packet_has_ref(base_pkt) == 1); + /* If base packet has now references, ref packet should be also + * references. */ + if (odp_packet_has_ref(base_pkt) == 1) { + CU_ASSERT(odp_packet_has_ref(refhdr_pkt[0]) == 1); + CU_ASSERT(odp_packet_has_ref(refhdr_pkt[1]) == 1); - /* Verify ref lengths and contents */ - CU_ASSERT(odp_packet_unshared_len(base_pkt) == 0); + CU_ASSERT(odp_packet_unshared_len(base_pkt) == 0); + } else { + CU_ASSERT(odp_packet_unshared_len(base_pkt) == pkt_len); + } CU_ASSERT(odp_packet_len(refhdr_pkt[0]) == hdr_len[0] + pkt_len - offset[0]); - CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == hdr_len[0]); CU_ASSERT(odp_packet_len(refhdr_pkt[1]) == hdr_len[1] + pkt_len - offset[1]); - CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[1]) == hdr_len[1]); + + if (odp_packet_has_ref(refhdr_pkt[0]) == 1) { + CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == hdr_len[0]); + } else { + CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == + odp_packet_len(refhdr_pkt[0])); + } + + if (odp_packet_has_ref(refhdr_pkt[1]) == 1) { + CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[1]) == hdr_len[1]); + } else { + CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[1]) == + odp_packet_len(refhdr_pkt[1])); + } packet_compare_offset(refhdr_pkt[0], hdr_len[0], base_pkt, offset[0], @@ -2137,23 +2166,16 @@ void packet_test_ref(void) refhdr_pkt[2] = odp_packet_ref_pkt(refhdr_pkt[0], 2, hdr_cpy); CU_ASSERT(refhdr_pkt[2] != ODP_PACKET_INVALID); - if (refhdr_pkt[2] != ODP_PACKET_INVALID) { - CU_ASSERT(odp_packet_has_ref(base_pkt) == 1); - CU_ASSERT(odp_packet_has_ref(refhdr_pkt[2]) == 1); + if (odp_packet_has_ref(refhdr_pkt[2]) == 1) { CU_ASSERT(odp_packet_has_ref(refhdr_pkt[0]) == 1); CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[2]) == hdr_len[2]); CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == 2); - - /* Free the compound ref and verify we're back to simple ref */ - odp_packet_free(refhdr_pkt[2]); - CU_ASSERT(odp_packet_has_ref(base_pkt) == 1); - CU_ASSERT(odp_packet_has_ref(refhdr_pkt[0]) == 1); - CU_ASSERT(odp_packet_unshared_len(refhdr_pkt[0]) == hdr_len[0]); } /* Delete the refs */ odp_packet_free(refhdr_pkt[0]); odp_packet_free(refhdr_pkt[1]); + odp_packet_free(refhdr_pkt[2]); /* Verify that base_pkt no longer has a ref */ CU_ASSERT(odp_packet_has_ref(base_pkt) == 0); @@ -2164,9 +2186,11 @@ void packet_test_ref(void) CU_ASSERT(hdr_pkt[2] != ODP_PACKET_INVALID); CU_ASSERT(hdr_pkt[3] != ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_has_ref(refhdr_pkt[2]) == 1); - CU_ASSERT(odp_packet_has_ref(refhdr_pkt[3]) == 1); - CU_ASSERT(odp_packet_has_ref(base_pkt) == 1); + + if (odp_packet_has_ref(base_pkt) == 1) { + CU_ASSERT(odp_packet_has_ref(refhdr_pkt[2]) == 1); + CU_ASSERT(odp_packet_has_ref(refhdr_pkt[3]) == 1); + } CU_ASSERT(odp_packet_len(refhdr_pkt[2]) == odp_packet_len(refhdr_pkt[3])); @@ -2185,7 +2209,12 @@ void packet_test_ref(void) /* Create a static reference */ ref_pkt[0] = odp_packet_ref_static(base_pkt); CU_ASSERT(ref_pkt[0] != ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_has_ref(base_pkt) == 1); + + if (odp_packet_has_ref(base_pkt) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_has_ref(ref_pkt[0]) == 1); + } + CU_ASSERT(odp_packet_len(ref_pkt[0]) == odp_packet_len(base_pkt)); packet_compare_offset(ref_pkt[0], 0, base_pkt, 0, odp_packet_len(base_pkt)); @@ -2194,33 +2223,38 @@ void packet_test_ref(void) odp_packet_free(ref_pkt[0]); CU_ASSERT(odp_packet_has_ref(base_pkt) == 0); - /* Create an invalid basic reference */ - ref_pkt[0] = odp_packet_ref(segmented_base_pkt, segmented_pkt_len); - CU_ASSERT(ref_pkt[0] == ODP_PACKET_INVALID); - CU_ASSERT(odp_packet_has_ref(segmented_base_pkt) == 0); - - /* Now create valid references */ + /* Create references */ ref_pkt[0] = odp_packet_ref(segmented_base_pkt, offset[0]); - CU_ASSERT(odp_packet_has_ref(ref_pkt[0]) == 1); - CU_ASSERT(odp_packet_has_ref(segmented_base_pkt) == 1); + if (odp_packet_has_ref(ref_pkt[0]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_has_ref(segmented_base_pkt) == 1); + } ref_pkt[1] = odp_packet_ref(segmented_base_pkt, offset[1]); - CU_ASSERT(odp_packet_has_ref(ref_pkt[1]) == 1); - CU_ASSERT(odp_packet_has_ref(segmented_base_pkt) == 1); + + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_has_ref(segmented_base_pkt) == 1); + } /* Verify reference lengths */ CU_ASSERT(odp_packet_len(ref_pkt[0]) == segmented_pkt_len - offset[0]); CU_ASSERT(odp_packet_len(ref_pkt[1]) == segmented_pkt_len - offset[1]); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0); + + if (odp_packet_has_ref(ref_pkt[0]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0); + } + + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + } /* Free the base pkts -- references should still be valid */ odp_packet_free(base_pkt); odp_packet_free(segmented_base_pkt); - CU_ASSERT(odp_packet_has_ref(ref_pkt[0]) == 1); - CU_ASSERT(odp_packet_has_ref(ref_pkt[1]) == 1); - packet_compare_offset(ref_pkt[0], 0, segmented_test_packet, offset[0], segmented_pkt_len - offset[0]); @@ -2233,20 +2267,35 @@ void packet_test_ref(void) hr[1] = odp_packet_headroom(ref_pkt[1]); CU_ASSERT(odp_packet_push_head(ref_pkt[0], hr[0]) != NULL); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0]); + + if (odp_packet_has_ref(ref_pkt[0]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0]); + } + CU_ASSERT(odp_packet_len(ref_pkt[0]) == hr[0] + segmented_pkt_len - offset[0]); CU_ASSERT(odp_packet_pull_head(ref_pkt[0], hr[0] / 2) != NULL); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0] - (hr[0] / 2)); + + if (odp_packet_has_ref(ref_pkt[0]) == 1) { + CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == + hr[0] - (hr[0] / 2)); + } if (hr[1] > 0) { CU_ASSERT(odp_packet_push_head(ref_pkt[1], 1) != NULL); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 1); + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 1); + } CU_ASSERT(odp_packet_len(ref_pkt[1]) == 1 + segmented_pkt_len - offset[1]); CU_ASSERT(odp_packet_pull_head(ref_pkt[1], 1) != NULL); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + } CU_ASSERT(odp_packet_len(ref_pkt[1]) == segmented_pkt_len - offset[1]); } @@ -2261,36 +2310,68 @@ void packet_test_ref(void) CU_ASSERT_FATAL(ref_pkt[1] != ODP_PACKET_INVALID); ref_len[1] = odp_packet_len(ref_pkt[1]); CU_ASSERT(ref_len[1] == odp_packet_len(base_pkt) - offset[1]); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + } CU_ASSERT(odp_packet_push_head(base_pkt, base_hr / 2) != NULL); - CU_ASSERT(odp_packet_unshared_len(base_pkt) == base_hr / 2 + offset[1]); + + if (odp_packet_has_ref(base_pkt) == 1) { + CU_ASSERT(odp_packet_unshared_len(base_pkt) == + base_hr / 2 + offset[1]); + } CU_ASSERT(odp_packet_len(ref_pkt[1]) == ref_len[1]); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + } ref_pkt[0] = odp_packet_ref(base_pkt, offset[0]); CU_ASSERT_FATAL(ref_pkt[0] != ODP_PACKET_INVALID); ref_len[0] = odp_packet_len(ref_pkt[0]); CU_ASSERT(ref_len[0] = odp_packet_len(base_pkt) - offset[0]); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0); + if (odp_packet_has_ref(ref_pkt[0]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0); + } CU_ASSERT(odp_packet_push_head(base_pkt, base_hr - base_hr / 2) != NULL); - CU_ASSERT(odp_packet_unshared_len(base_pkt) == - base_hr - base_hr / 2 + offset[0]); + if (odp_packet_has_ref(base_pkt) == 1) { + CU_ASSERT(odp_packet_unshared_len(base_pkt) == + base_hr - base_hr / 2 + offset[0]); + } CU_ASSERT(odp_packet_len(ref_pkt[1]) == ref_len[1]); CU_ASSERT(odp_packet_len(ref_pkt[0]) == ref_len[0]); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0); + + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == 0); + } + if (odp_packet_has_ref(ref_pkt[0]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == 0); + } hr[0] = odp_packet_headroom(ref_pkt[0]); hr[1] = odp_packet_headroom(ref_pkt[1]); CU_ASSERT(odp_packet_push_head(ref_pkt[0], hr[0]) != NULL); CU_ASSERT(odp_packet_push_head(ref_pkt[1], hr[1]) != NULL); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0]); - CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == hr[1]); - CU_ASSERT(odp_packet_unshared_len(base_pkt) == - base_hr - base_hr / 2 + offset[0]); + if (odp_packet_has_ref(ref_pkt[0]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[0]) == hr[0]); + } + if (odp_packet_has_ref(ref_pkt[1]) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(ref_pkt[1]) == hr[1]); + } + if (odp_packet_has_ref(base_pkt) == 1) { + /* CU_ASSERT needs braces */ + CU_ASSERT(odp_packet_unshared_len(base_pkt) == + base_hr - base_hr / 2 + offset[0]); + } odp_packet_free(base_pkt); odp_packet_free(ref_pkt[0]); From patchwork Wed Feb 15 12:29:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 94003 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2006277qgi; Wed, 15 Feb 2017 04:33:33 -0800 (PST) X-Received: by 10.55.24.72 with SMTP id j69mr13349832qkh.164.1487162013851; Wed, 15 Feb 2017 04:33:33 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id y5si2721179qka.176.2017.02.15.04.33.33; Wed, 15 Feb 2017 04:33:33 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 6C6216067D; Wed, 15 Feb 2017 12:33:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS 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 95CD460C1F; Wed, 15 Feb 2017 12:31:13 +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 14AC560BD7; Wed, 15 Feb 2017 12:31:04 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0114.outbound.protection.outlook.com [104.47.1.114]) by lists.linaro.org (Postfix) with ESMTPS id 35A6960E9F for ; Wed, 15 Feb 2017 12:29:57 +0000 (UTC) Received: from AM4PR0701CA0022.eurprd07.prod.outlook.com (10.165.102.32) by AM5PR0701MB1730.eurprd07.prod.outlook.com (10.167.215.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10; Wed, 15 Feb 2017 12:29:54 +0000 Received: from AM5EUR03FT034.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::205) by AM4PR0701CA0022.outlook.office365.com (2603:10a6:200:42::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10 via Frontend Transport; Wed, 15 Feb 2017 12:29:55 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.38 as permitted sender) Received: from hybrid2.ext.net.nokia.com (131.228.2.38) by AM5EUR03FT034.mail.protection.outlook.com (10.152.16.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.904.16 via Frontend Transport; Wed, 15 Feb 2017 12:29:55 +0000 Received: from fihe3nok1346.nsn-intra.net (10.158.36.134) by fihe3nok1349.nsn-intra.net (10.158.36.137) with Microsoft SMTP Server (TLS) id 15.1.466.34; Wed, 15 Feb 2017 14:29:53 +0200 Received: from mailrelay.int.nokia.com (10.130.128.30) by fihe3nok1346.nsn-intra.net (10.158.36.134) with Microsoft SMTP Server (TLS) id 15.1.466.34 via Frontend Transport; Wed, 15 Feb 2017 14:29:53 +0200 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWnX002938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWsp002922 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Wed, 15 Feb 2017 14:29:31 +0200 Message-ID: <1487161772-632-4-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> References: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.38; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(979002)(6009001)(7916002)(39850400002)(39450400003)(39840400002)(39860400002)(39410400002)(2980300002)(189002)(199003)(36756003)(626004)(22756006)(356003)(38730400002)(5660300001)(110136004)(2906002)(53936002)(305945005)(2950100002)(6916009)(50986999)(76176999)(389900002)(77096006)(8676002)(81156014)(81166006)(53946003)(5003940100001)(8936002)(50226002)(50466002)(86362001)(48376002)(189998001)(33646002)(450100001)(47776003)(92566002)(97736004)(105596002)(2351001)(106466001)(68736007)(41533002)(217873001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0701MB1730; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR03FT034; 1:AyP3CaRVoi+XwPnNq3r6dYtei/3bBEXlFu5l+WbnFGY06EvldRt8Y+DBJ+K79nPIJa9mu34+D1kVZHh5CiZ+aNNBoqSsTAyK1p/mfe/269C5VcVpekfmzBVi3PPZLR96P/QsT7HkC8C+8E13wMuctU8mSCZ973wv1HDpe3Kf9rGknqukr8YB2rOQNU0M3A8SqLv+FJcARPBxEy2av/vqicH3fog0clnTFYy9cesvirTb8DCTHMNPtYDHkyHQqFM78H31MrB7Tsc6g8ClNW0DucjGVrbqPIAB/XV045bXj3FBO8n5KBoYwabWZTBsxjS/Xg0QB7A44ohw4QXNUX3QfzfSXPqicfdSg3tN9rj2C5c9n5RaZbT1gU0lREOHT9IRdQvc/4H4bOCsLzoOR6xEShx/6CFleTSV7DWqSLgUanp685URxoUi3nNBgAgaaHJ7YwLCNshRjnbC9OMg9M/ilw== X-MS-Office365-Filtering-Correlation-Id: 85e2fd26-6407-4821-75ba-08d4559e5903 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0701MB1730; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1730; 3:Otldq1TwF+dGGh7256+FSmDdqs76ypEo+VFwb+6Ei74LDWpdgBKjRJAsB/Fi4rqW+TiI8EGyQizT+SN1ePxnQ+i8lItBHYsifPdbokbfbVT9ddEWPC3cPnboJk4k1PvisfH+QwHPyrCTLlVim2oxeSbop8D/YRpKR5BEsNQgiGIht6oHlH3rbhczPY397kBdrmv0dWHCVpUQM3YsyhOqaDNtmjkncJWnRLXP978lnUZj7zzDWYpb/8uOePOvTV3xREBnCo8UF4QbLfx6rzE1Pmvo2mH1kaj6pZBAoq8cKsUfg/QXAxvE6uhM24eHETcLFSg1pRNYULli/ZzKXT0iCmVNm+ovndNjkk2T4uS4Wi8sQkMN0Xf9071cNL/BCErA; 25:pIgWsYspSgdWvqLIE6g+YAI917GB8H9p+QfBDeScFIJYJV2EUHDPoQpvMFxTBcGReIXNKa2lyL96Y9fa5zD0BmPd7XrsxAz1HwEV3dDmBc/C1seWRyaB2iAFAjYPuhjAwwnlOUNcxm24ngh1a6h+uyv4OvQti2iqJiSrK7hLkFVG+kkEVfXRIe74O7MkY3vKavt1oCnDwd3DpAktiml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RnsvAHAF3eQDRRlxmUHKiKD6HS047c5SikBZyx2JQ930eErjx3xxgr5SMaE5/ZSCb40AL+kV0pfwgtV3IjGpSOKrRItunYpMY4hMSyAl1PsdmQ5fa/yaNEILxvW0rhOCXwuM/BUd8AUm94hZlJET3Qw= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(13016025)(13018025)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123558025)(20161123562025)(20161123564025)(20161123555025)(6072148); SRVR:AM5PR0701MB1730; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB1730; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1730; 4:XWPR3gZMB/1JGSE8+Sh278j56VJg+l3wc3ieYDa7gp61o8l7x2R44I+Dlv8IlBmEeTULtknLT4FoLXjLQt7kLhoko5OLuYHVKiltzWCWJImnlYHsqRvoprZyqmFyRE1Hn8//7ZmlFO+QALV0juDRWWhnjdk4EqsTfmo6P0WZ0fJBCxQYxIOvj+KnowY3jFj47cFzwfzXMkOhO2CnYoeRjdBkkFN7Q6vYvakTL4pDokYrgY0JMLZ7ZSU4neufU4VsS1CeKgQq09sQIxhcPV6BZH8Ua7Gw/3hbyyBFWLmp/l6MaYSt8ziXl2Qz4MtVMucxZiAPScK36Uo4RJdj1UrQKzENgeAmB7RJZ9Ro+YFlMr+LNgx39mpnN+qLwZJRUNRVtdgjA761B5Fw3SupoAt9eiDkOVbZz/9sbMwrZmxD9WnO72B5/A067u+aInTkbYFgPw9FPq7buYvTwTQkHHC50pbD09R/8jKbBOfDAK18Tr/v++YS49NmDEpQ+BLuY8Tqzbhd9T668bAGfMBFbtqirS4tdPrfML/VPzdI5+8p7svVTwqeq1IkC8vVo1/TTL3+nGqKaOJDw/4+wx1OlvYdYqqa3MfPJ5QCo4Ej/H9rRgtK/mGDPIfNyGW+H9kq5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Output: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB1730; 7:TNel6ninhLdVeTMYh54K20O+GjafX+hYLZQyqzHB12eEwqAvUeOMc6PlQ9dkiHKC9fJr1V15maANLciZMBE6XpQk6aOQTZZQYcnKjhO8O3YF7WESMUJmZUYOiWcaUVNI4mDDFEGIA4yOY/43EngY7MI3qbgN27dcwaAncvuQRarUu6CXYfZ0P+ROYHlhyyWLPE8EL4aFGtt026nVhYPX6pPTYz/VS2yIBDoA7m3GxiTZYFLMCK1vec5O1cqJfId/3wNeBQOSr3cWm3NRNiO7pfteUkpmSSbx/rADcGuW1bag3lbHQxRMy8DWGp1AseJMe5CHZIcprLJdz6Q1UrE5KL/zLsSlbx6LflsTAidO5XhX8Lr3SwXuKbK8d5YWns5akkoyAvB3tmGn8LaNdAL/V1CiX6XH1kgBBsZWTqOYnBfBHUgRon5oRc9QyRz/FT/C80GQmEaMtZUQCeiO1p8AFCMIoDkGeXJUa6JS8q++UCnG9w1fdFnHrvouubJlxVA4h+b43KggeKWeFUZ3KyryYA== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2017 12:29:55.1893 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.38]; Helo=[hybrid2.ext.net.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB1730 Subject: [lng-odp] [API-NEXT PATCH v2 3/4] Revert "linux-generic: packet: implement reference apis" 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" This reverts commit 22b3986fea090986625f3255d57b64de35bbc475. --- .../linux-generic/include/odp_packet_internal.h | 85 +--- platform/linux-generic/odp_packet.c | 536 ++++----------------- 2 files changed, 107 insertions(+), 514 deletions(-) -- 2.8.1 diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 42df5ac..e3ada5c 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -19,7 +19,6 @@ extern "C" { #include #include -#include #include #include #include @@ -169,7 +168,7 @@ typedef struct { * packet_init(). Because of this any new fields added must be reviewed for * initialization requirements. */ -typedef struct odp_packet_hdr_t { +typedef struct { /* common buffer header */ odp_buffer_hdr_t buf_hdr; @@ -185,13 +184,6 @@ typedef struct odp_packet_hdr_t { uint32_t headroom; uint32_t tailroom; - /* Fields used to support packet references */ - uint32_t unshared_len; - struct odp_packet_hdr_t *ref_hdr; - uint32_t ref_offset; - uint32_t ref_len; - odp_atomic_u32_t ref_count; - /* * Members below are not initialized by packet_init() */ @@ -220,55 +212,6 @@ static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt) return (odp_packet_hdr_t *)buf_hdl_to_hdr((odp_buffer_t)pkt); } -static inline odp_packet_hdr_t *odp_packet_last_hdr(odp_packet_t pkt, - uint32_t *offset) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - odp_packet_hdr_t *prev_hdr = pkt_hdr; - uint32_t ref_offset = 0; - - while (pkt_hdr->ref_hdr) { - ref_offset = pkt_hdr->ref_offset; - prev_hdr = pkt_hdr; - pkt_hdr = pkt_hdr->ref_hdr; - } - - if (offset) { - if (prev_hdr != pkt_hdr) - ref_offset += pkt_hdr->frame_len - prev_hdr->ref_len; - *offset = ref_offset; - } - - return pkt_hdr; -} - -static inline odp_packet_hdr_t *odp_packet_prev_hdr(odp_packet_hdr_t *pkt_hdr, - odp_packet_hdr_t *cur_hdr, - uint32_t *offset) -{ - uint32_t ref_offset = 0; - odp_packet_hdr_t *prev_hdr = pkt_hdr; - - while (pkt_hdr->ref_hdr != cur_hdr) { - ref_offset = pkt_hdr->ref_offset; - prev_hdr = pkt_hdr; - pkt_hdr = pkt_hdr->ref_hdr; - } - - if (offset) { - if (prev_hdr != pkt_hdr) - ref_offset += pkt_hdr->frame_len - prev_hdr->ref_len; - *offset = ref_offset; - } - - return pkt_hdr; -} - -static inline odp_packet_t _odp_packet_hdl(odp_packet_hdr_t *pkt_hdr) -{ - return (odp_packet_t)odp_hdr_to_buf(&pkt_hdr->buf_hdr); -} - static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr, odp_packet_hdr_t *dst_hdr) { @@ -291,41 +234,17 @@ static inline void pull_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len) pkt_hdr->tailroom += len; pkt_hdr->frame_len -= len; - pkt_hdr->unshared_len -= len; pkt_hdr->buf_hdr.seg[last].len -= len; } static inline uint32_t packet_len(odp_packet_hdr_t *pkt_hdr) { - uint32_t pkt_len = 0; - uint32_t offset = 0; - - do { - pkt_len += pkt_hdr->frame_len - offset; - offset = pkt_hdr->ref_offset; - if (pkt_hdr->ref_hdr) - offset += (pkt_hdr->ref_hdr->frame_len - - pkt_hdr->ref_len); - pkt_hdr = pkt_hdr->ref_hdr; - } while (pkt_hdr); - - return pkt_len; -} - -static inline uint32_t packet_ref_count(odp_packet_hdr_t *pkt_hdr) -{ - return odp_atomic_load_u32(&pkt_hdr->ref_count); -} - -static inline void packet_ref_count_set(odp_packet_hdr_t *pkt_hdr, uint32_t n) -{ - odp_atomic_init_u32(&pkt_hdr->ref_count, n); + return pkt_hdr->frame_len; } static inline void packet_set_len(odp_packet_hdr_t *pkt_hdr, uint32_t len) { pkt_hdr->frame_len = len; - pkt_hdr->unshared_len = len; } static inline int packet_parse_l2_not_done(packet_parser_t *prs) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 3aadc4d..024f694 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -33,24 +33,13 @@ static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->buf_hdr.handle.handle; } -static inline uint32_t packet_ref_inc(odp_packet_hdr_t *pkt_hdr) -{ - return odp_atomic_fetch_inc_u32(&pkt_hdr->ref_count); -} - -static inline uint32_t packet_ref_dec(odp_packet_hdr_t *pkt_hdr) -{ - return odp_atomic_fetch_dec_u32(&pkt_hdr->ref_count); -} - static inline uint32_t packet_seg_len(odp_packet_hdr_t *pkt_hdr, uint32_t seg_idx) { return pkt_hdr->buf_hdr.seg[seg_idx].len; } -static inline uint8_t *packet_seg_data(odp_packet_hdr_t *pkt_hdr, - uint32_t seg_idx) +static inline void *packet_seg_data(odp_packet_hdr_t *pkt_hdr, uint32_t seg_idx) { return pkt_hdr->buf_hdr.seg[seg_idx].data; } @@ -63,11 +52,6 @@ static inline int packet_last_seg(odp_packet_hdr_t *pkt_hdr) return pkt_hdr->buf_hdr.segcount - 1; } -static inline void *packet_data(odp_packet_hdr_t *pkt_hdr) -{ - return pkt_hdr->buf_hdr.seg[0].data; -} - static inline uint32_t packet_first_seg_len(odp_packet_hdr_t *pkt_hdr) { return packet_seg_len(pkt_hdr, 0); @@ -80,6 +64,11 @@ static inline uint32_t packet_last_seg_len(odp_packet_hdr_t *pkt_hdr) return packet_seg_len(pkt_hdr, last); } +static inline void *packet_data(odp_packet_hdr_t *pkt_hdr) +{ + return pkt_hdr->buf_hdr.seg[0].data; +} + static inline void *packet_tail(odp_packet_hdr_t *pkt_hdr) { int last = packet_last_seg(pkt_hdr); @@ -110,7 +99,6 @@ static inline void push_head(odp_packet_hdr_t *pkt_hdr, uint32_t len) { pkt_hdr->headroom -= len; pkt_hdr->frame_len += len; - pkt_hdr->unshared_len += len; pkt_hdr->buf_hdr.seg[0].data -= len; pkt_hdr->buf_hdr.seg[0].len += len; } @@ -119,7 +107,6 @@ static inline void pull_head(odp_packet_hdr_t *pkt_hdr, uint32_t len) { pkt_hdr->headroom += len; pkt_hdr->frame_len -= len; - pkt_hdr->unshared_len -= len; pkt_hdr->buf_hdr.seg[0].data += len; pkt_hdr->buf_hdr.seg[0].len -= len; } @@ -130,7 +117,6 @@ static inline void push_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len) pkt_hdr->tailroom -= len; pkt_hdr->frame_len += len; - pkt_hdr->unshared_len += len; pkt_hdr->buf_hdr.seg[last].len += len; } @@ -158,10 +144,6 @@ static inline void packet_seg_copy_md(odp_packet_hdr_t *dst, dst->buf_hdr.uarea_addr = src->buf_hdr.uarea_addr; dst->buf_hdr.uarea_size = src->buf_hdr.uarea_size; - /* reference related metadata */ - dst->ref_len = src->ref_len; - dst->unshared_len = src->unshared_len; - /* segmentation data is not copied: * buf_hdr.seg[] * buf_hdr.segcount @@ -176,15 +158,7 @@ static inline void *packet_map(odp_packet_hdr_t *pkt_hdr, int seg = 0; int seg_count = pkt_hdr->buf_hdr.segcount; - /* Special processing for references */ - while (offset >= pkt_hdr->frame_len && pkt_hdr->ref_hdr) { - offset -= (pkt_hdr->frame_len - pkt_hdr->ref_offset); - offset += (pkt_hdr->ref_hdr->frame_len - pkt_hdr->ref_len); - pkt_hdr = pkt_hdr->ref_hdr; - seg_count = pkt_hdr->buf_hdr.segcount; - } - - if (odp_unlikely(offset > pkt_hdr->frame_len)) + if (odp_unlikely(offset >= pkt_hdr->frame_len)) return NULL; if (odp_likely(CONFIG_PACKET_MAX_SEGS == 1 || seg_count == 1)) { @@ -233,9 +207,6 @@ void packet_parse_reset(odp_packet_hdr_t *pkt_hdr) pkt_hdr->p.l2_offset = 0; pkt_hdr->p.l3_offset = ODP_PACKET_OFFSET_INVALID; pkt_hdr->p.l4_offset = ODP_PACKET_OFFSET_INVALID; - - /* Ensure dummy pkt_hdrs used in I/O recv classification are valid */ - pkt_hdr->ref_hdr = NULL; } /** @@ -281,10 +252,6 @@ static inline void packet_init(odp_packet_hdr_t *pkt_hdr, uint32_t len, CONFIG_PACKET_TAILROOM; pkt_hdr->input = ODP_PKTIO_INVALID; - - /* By default packet has no references */ - pkt_hdr->unshared_len = len; - pkt_hdr->ref_hdr = NULL; } static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) @@ -297,7 +264,6 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) hdr->buf_hdr.seg[0].data = hdr->buf_hdr.base_data; hdr->buf_hdr.seg[0].len = BASE_LEN; - packet_ref_count_set(hdr, 1); /* Link segments */ if (CONFIG_PACKET_MAX_SEGS != 1) { @@ -307,7 +273,6 @@ static inline void init_segments(odp_packet_hdr_t *pkt_hdr[], int num) for (i = 1; i < num; i++) { odp_buffer_hdr_t *buf_hdr; - packet_ref_count_set(pkt_hdr[i], 1); buf_hdr = &pkt_hdr[i]->buf_hdr; hdr->buf_hdr.seg[i].hdr = buf_hdr; hdr->buf_hdr.seg[i].data = buf_hdr->base_data; @@ -411,10 +376,9 @@ static inline odp_packet_hdr_t *add_segments(odp_packet_hdr_t *pkt_hdr, new_hdr->buf_hdr.seg[0].len = seg_len; packet_seg_copy_md(new_hdr, pkt_hdr); - new_hdr->frame_len = pkt_hdr->frame_len + len; - new_hdr->unshared_len = pkt_hdr->unshared_len + len; - new_hdr->headroom = pool->headroom + offset; - new_hdr->tailroom = pkt_hdr->tailroom; + new_hdr->frame_len = pkt_hdr->frame_len + len; + new_hdr->headroom = pool->headroom + offset; + new_hdr->tailroom = pkt_hdr->tailroom; pkt_hdr = new_hdr; } else { @@ -427,9 +391,8 @@ static inline odp_packet_hdr_t *add_segments(odp_packet_hdr_t *pkt_hdr, last = packet_last_seg(pkt_hdr); pkt_hdr->buf_hdr.seg[last].len = seg_len; - pkt_hdr->frame_len += len; - pkt_hdr->unshared_len += len; - pkt_hdr->tailroom = pool->tailroom + offset; + pkt_hdr->frame_len += len; + pkt_hdr->tailroom = pool->tailroom + offset; } return pkt_hdr; @@ -437,18 +400,13 @@ static inline odp_packet_hdr_t *add_segments(odp_packet_hdr_t *pkt_hdr, static inline void free_bufs(odp_packet_hdr_t *pkt_hdr, int first, int num) { - int i, nfree; + int i; odp_buffer_t buf[num]; - for (i = 0, nfree = 0; i < num; i++) { - odp_packet_hdr_t *hdr = pkt_hdr->buf_hdr.seg[first + i].hdr; - - if (packet_ref_dec(hdr) == 1) - buf[nfree++] = buffer_handle(hdr); - } + for (i = 0; i < num; i++) + buf[i] = buffer_handle(pkt_hdr->buf_hdr.seg[first + i].hdr); - if (nfree > 0) - buffer_free_multi(buf, nfree); + buffer_free_multi(buf, num); } static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr, @@ -459,15 +417,11 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr, if (head) { odp_packet_hdr_t *new_hdr; - int i, nfree; + int i; odp_buffer_t buf[num]; - for (i = 0, nfree = 0; i < num; i++) { - new_hdr = pkt_hdr->buf_hdr.seg[i].hdr; - - if (packet_ref_dec(new_hdr) == 1) - buf[nfree++] = buffer_handle(new_hdr); - } + for (i = 0; i < num; i++) + buf[i] = buffer_handle(pkt_hdr->buf_hdr.seg[i].hdr); /* First remaining segment is the new packet descriptor */ new_hdr = pkt_hdr->buf_hdr.seg[num].hdr; @@ -476,17 +430,15 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr, packet_seg_copy_md(new_hdr, pkt_hdr); /* Tailroom not changed */ - new_hdr->tailroom = pkt_hdr->tailroom; - new_hdr->headroom = seg_headroom(new_hdr, 0); - new_hdr->frame_len = pkt_hdr->frame_len - free_len; - new_hdr->unshared_len = pkt_hdr->unshared_len - free_len; + new_hdr->tailroom = pkt_hdr->tailroom; + new_hdr->headroom = seg_headroom(new_hdr, 0); + new_hdr->frame_len = pkt_hdr->frame_len - free_len; pull_head(new_hdr, pull_len); pkt_hdr = new_hdr; - if (nfree > 0) - buffer_free_multi(buf, nfree); + buffer_free_multi(buf, num); } else { /* Free last 'num' bufs */ free_bufs(pkt_hdr, num_remain, num); @@ -495,7 +447,6 @@ static inline odp_packet_hdr_t *free_segments(odp_packet_hdr_t *pkt_hdr, * of the metadata. */ pkt_hdr->buf_hdr.segcount = num_remain; pkt_hdr->frame_len -= free_len; - pkt_hdr->unshared_len -= free_len; pkt_hdr->tailroom = seg_tailroom(pkt_hdr, num_remain - 1); pull_tail(pkt_hdr, pull_len); @@ -599,34 +550,45 @@ int odp_packet_alloc_multi(odp_pool_t pool_hdl, uint32_t len, return num; } -static inline void packet_free(odp_packet_hdr_t *pkt_hdr) -{ - odp_packet_hdr_t *ref_hdr; - uint32_t ref_count; - - do { - ref_hdr = pkt_hdr->ref_hdr; - ref_count = packet_ref_count(pkt_hdr) - 1; - free_bufs(pkt_hdr, 0, pkt_hdr->buf_hdr.segcount); - - if (ref_count == 1) - pkt_hdr->unshared_len = pkt_hdr->frame_len; - - pkt_hdr = ref_hdr; - } while (pkt_hdr); -} - void odp_packet_free(odp_packet_t pkt) { - packet_free(odp_packet_hdr(pkt)); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + int num_seg = pkt_hdr->buf_hdr.segcount; + + if (odp_likely(CONFIG_PACKET_MAX_SEGS == 1 || num_seg == 1)) + buffer_free_multi((odp_buffer_t *)&pkt, 1); + else + free_bufs(pkt_hdr, 0, num_seg); } void odp_packet_free_multi(const odp_packet_t pkt[], int num) { - int i; + if (CONFIG_PACKET_MAX_SEGS == 1) { + buffer_free_multi((const odp_buffer_t * const)pkt, num); + } else { + odp_buffer_t buf[num * CONFIG_PACKET_MAX_SEGS]; + int i, j; + int bufs = 0; - for (i = 0; i < num; i++) - packet_free(odp_packet_hdr(pkt[i])); + for (i = 0; i < num; i++) { + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt[i]); + int num_seg = pkt_hdr->buf_hdr.segcount; + odp_buffer_hdr_t *buf_hdr = &pkt_hdr->buf_hdr; + + buf[bufs] = (odp_buffer_t)pkt[i]; + bufs++; + + if (odp_likely(num_seg == 1)) + continue; + + for (j = 1; j < num_seg; j++) { + buf[bufs] = buffer_handle(buf_hdr->seg[j].hdr); + bufs++; + } + } + + buffer_free_multi(buf, bufs); + } } int odp_packet_reset(odp_packet_t pkt, uint32_t len) @@ -637,9 +599,6 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len) if (len > pool->headroom + pool->data_size + pool->tailroom) return -1; - if (pkt_hdr->ref_hdr) - packet_free(pkt_hdr->ref_hdr); - packet_init(pkt_hdr, len, 0); return 0; @@ -682,21 +641,15 @@ void *odp_packet_head(odp_packet_t pkt) uint32_t odp_packet_buf_len(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - uint32_t buf_len = 0; - do { - buf_len += pkt_hdr->buf_hdr.size * pkt_hdr->buf_hdr.segcount; - pkt_hdr = pkt_hdr->ref_hdr; - } while (pkt_hdr); - - return buf_len; + return pkt_hdr->buf_hdr.size * pkt_hdr->buf_hdr.segcount; } void *odp_packet_data(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - return packet_map(pkt_hdr, 0, NULL, NULL); + return packet_data(pkt_hdr); } uint32_t odp_packet_seg_len(odp_packet_t pkt) @@ -708,32 +661,7 @@ uint32_t odp_packet_seg_len(odp_packet_t pkt) uint32_t odp_packet_len(odp_packet_t pkt) { - return packet_len(odp_packet_hdr(pkt)); -} - -uint32_t odp_packet_unshared_len(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - uint32_t pkt_len = 0, offset = 0; - - do { - if (packet_ref_count(pkt_hdr) > 1) { - if (offset == 0) - pkt_len += pkt_hdr->unshared_len; - break; - } - - pkt_len += pkt_hdr->frame_len - offset; - offset = pkt_hdr->ref_offset; - - if (pkt_hdr->ref_hdr) - offset += (pkt_hdr->ref_hdr->frame_len - - pkt_hdr->ref_len); - - pkt_hdr = pkt_hdr->ref_hdr; - } while (pkt_hdr); - - return pkt_len; + return odp_packet_hdr(pkt)->frame_len; } uint32_t odp_packet_headroom(odp_packet_t pkt) @@ -743,12 +671,12 @@ uint32_t odp_packet_headroom(odp_packet_t pkt) uint32_t odp_packet_tailroom(odp_packet_t pkt) { - return odp_packet_last_hdr(pkt, NULL)->tailroom; + return odp_packet_hdr(pkt)->tailroom; } void *odp_packet_tail(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(pkt, NULL); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); return packet_tail(pkt_hdr); } @@ -942,7 +870,7 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); uint32_t frame_len = pkt_hdr->frame_len; - uint32_t headroom = pkt_hdr->headroom; + uint32_t headroom = pkt_hdr->headroom; int ret = 0; if (len > headroom) { @@ -957,46 +885,6 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, segs = pkt_hdr->buf_hdr.segcount; if (odp_unlikely((segs + num) > CONFIG_PACKET_MAX_SEGS)) { - /* Handle recursively via references when - * working with referenced packets since another - * thread may be accessing it concurrently via - * its reference to it. */ - if (packet_ref_count(pkt_hdr) > 1) { - odp_packet_t ref; - uint32_t unshared_len; - - push_head(pkt_hdr, headroom); - unshared_len = pkt_hdr->unshared_len; - ref = odp_packet_ref(*pkt, 0); - - if (ref == ODP_PACKET_INVALID) { - pull_head(pkt_hdr, headroom); - return -1; - } - - ret = odp_packet_extend_head(&ref, - len - headroom, - data_ptr, - seg_len); - - if (ret < 0) { - odp_packet_free(ref); - pull_head(pkt_hdr, headroom); - return -1; - } - - /* Since this is a special ref, the - * base pkt's unshared len is unchanged */ - pkt_hdr->unshared_len = unshared_len; - - /* Remove extra ref to the base pkt */ - odp_packet_free(*pkt); - - /* Return the ref as the extension result */ - *pkt = ref; - return 1; - } - /* Cannot directly add new segments */ odp_packet_hdr_t *new_hdr; int new_segs = 0; @@ -1048,7 +936,6 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, pkt_hdr->buf_hdr.segcount = segs; pkt_hdr->frame_len = frame_len; - pkt_hdr->unshared_len = frame_len; pkt_hdr->headroom = offset + pool->headroom; pkt_hdr->tailroom = pool->tailroom; @@ -1074,16 +961,11 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, push_head(pkt_hdr, len); } - if (data_ptr || seg_len) { - uint32_t seg_ln = 0; - void *data = packet_map(pkt_hdr, 0, &seg_ln, NULL); - - if (data_ptr) - *data_ptr = data; + if (data_ptr) + *data_ptr = packet_data(pkt_hdr); - if (seg_len) - *seg_len = seg_ln; - } + if (seg_len) + *seg_len = packet_first_seg_len(pkt_hdr); return ret; } @@ -1095,8 +977,6 @@ void *odp_packet_pull_head(odp_packet_t pkt, uint32_t len) if (len > pkt_hdr->frame_len) return NULL; - ODP_ASSERT(len <= pkt_hdr->unshared_len); - pull_head(pkt_hdr, len); return packet_data(pkt_hdr); } @@ -1104,35 +984,15 @@ void *odp_packet_pull_head(odp_packet_t pkt, uint32_t len) int odp_packet_trunc_head(odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len_out) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt), *nxt_hdr; + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); uint32_t seg_len = packet_first_seg_len(pkt_hdr); - int ret = 0; - if (len > packet_len(pkt_hdr)) + if (len > pkt_hdr->frame_len) return -1; - ODP_ASSERT(len <= odp_packet_unshared_len(*pkt)); - - /* Special processing for references */ - while (len >= pkt_hdr->frame_len && pkt_hdr->ref_hdr) { - ODP_ASSERT(packet_ref_count(pkt_hdr) == 1); - nxt_hdr = pkt_hdr->ref_hdr; - len -= pkt_hdr->frame_len; - len += pkt_hdr->ref_offset + - (nxt_hdr->frame_len - pkt_hdr->ref_len); - pkt_hdr->ref_hdr = NULL; - packet_free(pkt_hdr); - pkt_hdr = nxt_hdr; - seg_len = packet_first_seg_len(pkt_hdr); - *pkt = packet_handle(pkt_hdr); - ret = 1; - } - - if (CONFIG_PACKET_MAX_SEGS == 1 || - len < seg_len || - pkt_hdr->buf_hdr.segcount == 1) { + if (len < seg_len) { pull_head(pkt_hdr, len); - } else { + } else if (CONFIG_PACKET_MAX_SEGS != 1) { int num = 0; uint32_t pull_len = 0; @@ -1147,29 +1007,23 @@ int odp_packet_trunc_head(odp_packet_t *pkt, uint32_t len, *pkt = packet_handle(pkt_hdr); } - if (data_ptr || seg_len_out) { - void *data_head = packet_map(pkt_hdr, 0, &seg_len, NULL); - - if (data_ptr) - *data_ptr = data_head; + if (data_ptr) + *data_ptr = packet_data(pkt_hdr); - if (seg_len_out) - *seg_len_out = seg_len; - } + if (seg_len_out) + *seg_len_out = packet_first_seg_len(pkt_hdr); - return ret; + return 0; } void *odp_packet_push_tail(odp_packet_t pkt, uint32_t len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(pkt, NULL); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); void *old_tail; if (len > pkt_hdr->tailroom) return NULL; - ODP_ASSERT(packet_ref_count(pkt_hdr) == 1); - old_tail = packet_tail(pkt_hdr); push_tail(pkt_hdr, len); @@ -1179,14 +1033,12 @@ void *odp_packet_push_tail(odp_packet_t pkt, uint32_t len) int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len_out) { - odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(*pkt, NULL); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); uint32_t frame_len = pkt_hdr->frame_len; uint32_t tailroom = pkt_hdr->tailroom; uint32_t tail_off = frame_len; int ret = 0; - ODP_ASSERT(packet_ref_count(pkt_hdr) == 1); - if (len > tailroom) { pool_t *pool = pool_entry_from_hdl(pkt_hdr->buf_hdr.pool_hdl); int num; @@ -1277,7 +1129,6 @@ void *odp_packet_pull_tail(odp_packet_t pkt, uint32_t len) if (len > packet_last_seg_len(pkt_hdr)) return NULL; - ODP_ASSERT(packet_ref_count(pkt_hdr) == 1); pull_tail(pkt_hdr, len); return packet_tail(pkt_hdr); @@ -1288,34 +1139,17 @@ int odp_packet_trunc_tail(odp_packet_t *pkt, uint32_t len, { int last; uint32_t seg_len; - uint32_t offset; - odp_packet_hdr_t *first_hdr = odp_packet_hdr(*pkt); - odp_packet_hdr_t *pkt_hdr, *prev_hdr; + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); - if (len > packet_len(first_hdr)) + if (len > pkt_hdr->frame_len) return -1; - pkt_hdr = odp_packet_last_hdr(*pkt, &offset); - - /* Special processing for references */ - while (len >= pkt_hdr->frame_len - offset && first_hdr->ref_hdr) { - len -= (pkt_hdr->frame_len - offset); - prev_hdr = odp_packet_prev_hdr(first_hdr, pkt_hdr, &offset); - ODP_ASSERT(packet_ref_count(prev_hdr) == 1); - prev_hdr->ref_hdr = NULL; - packet_free(pkt_hdr); - pkt_hdr = prev_hdr; - } - - ODP_ASSERT(packet_ref_count(pkt_hdr) == 1); last = packet_last_seg(pkt_hdr); seg_len = packet_seg_len(pkt_hdr, last); - if (CONFIG_PACKET_MAX_SEGS == 1 || - len < seg_len || - pkt_hdr->buf_hdr.segcount == 1) { + if (len < seg_len) { pull_tail(pkt_hdr, len); - } else { + } else if (CONFIG_PACKET_MAX_SEGS != 1) { int num = 0; uint32_t pull_len = 0; @@ -1522,50 +1356,35 @@ void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) int odp_packet_is_segmented(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->buf_hdr.segcount > 1 || pkt_hdr->ref_hdr != NULL; + return odp_packet_hdr(pkt)->buf_hdr.segcount > 1; } int odp_packet_num_segs(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - uint32_t segcount = 0, i; - uint32_t seg_offset = 0, offset; - - do { - segcount += pkt_hdr->buf_hdr.segcount - seg_offset; - offset = pkt_hdr->ref_offset; - pkt_hdr = pkt_hdr->ref_hdr; - if (pkt_hdr) { - for (i = 0, seg_offset = 0; - i < pkt_hdr->buf_hdr.segcount; - i++, seg_offset++) { - if (offset < pkt_hdr->buf_hdr.seg[i].len) - break; - offset -= pkt_hdr->buf_hdr.seg[i].len; - } - } - } while (pkt_hdr); - return segcount; + return pkt_hdr->buf_hdr.segcount; } -odp_packet_seg_t odp_packet_first_seg(odp_packet_t pkt ODP_UNUSED) +odp_packet_seg_t odp_packet_first_seg(odp_packet_t pkt) { + (void)pkt; + return 0; } odp_packet_seg_t odp_packet_last_seg(odp_packet_t pkt) { - return (odp_packet_seg_t)(odp_packet_num_segs(pkt) - 1); + odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + + return packet_last_seg(pkt_hdr); } odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - if (odp_unlikely(seg >= packet_last_seg(pkt_hdr))) + if (odp_unlikely(seg >= (odp_packet_seg_t)packet_last_seg(pkt_hdr))) return ODP_PACKET_SEG_INVALID; return seg + 1; @@ -1581,51 +1400,21 @@ odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg) void *odp_packet_seg_data(odp_packet_t pkt, odp_packet_seg_t seg) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - uint32_t seg_offset = 0, offset = 0, i; - - while (seg >= pkt_hdr->buf_hdr.segcount - seg_offset && - pkt_hdr->ref_hdr) { - seg -= (pkt_hdr->buf_hdr.segcount - seg_offset); - offset = pkt_hdr->ref_offset; - pkt_hdr = pkt_hdr->ref_hdr; - for (i = 0, seg_offset = 0; - i < pkt_hdr->buf_hdr.segcount; - i++, seg_offset++) { - if (offset < pkt_hdr->buf_hdr.seg[i].len) - break; - offset -= pkt_hdr->buf_hdr.seg[i].len; - } - } - if (odp_unlikely(seg + seg_offset >= pkt_hdr->buf_hdr.segcount)) + if (odp_unlikely(seg >= pkt_hdr->buf_hdr.segcount)) return NULL; - return packet_seg_data(pkt_hdr, seg + seg_offset) + offset; + return packet_seg_data(pkt_hdr, seg); } uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - uint32_t seg_offset = 0, offset = 0, i; - - while (seg >= pkt_hdr->buf_hdr.segcount - seg_offset && - pkt_hdr->ref_hdr) { - seg -= (pkt_hdr->buf_hdr.segcount - seg_offset); - offset = pkt_hdr->ref_offset; - pkt_hdr = pkt_hdr->ref_hdr; - for (i = 0, seg_offset = 0; - i < pkt_hdr->buf_hdr.segcount; - i++, seg_offset++) { - if (offset < pkt_hdr->buf_hdr.seg[i].len) - break; - offset -= pkt_hdr->buf_hdr.seg[i].len; - } - } - if (odp_unlikely(seg + seg_offset >= pkt_hdr->buf_hdr.segcount)) + if (odp_unlikely(seg >= pkt_hdr->buf_hdr.segcount)) return 0; - return packet_seg_len(pkt_hdr, seg + seg_offset) - offset; + return packet_seg_len(pkt_hdr, seg); } /* @@ -1639,14 +1428,12 @@ int odp_packet_add_data(odp_packet_t *pkt_ptr, uint32_t offset, uint32_t len) { odp_packet_t pkt = *pkt_ptr; odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - uint32_t pktlen = packet_len(pkt_hdr); + uint32_t pktlen = pkt_hdr->frame_len; odp_packet_t newpkt; if (offset > pktlen) return -1; - ODP_ASSERT(odp_packet_unshared_len(*pkt_ptr) >= offset); - newpkt = odp_packet_alloc(pkt_hdr->buf_hdr.pool_hdl, pktlen + len); if (newpkt == ODP_PACKET_INVALID) @@ -1709,8 +1496,6 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len, if (align > ODP_CACHE_LINE_SIZE) return -1; - ODP_ASSERT(odp_packet_has_ref(*pkt) == 0); - if (seglen >= len) { misalign = align <= 1 ? 0 : ROUNDUP_ALIGN(uaddr, align) - uaddr; @@ -1750,13 +1535,10 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) uint32_t dst_len = dst_hdr->frame_len; uint32_t src_len = src_hdr->frame_len; - ODP_ASSERT(packet_ref_count(dst_hdr) == 1); - /* Do a copy if resulting packet would be out of segments or packets - * are from different pools or src is a reference. */ + * are from different pools. */ if (odp_unlikely((dst_segs + src_segs) > CONFIG_PACKET_MAX_SEGS) || - odp_unlikely(dst_pool != src_pool) || - odp_unlikely(packet_ref_count(src_hdr)) > 1) { + odp_unlikely(dst_pool != src_pool)) { if (odp_packet_extend_tail(dst, src_len, NULL, NULL) >= 0) { (void)odp_packet_copy_from_pkt(*dst, dst_len, src, 0, src_len); @@ -1771,9 +1553,8 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) add_all_segs(dst_hdr, src_hdr); - dst_hdr->frame_len = dst_len + src_len; - dst_hdr->unshared_len = dst_len + src_len; - dst_hdr->tailroom = src_hdr->tailroom; + dst_hdr->frame_len = dst_len + src_len; + dst_hdr->tailroom = src_hdr->tailroom; /* Data was not moved in memory */ return 0; @@ -1786,7 +1567,6 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, odp_packet_t *tail) if (len >= pktlen || tail == NULL) return -1; - ODP_ASSERT(odp_packet_unshared_len(*pkt) >= len); *tail = odp_packet_copy_part(*pkt, len, pktlen - len, odp_packet_pool(*pkt)); @@ -1797,109 +1577,6 @@ int odp_packet_split(odp_packet_t *pkt, uint32_t len, odp_packet_t *tail) } /* - * References - */ - -static inline void packet_ref(odp_packet_hdr_t *pkt_hdr) -{ - uint32_t i; - odp_packet_hdr_t *hdr; - - do { - for (i = 0; i < pkt_hdr->buf_hdr.segcount; i++) { - hdr = pkt_hdr->buf_hdr.seg[i].hdr; - packet_ref_inc(hdr); - } - - pkt_hdr = pkt_hdr->ref_hdr; - } while (pkt_hdr); -} - -static inline odp_packet_t packet_splice(odp_packet_hdr_t *pkt_hdr, - uint32_t offset, - odp_packet_hdr_t *ref_hdr) -{ - /* Catch attempted references to stale handles in debug builds */ - ODP_ASSERT(packet_ref_count(pkt_hdr) > 0); - - /* Splicing is from the last section of src pkt */ - while (ref_hdr->ref_hdr) - ref_hdr = ref_hdr->ref_hdr; - - /* Find section where splice begins */ - while (offset >= pkt_hdr->frame_len && pkt_hdr->ref_hdr) { - offset -= (pkt_hdr->frame_len - pkt_hdr->ref_offset); - offset += (pkt_hdr->ref_hdr->frame_len - pkt_hdr->ref_len); - pkt_hdr = pkt_hdr->ref_hdr; - } - - ref_hdr->ref_hdr = pkt_hdr; - ref_hdr->ref_offset = offset; - ref_hdr->ref_len = pkt_hdr->frame_len; - - if (offset < pkt_hdr->unshared_len) - pkt_hdr->unshared_len = offset; - - packet_ref(pkt_hdr); - return _odp_packet_hdl(ref_hdr); -} - -odp_packet_t odp_packet_ref_static(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - pkt_hdr->unshared_len = 0; - packet_ref(pkt_hdr); - return pkt; -} - -odp_packet_t odp_packet_ref(odp_packet_t pkt, uint32_t offset) -{ - odp_packet_t hdr; - odp_packet_hdr_t *pkt_hdr; - - if (pkt == ODP_PACKET_INVALID) - return ODP_PACKET_INVALID; - - pkt_hdr = odp_packet_hdr(pkt); - if (offset >= packet_len(pkt_hdr)) - return ODP_PACKET_INVALID; - - hdr = odp_packet_alloc(odp_packet_pool(pkt), 0); - - if (hdr == ODP_PACKET_INVALID) - return ODP_PACKET_INVALID; - - return packet_splice(pkt_hdr, offset, odp_packet_hdr(hdr)); -} - -odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset, - odp_packet_t hdr) -{ - odp_packet_hdr_t *pkt_hdr; - - if (pkt == ODP_PACKET_INVALID || - hdr == ODP_PACKET_INVALID || - pkt == hdr) - return ODP_PACKET_INVALID; - - ODP_ASSERT(odp_packet_has_ref(hdr) == 0); - - pkt_hdr = odp_packet_hdr(pkt); - if (offset >= packet_len(pkt_hdr)) - return ODP_PACKET_INVALID; - - return packet_splice(pkt_hdr, offset, odp_packet_hdr(hdr)); -} - -int odp_packet_has_ref(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->ref_hdr != NULL || packet_ref_count(pkt_hdr) > 1; -} - -/* * * Copy * ******************************************************** @@ -1908,7 +1585,8 @@ int odp_packet_has_ref(odp_packet_t pkt) odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool) { - uint32_t pktlen = odp_packet_len(pkt); + odp_packet_hdr_t *srchdr = odp_packet_hdr(pkt); + uint32_t pktlen = srchdr->frame_len; odp_packet_t newpkt = odp_packet_alloc(pool, pktlen); if (newpkt != ODP_PACKET_INVALID) { @@ -1947,7 +1625,7 @@ int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, uint8_t *dstaddr = (uint8_t *)dst; odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - if (offset + len > packet_len(pkt_hdr)) + if (offset + len > pkt_hdr->frame_len) return -1; while (len > 0) { @@ -1971,11 +1649,9 @@ int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, const uint8_t *srcaddr = (const uint8_t *)src; odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - if (offset + len > packet_len(pkt_hdr)) + if (offset + len > pkt_hdr->frame_len) return -1; - ODP_ASSERT(odp_packet_unshared_len(pkt) >= offset + len); - while (len > 0) { mapaddr = packet_map(pkt_hdr, offset, &seglen, NULL); cpylen = len > seglen ? seglen : len; @@ -2001,12 +1677,10 @@ int odp_packet_copy_from_pkt(odp_packet_t dst, uint32_t dst_offset, uint32_t src_seglen = 0; /* GCC */ int overlap; - if (dst_offset + len > packet_len(dst_hdr) || - src_offset + len > packet_len(src_hdr)) + if (dst_offset + len > dst_hdr->frame_len || + src_offset + len > src_hdr->frame_len) return -1; - ODP_ASSERT(odp_packet_unshared_len(dst) >= dst_offset + len); - overlap = (dst_hdr == src_hdr && ((dst_offset <= src_offset && dst_offset + len >= src_offset) || @@ -2090,7 +1764,7 @@ void odp_packet_print(odp_packet_t pkt) len += snprintf(&str[len], n - len, " l4_offset %" PRIu32 "\n", hdr->p.l4_offset); len += snprintf(&str[len], n - len, - " frame_len %" PRIu32 "\n", packet_len(hdr)); + " frame_len %" PRIu32 "\n", hdr->frame_len); len += snprintf(&str[len], n - len, " input %" PRIu64 "\n", odp_pktio_to_u64(hdr->input)); From patchwork Wed Feb 15 12:29:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 93996 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2004787qgi; Wed, 15 Feb 2017 04:29:59 -0800 (PST) X-Received: by 10.55.203.147 with SMTP id u19mr1201qkl.269.1487161799339; Wed, 15 Feb 2017 04:29:59 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q186si2717459qkf.140.2017.02.15.04.29.58; Wed, 15 Feb 2017 04:29:59 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C060562D8A; Wed, 15 Feb 2017 12:29:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 D506F609DD; Wed, 15 Feb 2017 12:29:54 +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 56F2260BDC; Wed, 15 Feb 2017 12:29:52 +0000 (UTC) Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20124.outbound.protection.outlook.com [40.107.2.124]) by lists.linaro.org (Postfix) with ESMTPS id 9ACE3609DD for ; Wed, 15 Feb 2017 12:29:50 +0000 (UTC) Received: from HE1PR0701CA0061.eurprd07.prod.outlook.com (10.168.191.29) by DB6PR0701MB1734.eurprd07.prod.outlook.com (10.168.10.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10; Wed, 15 Feb 2017 12:29:47 +0000 Received: from VE1EUR03FT048.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::200) by HE1PR0701CA0061.outlook.office365.com (2603:10a6:3:9e::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10 via Frontend Transport; Wed, 15 Feb 2017 12:29:47 +0000 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning linaro.org discourages use of 131.228.2.35 as permitted sender) Received: from hybrid2.ext.net.nokia.com (131.228.2.35) by VE1EUR03FT048.mail.protection.outlook.com (10.152.19.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.904.16 via Frontend Transport; Wed, 15 Feb 2017 12:29:47 +0000 Received: from fihe3nok1347.nsn-intra.net (10.158.36.135) by fihe3nok1346.nsn-intra.net (10.158.36.134) with Microsoft SMTP Server (TLS) id 15.1.466.34; Wed, 15 Feb 2017 14:29:46 +0200 Received: from mailrelay.int.nokia.com (10.130.128.30) by fihe3nok1347.nsn-intra.net (10.158.36.135) with Microsoft SMTP Server (TLS) id 15.1.466.34 via Frontend Transport; Wed, 15 Feb 2017 14:29:46 +0200 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWvv002941 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 Received: from 10.144.19.15 ([10.144.104.219]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id v1FCTWsq002922 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Wed, 15 Feb 2017 14:29:32 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Wed, 15 Feb 2017 14:29:32 +0200 Message-ID: <1487161772-632-5-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> References: <1487161772-632-1-git-send-email-petri.savolainen@linaro.org> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.35; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39860400002)(39840400002)(39450400003)(39850400002)(39410400002)(2980300002)(189002)(199003)(6916009)(92566002)(2950100002)(33646002)(97736004)(81166006)(81156014)(68736007)(8936002)(38730400002)(110136004)(50226002)(36756003)(8676002)(53936002)(77096006)(5003940100001)(48376002)(47776003)(50986999)(76176999)(626004)(2906002)(50466002)(105596002)(356003)(450100001)(189998001)(86362001)(22756006)(305945005)(106466001)(2351001)(5660300001)(389900002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0701MB1734; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; VE1EUR03FT048; 1:snposjmfXj6KdKBZWUx7xXyq3/YXrWSjW3r2b3nWY68rseTTD5JQK/sxh0mpz/hDhwhIRb7btkrthMaWoCOIhbOao5RB5MwP22ijkAIHsPilrJo/dRlGxZSJ8rNLHE5bZbS/PHAuseiQyaoB35wS2pBbqqPVYjNUvjhgENDaQemqMHVza8QQ+6lXeluywWX24XB/NTJfdJAzhd95DrXJY82pxYhf8Tg01lvJI1mgB3yYp/u1p7WffbkVrP45ccd5DMjkN/IGm12H/1VfXgKCMvf+PpoeVwZ3nsKz8NkNBnxCEeDi0OFmL8BquIAjkOS4hSWQvPuo04CRHUGZ6VdTt0fC6s0ZkZGxzBYH8bPoiPLPur6yTGH8PYGRW1ysclNIp/SjuH44ii0MZTSKN2x1o9rcvKWn/nvFIwRWeCqv7QDlM6whn7h+VccGV1eFVq0m1s+fH44uh7Fe3h38qD70Zg== X-MS-Office365-Filtering-Correlation-Id: b072781d-877d-4d24-4914-08d4559e5490 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB6PR0701MB1734; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1734; 3:18onvkzS6rqGNpx12mtF3jXQM2qq6j0JF2xhLgP5E+tmEC5OwWIxnStUPRGw76YB3DRMknKVRLOjx1SndPbB0WYzIA1uwlDezpYenjIZfNLr6+2cTnschVWRUcX8V7NuQ8u+G53rED/OczoWpyFm9qsK+H59mX/GbpFLL7c777k+VMxACghdtvRnm2N1beKXAk68765Z+BJDLDndkQ8ynwyTA2HA0qnA3g1B5zuCVnKZGl0L/A19MnKEjBF/Z+122Bdha3sUDvRV9Z25vbojqvLrDt2vpgIFL4eBvR3XfWUtd8trLTjjNVMs1W8ociEFxjBXu6glycDgtZ/rc9gMSTsOFCK6pxZy7cK7ZBq6CXZaFEgDlFf7bBCURwNKt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yjtHmq5ojLVp86u2RzSEnQ2P+/9l5osbxsqEmKRSWq9Yv2lR32oa66guyi7A5cImdLsMEPOwwYnPm9m8pt23BdtQcDsTnQWICE32ISgqmr7QjAGTkLwcMdb0KMZO5iCtsOwvwzazPry3MpHTeJM2o989w+xf2qwUTe7vxx44td+RFxpUulDZ9I7j+NyJTYqR8lfwLz0l+ue4PJjmNpPEaoFNoIpKt1PZszcpcmkjeLj5Nxd61QzLrfcnpBARD7Wgf9YI6lS78CNMeH0Rrl32zBR622XSMAxXuSTcw+9CPnRU1DubcPrVM4SQviNHo7BLGeoKcV2t8Fa/tea773qOI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(13016025)(13018025)(10201501046)(3002001)(6055026)(6041248)(20161123558025)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(6072148); SRVR:DB6PR0701MB1734; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0701MB1734; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1734; 4:hni/KMO0RCEHLesbvADDS1SA939JzqSuGDusz7aLgIh9r3QM0NWxHst2kk1IYXKg/L3jNpxzoEv2ebr6y5ajWQB6uQqL8quaM8bKIv3cHV+nR9JX6La6jyFgSrcUkUS4iEPmg4tKlrBL7lm8XMrC/hZuA7IRXi6/kft0AltdZp8bUxrMkCBBlJkt+bvEf1fbUxvCNXJNGwSOMZmVRsQ4+8Gt/kGI9AJluH6+xnJu7T1sLMG9dMhVsQSowRfjtyDeJwj0oo2toQjM41Zu+yktkXzn+pY74k8i7PH9fDHctwXbspj3/LVCDRSWby5CAC9KLA9L+LWOsYhI5ZwkSwAWUYf0sSTcyDWnLHeSSj8KKJvbf3wccnPYHVyPx1yvYwwSZrE2s19gqXmQjntxmOD3R+ICel89S5Zv8eqfwbgXn7E1hX9pjX/U+d4jNwG/7yqTNp4Ozgexg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KGmM3qYc5Eln51jT98jOeOSqfa6TTCaRyT72iMm6DGywj3Fo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1734; 7:1lhDl5nSvE39veYEVKKAl/Qnhl8HdxHIUuwGB42buteUYEUNhpMu8EkpDVeet15SOPYULwSaVulBpmHi83tgckyEGuB3SwDrH7GVRALCHAjyFtAWhLycNdho5dQKfSLWUPEbixyiQ+U2kqC1ucUjB1QoXAfz17Elj/NLTe7n4AvA4KvLoNhD2iwTVuql25CgpkwGxdVTe72hmMQeHBqsCr2BD4pHZzbywMGUJM2RfPtYt1m7YpDj5lU/RJLcIdDu0Uvb7EGDraqFfeL1VoGQWnZrojI8bwgKGmGKhSIN6oY41ROFESDzhBBWApDagx3hFZmwLYxrDgBX1Fcr3WVcwziJL+d9OGZXOS8pppklWAXuvVhbZiC79BBEtXZEOoJgGvhBQ6wUZwL+ZX3BjB20Tfz1SK83EQ3ALOJqGNjK9Q3hgZTDjui2vwuwMqWn8hpO8zZJEGxmDerZXCwtrC6fYsTRb/8zF83GOIts1jvZXXQkOJquFaH4Z2B54nGaSKLFPzG62bcQKJtCsSlmUnupxw== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2017 12:29:47.7080 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.35]; Helo=[hybrid2.ext.net.nokia.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0701MB1734 Subject: [lng-odp] [API-NEXT PATCH v2 4/4] linux-gen: packet: implement references as copy 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" Implement packet references API as packet copy. This is the simplest way to support the API, as other packet functions are not affected at all. Signed-off-by: Petri Savolainen --- platform/linux-generic/odp_packet.c | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) -- 2.8.1 diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 024f694..9eccb57 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2221,3 +2221,77 @@ uint64_t odp_packet_seg_to_u64(odp_packet_seg_t hdl) { return _odp_pri(hdl); } + +odp_packet_t odp_packet_ref_static(odp_packet_t pkt) +{ + return odp_packet_copy(pkt, odp_packet_pool(pkt)); +} + +odp_packet_t odp_packet_ref(odp_packet_t pkt, uint32_t offset) +{ + odp_packet_t new; + int ret; + + new = odp_packet_copy(pkt, odp_packet_pool(pkt)); + + if (new == ODP_PACKET_INVALID) { + ODP_ERR("copy failed\n"); + return ODP_PACKET_INVALID; + } + + ret = odp_packet_trunc_head(&new, offset, NULL, NULL); + + if (ret < 0) { + ODP_ERR("trunk_head failed\n"); + odp_packet_free(new); + return ODP_PACKET_INVALID; + } + + return new; +} + +odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset, + odp_packet_t hdr) +{ + odp_packet_t new; + int ret; + + new = odp_packet_copy(pkt, odp_packet_pool(pkt)); + + if (new == ODP_PACKET_INVALID) { + ODP_ERR("copy failed\n"); + return ODP_PACKET_INVALID; + } + + if (offset) { + ret = odp_packet_trunc_head(&new, offset, NULL, NULL); + + if (ret < 0) { + ODP_ERR("trunk_head failed\n"); + odp_packet_free(new); + return ODP_PACKET_INVALID; + } + } + + ret = odp_packet_concat(&hdr, new); + + if (ret < 0) { + ODP_ERR("concat failed\n"); + odp_packet_free(new); + return ODP_PACKET_INVALID; + } + + return hdr; +} + +int odp_packet_has_ref(odp_packet_t pkt) +{ + (void)pkt; + + return 0; +} + +uint32_t odp_packet_unshared_len(odp_packet_t pkt) +{ + return odp_packet_len(pkt); +}