From patchwork Mon Feb 13 12:53:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 93882 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1080675qgi; Mon, 13 Feb 2017 04:55:15 -0800 (PST) X-Received: by 10.200.39.77 with SMTP id h13mr22067114qth.62.1486990515719; Mon, 13 Feb 2017 04:55:15 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m90si7165736qtd.98.2017.02.13.04.55.15; Mon, 13 Feb 2017 04:55:15 -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 5931360809; Mon, 13 Feb 2017 12:55:15 +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_H4, 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 4E10E60668; Mon, 13 Feb 2017 12:54:36 +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 2B571607F1; Mon, 13 Feb 2017 12:54:30 +0000 (UTC) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0136.outbound.protection.outlook.com [104.47.2.136]) by lists.linaro.org (Postfix) with ESMTPS id 666B860659 for ; Mon, 13 Feb 2017 12:54:07 +0000 (UTC) Received: from AM2PR07CA0004.eurprd07.prod.outlook.com (10.163.24.142) by DB6PR0701MB1736.eurprd07.prod.outlook.com (10.168.10.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10; Mon, 13 Feb 2017 12:54:05 +0000 Received: from DB5EUR03FT040.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::205) by AM2PR07CA0004.outlook.office365.com (2a01:111:e400:8448::14) 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; Mon, 13 Feb 2017 12:54:06 +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 DB5EUR03FT040.mail.protection.outlook.com (10.152.20.243) 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; Mon, 13 Feb 2017 12:54:05 +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; Mon, 13 Feb 2017 14:54:04 +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; Mon, 13 Feb 2017 14:54:04 +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 v1DCrU77020093 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Feb 2017 14:53:30 +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 v1DCrU2D020084 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Mon, 13 Feb 2017 14:53:30 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Mon, 13 Feb 2017 14:53:27 +0200 Message-ID: <1486990410-14928-2-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1486990410-14928-1-git-send-email-petri.savolainen@linaro.org> References: <1486990410-14928-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)(39840400002)(39450400003)(39860400002)(39410400002)(39850400002)(2980300002)(199003)(189002)(50466002)(356003)(2950100002)(97736004)(6916009)(2906002)(48376002)(77096006)(50986999)(5660300001)(76176999)(5003940100001)(105596002)(106466001)(6666003)(189998001)(86362001)(2351001)(626004)(450100001)(47776003)(8936002)(92566002)(38730400002)(68736007)(305945005)(110136004)(50226002)(22756006)(81156014)(81166006)(53936002)(8676002)(33646002)(36756003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0701MB1736; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB5EUR03FT040; 1:toKPG4JOVs6eNUeKwn4eYC+uPk80FtbdTSTTo75lABqDqcTxXJfU/XcTVvQdXL204jQY0d4vXVQSxHllw91wMVXmGMMjXLwSrrLW5FwGuRsFtyw28ApXtlW4BlOQ8SAVFcb6zGdl2kzCFJanmNXGYssiy0cy9sFY69x4myqupM+OZa3zE+ZiiEF4HQpSZ4rx+f7QyZqgqVfXlgYWppzwZ9nmEtOL2MQkwc3HoCMZGBSz9zRKtdHOuNE0XAAAjaXrNvB8q8G441IoCLuweJj6b9jwhvx8leGSuc4ldm/WgX6EP5HN/0yiRDQ96YwxAGtjWrUnjN15EunUe4lmIwaqTUOw8nrUkiSFMakI5K3ZOXLMpLGBreVou7nufYtDsySDCaPVj8yZKup8eIXqTYsNJwowG+Vre4X1d4s4vSp80TmdaCZDdB0dOxDa/yMG2OoHp0pYNX0izS4m2KiSGkVs7A== X-MS-Office365-Filtering-Correlation-Id: 57f541cd-36a1-4f2e-256d-08d4540f64a6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB6PR0701MB1736; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1736; 3:VOtUVRdXAKE8b4L2nGrDIeVrUO9nN7Sh3CzRhZQLxS3EkMBbcgafiWMednmZgEApqdPHHBPFJ6sBK5vZALwttnNqtcE+JSV/kVj+aojmJy2N4H37aWJHxpuvlOgDzaGi+JU/dN3bNEcZfmFV5/lsskvfPUwfKkbNXs3WzXI6LbMY+B34+0xDlcePIq/oPkNUJTvaaM2Ah3JxR1kbsnvY3iy6OteTmJS1oi4N7X04G3pudX6zACvTF8ito6p8B2pSlbLOfY5eT3KM7J0sLdt9/bDUaYVsBIqcGsc1mEo/0X+U5zKoZbtkF11puknYXZD7hckSv1zraxiy6BsBEynnZV4TPESTGxmiI/TRKOFRFR7z2BDz3snuw183pzulRjnV; 25:fbpgp/0UyczvE7z3AKStrYadyaxCfCwxUMoP31WS2ht5oOQ2YdsmPqJmt/apmE15WOXvpT+6WjI+qGz8SVVeui9g9UCgUFupGNuA98+p1VPOq8evTP2bXYWULbbl2GxqmEw2wivYRnUCMPFGeO6dp8IJcEaAtfHZH4cY9luPjsBW/0u6skc6tcNtAYC91omy4UpGpL5q0Z+f7XU5l5Z5/tonwK8pPcj3bSuXY1w8VrVHLvOHtu+d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Hh7TydCQ7OSKETO5N9PLsbZm9deWTemdMm5RiORH+KtJug1aedgJy0r4gdKjaJcHocXGCo3cFNntWiLYVPbBTuaeXavGa/Y2xo8r28= 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)(20161123562025)(20161123555025)(20161123560025)(6072148); SRVR:DB6PR0701MB1736; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0701MB1736; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1736; 4:8wpLBNWRT6eMPNRV3HhODDywGTE2gV7/8XNZ/G5gkfvlSZs3qEeDthc56/nNDZlh0bplB1tMFUxi6Gm4OtGSWQDXAjh96Qm86QQii9OGi7mxQN7Gll4KXNlmjCYA76+7JY+500/Fz1/PzQ93X8JUp1A1er/2Rp8gcEFVPtCfpo1w+d43A4S2scpu1QwOXGgKPLEn6XNmg40Jc+nlEcw0ReJwHtWm5IJpZWYkJ9MgIiGuqLF8llVYLlw31U9pcrHnpCUAW80s8F15qNrPfe88jPK8jEhVK/X088NOmLR/+rE9XleunBn3Axcuwtg+eazM44XK8BzBEVIX8P3RxVTLX+xR4UpFreX8yEo78ok4vpWZlkal1C6gHhIPBNZ5BUgB449nVS1sW9Uc+yUqbduOnw2fFikZyJ4AQCXdJpcpw4RUQq31hQ76sUvMaM77D2lo1uSScVJFdswyYi8LHoHhGQ4xxsM9OE6/6r6wiKH0X3O1w6r8aoqoDS2aJBr3mwKXWVFidqJEg05Rka8zW8JrukhuV85RhuxIVe4GrWrPg+y1Vyi4N8cDM8ooYsAMtuPwFkih5xLGnflGYFzVCQZl4vmmVpx8HEPT6/iQaeYmwaEu4CEv+NRu4RCNcvTxdy/VaP6pyEA0kd98brgp9XGFkWJ1s/n+R9VquzfZl/GZGg4= X-Forefront-PRVS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lHJ/RssZNIpz1ZOBvdbEm3rXL7WdSwX/OQMiltdGbHR8aP4EcmwzHxMlXUt/sTAJgyZYKv098LZNlVrdbRloL3e58cEdd4jebVdtupiz6OAWDhvQy7JPN/v X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1736; 6:5GjufMRtk4vSPQwPIFl3ubbXwUzH9qGj6xWP0XGIpLM7Ci0t3vnXGVNctig2In57bhUHEDec+HNoSglUTw3mfySCbhL30eukmfUmDa4Qg2yEubH9x0712nDDXWZdSRRZlgEVXoAnr0ho7lfxz8KL0zwfYg1kggoo6yG5rTPrMH9nEtGPNUDKk6mPMdigsHUuMdi1aLC4ZdG1GvK02pu8Qye753CInYPsDuZJ40+HE7ffCvbPKU4SKAHGel4eco6ha27SmCo9b3T6E1LqJscjUSJ+Tu+P/XIweZPPKPrk0yVbAzC2GVeKWat8ZQUznBM3tF8MUUYa4LoriTnOiZhlrMmDRs/DnSrF2bSwQ8w/pLJC/QINLR71fxYRrZD5eZgxAdAFJyQSxkDQgS/j6ldRqKvcTipUFrOPJ/kQD3jJ0hg=; 5:Yq8yqVK0yHjbiA2Osv8LqzgJytjOzg0I6/5qRfXr14OAA5rz+lVjvK09J686dzrbsHVQeLLuYyy+sDTnrIp94mAontFPHS4W00Wdk0/y+y53xv/NypBzNGbJ2RUH4gdCIMYpmQ0sl37m9LPOD0yQRMJ672/PGxAKsfkvvZql+I4=; 24:vz+y8mwWb0lHrFVwX7hM8GRymsZs6P+2MHHvCZdxyO7nMgYN3IH/A/iiEmsX9bmkSimaBhAhtcO48C8I7Uib6AXUB69jHJt8VILp+d8k6BQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1736; 7:l5OpsLqdPcnU0MuCCcCEKAoNdsmpgWoqMu1PH8Kyu4hdi3MiM4pG11cvdapFGvEH0BzMMS3Y/uqDcBTmToKgnQCj/RVI0dz9Mt10Mg1I720S3OZKGwwUljpvvved3eeEeDfepK4od+CumPa4jbj1CEgqSEJsVIK1KbtlWNuGI1Zxekcyz4xBSoL3VhwufA8dq9hWDmcKzXUiIAtMfmSrM9/Xk/MsM/mSkCXVS1TGuWmtw9kDIcJZZN4uINpt371qO3xg54IAUCzydPaT/elfz2cUmdjmFlCfBPwKQrRWKI6j2lEjGSCOfk5Ur1C33mNlkPb7GX54hfSzfJ3hy7kC3WqgZB5iT+LfMZWxGM+1j32iiEvOQXbMUWKZ1e0F1+gXxcN68E5mgwCLD1DKwllWmMcbpWKWmT4WMisUGaxTdYxBDliHwI0CEBElveDw3JM2CJvLd3kNDXNnmKILwZjSDImhYMQEhhnIy4a1Yn3+XNoqAosGtRXRkhGph6PZqsiXXfGRPjvoGGCFP82SPkshrA== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2017 12:54:05.4841 (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: DB6PR0701MB1736 Subject: [lng-odp] [API-NEXT PATCH 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 | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) -- 2.8.1 diff --git a/include/odp/api/spec/packet.h b/include/odp/api/spec/packet.h index b6450c1..05ffd68 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,16 @@ 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. However, some of those calls may implement the + * new reference as a packet copy. 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 Mon Feb 13 12:53:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 93883 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1080901qgi; Mon, 13 Feb 2017 04:55:49 -0800 (PST) X-Received: by 10.36.77.10 with SMTP id l10mr20406086itb.59.1486990549851; Mon, 13 Feb 2017 04:55:49 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e124si3518942ith.122.2017.02.13.04.55.49; Mon, 13 Feb 2017 04:55:49 -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 5D03C607A7; Mon, 13 Feb 2017 12:55:49 +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 B973F608D2; Mon, 13 Feb 2017 12:54:44 +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 99EA16089B; Mon, 13 Feb 2017 12:54:33 +0000 (UTC) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10132.outbound.protection.outlook.com [40.107.1.132]) by lists.linaro.org (Postfix) with ESMTPS id 12F5760668 for ; Mon, 13 Feb 2017 12:54:11 +0000 (UTC) Received: from HE1PR0701CA0070.eurprd07.prod.outlook.com (10.168.122.14) by AM5PR0701MB2914.eurprd07.prod.outlook.com (10.168.156.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.10; Mon, 13 Feb 2017 12:54:09 +0000 Received: from AM5EUR03FT009.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::204) by HE1PR0701CA0070.outlook.office365.com (2603:10a6:3:64::14) 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; Mon, 13 Feb 2017 12:54:09 +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 AM5EUR03FT009.mail.protection.outlook.com (10.152.16.110) 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; Mon, 13 Feb 2017 12:54:09 +0000 Received: from fihe3nok1349.nsn-intra.net (10.158.36.137) by fihe3nok1346.nsn-intra.net (10.158.36.134) with Microsoft SMTP Server (TLS) id 15.1.466.34; Mon, 13 Feb 2017 14:54:05 +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; Mon, 13 Feb 2017 14:54:05 +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 v1DCrUWc020098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Feb 2017 14:53:31 +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 v1DCrU2E020084 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Mon, 13 Feb 2017 14:53:30 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Mon, 13 Feb 2017 14:53:28 +0200 Message-ID: <1486990410-14928-3-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1486990410-14928-1-git-send-email-petri.savolainen@linaro.org> References: <1486990410-14928-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)(39840400002)(39450400003)(39860400002)(39850400002)(39410400002)(2980300002)(199003)(189002)(50466002)(2950100002)(97736004)(6916009)(2906002)(48376002)(77096006)(50986999)(5660300001)(76176999)(5003940100001)(105596002)(106466001)(189998001)(86362001)(2351001)(626004)(450100001)(47776003)(8936002)(92566002)(38730400002)(68736007)(305945005)(110136004)(356003)(50226002)(22756006)(81156014)(81166006)(53936002)(8676002)(33646002)(36756003)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:AM5PR0701MB2914; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR03FT009; 1:n8GwqBZcNUITblrzmT3oEa6+UIzUbCG032g0sTIefMnNWXf/wrd/Q4h1Xaqfl5HtQbeka8xU2bi3lDr7RG2HCIz4lnjQhTby1aGCRZ3nqkgyNhYQweqcP5q4MtNfcorOkofHJwVbVcSjf7ba4ByGUJQ2bZ/mhgk+nTrPhl6idofhN24cFu068bJ132c0KLg0BRQnPoSz+8hpjQIG1S+x3z7CFtrgA7QE0/nEzLUZBsTZZ8ftDFconekbN+AJG2iJ4jy0dl/A2Y0iFU7ittlsaLwL5isA2sRoM0GqVr/6okzA3wdUdwdxN/EzA0F4qoXt9BUSLWqc8JjGroTfccMTIs/Go+qKydBBRhVD9zyxcfI4iuhTmPIhTzSwTw0oV8eMZhNpmczG2/WXLgeX9ZDBEZxzrkS6O2YLaF7mfSFYEV6fbLi9ooK5tH0YyIJmbdyv6iS0lb2kVFOUzQGnsRG0vg== X-MS-Office365-Filtering-Correlation-Id: 4907a114-c6d7-4512-005a-08d4540f66be X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:AM5PR0701MB2914; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2914; 3:UP2fFEzntHUiqo6sF1bxOy0cgwWquvTC2/AG/UcXbVK5Nc3C39MAixxNajXltEa6OHouAUQlb0Lw3pzZXiYrrucAOUWdrxB6qZtTMaw++EWD7nCDJLKlqQIkiDRFxF7hdzdyMB5FW/2TJs/lXelvs37mjv/BeFIrxojREakGCU73XrosYsz3hLe1Ycxy0MPwoU2Q2kAyNW/7HMnEZiwro+Q0tSZD9GAz73IeHrxwd/QybRFm/lR0kGgf7CHOV3ViaxjvBCnPTPFNTIgUuoVSUvR3dFB7qe1YhTYYcrxhC/qeBFdeJF6UGnD6BV4FGIBK5DmUZGlkk1IZS+EK1uXoAstC3otJEfzhpK4kFUu66mT6pGS1jfY4KOeitmkhjRRf; 25:9Y36l+TYCtkYT12ugINXJUr+wZKRf2SeUNtRom0fWFLamJGAPKm29Bfh5d2Y0zuXejMReMa1KSIhSZXQbeNw7taRK2M+4hfXiIP5bcVMi8OKlQNsrp6/2cxKl8MwLp2U/01oXUjxGnf19x6NopQ0H8CkUkqHvu0211KLrNuCZT5lDP86YfEwdkF6+ovuFZiTqWGcruhUVz+Ouy9rWuF+kvQ6Fi5mXdxijCjCtct1yWvqpp/VtiOkcuQFFXZwv0jPkGm4bX329Gqj7CKW+pPPvQPMMkPk4o55Lg/Pm1GtgzaX2k7q/ORJb8cSGTrtpETNWOvc2hYZsCVvLXOSbTHEm/Fd50NUJXOhqIsdFv/Bw2fO3lHxhB7jGocyHUlmFdS+p/5mTrDgYlQQy9sfhTZlBQy7UJJRsR91iNB4CmsMZd+MpBcipxGl9DY8xnzBvmDnpKdEYI8Eou3LvqpnFrb34g== X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2914; 31:6Kkhis/r2Hj5Tqi4Bt5tTKPczkVXbSC8F7nxyIM1eKvtcVvxGpf3YaBuR89VJMDNwutFd0o0hlJqjUaBxx/KqaEiok3ja6mG3KJa6g13J+1Tv5g2LGa8B/ycP1avb+K98sEOAZDCNIbtxCA1DUPg1Q1U+FGluOWvEEDIoAGA62GngcZS2+qtIer9i+7FrEQhy/0WQcQyPKZm/eRsj937hNA7qFgJVQMy6d4gUR3VnoY5SECJaXqEtHxZs9YSbVKMIzfGcmjNekyxuZVAr7H6VA==; 20:OrjnkSp6Y+FbX7LPNiOPZHCwTlsz0GwtlHaovxI5FcGRDRPhydlqO0c1Mpo3xLuazV83FkVOYuFBgyn4F3mAOOOo4LxGYCndpWNY3GplQQ4bjARyQgAjTKNyxnaoEOic4kNlw3Nnrf8G68neZ1/cqy6mMzwBTOHjWtnYkFGn/oARtorSbKKsmevcNs6mslxB2qyu+1MXbAZJOdrF/c6aeXufvtuqlAb7SZCGMg/ESQhhC/LdvLVyoq1Uod99roULL2P1fBahYErp0aMNsTPmwKWbRl5bRXL0fTfxI5lutf2kjGaihOvwUBMlJ/5/dModoCvWH5/fhcoaEd1MwknlaL6kafocM3VPmhryaQvC7scShNHx+tJMXFuDcRI2yKIlDGUZWU7+lBd5X27pzbMdArKeMsiXa9sUqVB+kVtP8AL61xrqaJlo+amdGx0x5lg/o5xALQtdqbaoClOHcRrMQrGC0XbmtXiZRgxuRSOMewIIagyMlnajKbRMsLAKiDgpNUStFu4Fax1SYmFruaTcz2abEOf48t38qZuxTWCeifpG8QxmKq6rYRqp2wXkot0vI3NyaIpBJTPtPJMQcex+TCOp5mdFQ+1Z+1tzZ8JdUpY= 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)(20161123562025)(20161123555025)(20161123560025)(6072148); SRVR:AM5PR0701MB2914; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0701MB2914; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0701MB2914; 4:/ajt4BqEwgAvxl7MrbKFOUEFnv9Bx0KSEWN1+RvTZ1Z7EYKQfCJsy3J/8FJ8MCn2vzClChip997aTm8N5POEXtLhd/Q3Ou8YX4EQXzgiTsYDeEoyRpXBpIICYX/DurQFfRRCePfy5QvMX1+8WlmoZQ9WWt19p8JpGmPQBUcYVtuDotpVnvaFAgzKLoLRaspsPsv+gGY4UHO4DTyo+9ntE6yq32zPfsuBHaYtybdDe5GHCZmDo+ibmkFuiMCvu7KhkWGw8njVEADeyNCa3FINvee0HO2WuvNJQleAXosFuhx9qUTc6dAAgDmMeGnLvQOTorDdL1E4ymPiBJCHrDoG0u6NgzXX/eX8LbBiG5XSY+ynqghu2ggxZaxTWgJHWli8cj9lBLFpnzj5QTsVvFo6DrkV28mdAAgwGF8WeqZhtiLjckeINFLTTvcWZSD6KgUlhvIaOhajQ6WZKYlmFLK8yHIvVychEBKLV3ngJ3Q84t2rhR0gbar1Z6+eCFWdHQA3S1uohettBIw3/DJvFqsp31bR9GDfwhUu+Oz+ftxdKRL61cdKQGUjCc3eF6CqsDxLvdC+BxEAY18pfAd/y5qmEcu0MThMjQ7UCBf/rY09pFOMwnK3QuYLVT7hWOv4hQDVteTRkib1zwTjfB4G8YVUOjqy7FM+0JkHI5p1TCON36k= X-Forefront-PRVS: 02176E2458 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM5PR0701MB2914; 23:Ci5PZmHiRf8uxEiaAklYlhQltyy9Yrf6D/f4wQE?= Hy7tTajkjhqc8HAHzFBjlQ9eDkX6+woeeAxRMnCbeT0gaYMlzeNmXmR2qdKjpO8phBnlOwH+xr7SFN/rCBawXr/Xeo3wT2rZmrLj3kVawvPc4qJQ9I+ACvlqQMiq+vfdVm+hZWiH8eoACBMumj15Dt+pf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7Crkk/iJzVaK+C4d0rII+ebUy3zNIiPSQI66JS4l8P+dLjAHDpEf6yIelMzQIYfE681cP1kfB6+G+SpAxzXm8w/KycNjsFKuI1sILJ3q2eFCL/vDCcpdBEMkT+ulTDrWxVzW2cdnlbUDl8pPA6ExzRZ9Q0Ig== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2017 12:54:09.0271 (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: AM5PR0701MB2914 Subject: [lng-odp] [API-NEXT PATCH 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 Mon Feb 13 12:53: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: 93884 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1081340qgi; Mon, 13 Feb 2017 04:57:03 -0800 (PST) X-Received: by 10.200.49.249 with SMTP id i54mr22226977qte.3.1486990623735; Mon, 13 Feb 2017 04:57:03 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t28si7143050qtc.337.2017.02.13.04.57.03; Mon, 13 Feb 2017 04:57:03 -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 54E226084D; Mon, 13 Feb 2017 12:57:03 +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 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 2BC6D62FAF; Mon, 13 Feb 2017 12:54: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 8F3A8608D2; Mon, 13 Feb 2017 12:54:38 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0110.outbound.protection.outlook.com [104.47.1.110]) by lists.linaro.org (Postfix) with ESMTPS id 8A6B260870 for ; Mon, 13 Feb 2017 12:54:12 +0000 (UTC) Received: from HE1PR0701CA0088.eurprd07.prod.outlook.com (10.168.122.32) by HE1PR0701MB2924.eurprd07.prod.outlook.com (10.168.93.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.5; Mon, 13 Feb 2017 12:54:10 +0000 Received: from AM5EUR03FT009.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::207) by HE1PR0701CA0088.outlook.office365.com (2603:10a6:3:64::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; Mon, 13 Feb 2017 12:54:10 +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 AM5EUR03FT009.mail.protection.outlook.com (10.152.16.110) 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; Mon, 13 Feb 2017 12:54:10 +0000 Received: from fihe3nok1349.nsn-intra.net (10.158.36.137) by fihe3nok1346.nsn-intra.net (10.158.36.134) with Microsoft SMTP Server (TLS) id 15.1.466.34; Mon, 13 Feb 2017 14:54:06 +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; Mon, 13 Feb 2017 14:54:05 +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 v1DCrVHA020106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Feb 2017 14:53:31 +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 v1DCrU2F020084 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Mon, 13 Feb 2017 14:53:31 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Mon, 13 Feb 2017 14:53:29 +0200 Message-ID: <1486990410-14928-4-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1486990410-14928-1-git-send-email-petri.savolainen@linaro.org> References: <1486990410-14928-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)(110136004)(38730400002)(53936002)(48376002)(189998001)(53946003)(33646002)(86362001)(47776003)(50466002)(356003)(450100001)(8936002)(77096006)(81166006)(81156014)(106466001)(97736004)(22756006)(50986999)(76176999)(68736007)(8676002)(626004)(305945005)(105596002)(5660300001)(2906002)(2950100002)(2351001)(36756003)(50226002)(92566002)(6916009)(5003940100001)(41533002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0701MB2924; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR03FT009; 1:9WeoECGrWBjrXoq58qMRo1iYZlaXL0u8kKi+UyBppy2LNB1icPoOKpyK728Oa4M8nHnA1eyeGA833VyGmoh6ZFvUHTkT4qocSpYDp5AUfQQ7Tbw0wbejzpddXMfnaWG2xAjmpZiFbcqrFae+mmlQokxbH7JIJMxmx0pvMGIBK1+hpMufhiUuD9v1iegDqELDSYqKAzpvJ/cJkuj469Xzn6pZnvgeQ6GD+ZRVH6ibSh8NN2gIi4e02IKU4nR0VaOqu3hoFClRWbecZSQn970XFGLRy6vcTizUlVA6/Rytg7nysc/akXTNm5//TrAYwcZIqb1a2qTwUa81UWLpQ+KPe2o+v83g7mk/GunKqnDMsBbsNxGPS+kabzqI9lxMMMaRlyXopHZgebZ6fy5J9UwBrIRoHq/WV1Kqj6vqma/V7HUIVJGRHp+OC0RaMzW5O0HSB3DDiViLnPi6V3RUoiXxoQ== X-MS-Office365-Filtering-Correlation-Id: 5e6a1a8c-4108-4419-6f96-08d4540f676e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:HE1PR0701MB2924; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2924; 3:cI8IY+H+029f536ahVEgUHiMi7U4Gl30X5AehfNCMP/f8KL5oP+T4fWU0wkafHqeLRgJvm21eRIPy9SwKWfR+7nlEaHi2eYe91mV931i5ky0qEROYomJVkW8Bl5pnTlDLU2J4bJRrGZqdFe/qtaUJ3npVVBeIam0KqCriVrIBLP8ggfWihfF2nI/JLvDbKjVljzKEVUVwegwVJEfUwcw4UwZOdCkZfCnkU6DN/0gOCFifPvo1wJyQ1UqWWlVH/Ut3lPhnDfa5jjN30FbbCXuK3wTfJ24La3KGhpG6aGpirr8ZdAozyU9fX2m5RSxnwfae7M1y5+qqn9g+lACM7IxfbsuHXVYNnrxQfnKdUuYc2Lp+Qs+OJWgXlci5mt/8BCH; 25:lm+TkhSRnKFQl+z2/bMNdJp8kJVrpwWeajgXyLvGhwTw5zhnmqFysY4S6Q4h3Pt/E2Lb+TEkL2edA4YEJx5fWWElIqeBKYsn/49a/g4Od88LE4Amt1bAOzyNN8Q7Y6ScyzsrkynE1r5IcW3HoDbPoh+Bq5tpKsuo0dhc9d4Wh2fBk0x3ZvZQizGLEA0wS1NKq3y45YZKLXGMNJavyql5KnnlSByCA7UN+EFtE/iYah3I01vdes8xczHTN6a0MDG/nZ3Nq1y14JN0T6kJXLhgBQsMJIB05s4N6lULmUKD8zvpHyGyV+RWaqcyyYEQZmp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6Br7zzjoSlN6rBuock9g46bnC5czf0g4IABB9w= 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)(13016025)(5005006)(13018025)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123558025)(20161123560025)(6072148); SRVR:HE1PR0701MB2924; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0701MB2924; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2924; 4:S+rQ1RuK8F0FV9jQmLVTmNdHBExo13iSM2uqM0XDTVgXH6/MpF2xAGKIDO8nfjJLywvP3w8nCGyszl3wVRNgxBhee1wDn569F5+rcTFCEYWqiCMC7BQ/yZNOUaLNpPzQhZorku/E1qC631tQUoz4N6zq4OBjV3AL6x5VH9X/YnZ2ubheQKr1a5niInA/VxYAvCEZWVT0KSGKZPgb1ywna3ikgTZrsooRJ9kyikJNCO/nQamfD8CuJDdAah/maCxUOqAv0H7ZIS6vOYwXLiDfL/uSr8UB7cZv4jxM6dAVfIa70jAc54JokvWs5bbq8kuqPbqNQt7wP0tudLJQxWfVmrlsqzvQ53I7IV8yekTA72zxUC2zr0etj0HQ7BQL+5vOsyQJLfjIU0hMnR107SPsvmWB9lgvA62Z0e6SAF/xcZMO7HS1lysDb2OJuPTtj4g3+lgai+6SpMQCirKriY+kIb+jcLvfUCW0ddR4fWCKZzHE2ZCP/7PbXPfo6R+ZwQcgstH4Cdpi0c/VVeS+2xWc9j8G5l5hMzEjFpuOfO5I+IYSYwtz3jRmhE0LgsJInn4Ksy0EmL5ZWOiQRxt8QfmzQsH2qmIpqTMoDNdQNBVo3H5HS1w5TRFYtcXm96O/awT6XP/P1tTaPjCwmHsIzpwLLGadweK24G0TXbWXC8xYc70= X-Forefront-PRVS: 02176E2458 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0701MB2924; 23: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IcJAmUFXgY0360GN9ccyIcNqx7PCpQuunxvcG4DXOVmPOOOvf/9D1pqvJ4T/343NtORRpUXQvPMFV3vK/8K6EutjpgVw== X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2924; 6:MXs/2YhwgWC7Uc4whMjoa/h7E4m69orM1xSWAjz8LM+5LCT+svN6Hpc1QO7qE9q7r7GoN7/VoGS9Mj4edc2fkjAZW9G+GSM7jFgdwu9FyEqkuHH3qQphKSdK/g5jcr3l4dyHQrJ+qTgdP3f10hWovavPzkIu2sOJ96pTIk2/ctjKWdhEPMQDt02edMxpy2D96mW3evnw2n/6wxhcNfnwtHouboEWDypGW0rSQWQMO7loD1ty++1p4f0NHiPkO95gnL7VIQJ242WgVSDZ/qnTmecUGll87diOfxdNQbIYqLLjadHMl7q43X6KA6gjY8X6/OvEknJ9RRTGvIXCi7kI+6qvmXKPW6ANzqF93eJEK/pC82cMuY9c/j2e6FhJKOkOr6ZPT/9tlDO2Z5XPitpwc+m5W/HF4HqGIObyvYd0B28=; 5:6YY1F58udFNZNp892mlLo3VOc/uyOOVO6hBNbKiZlb4GvQd4b8kAPInve5dDd25/p6as2C8Zz11KEdox2HLb+qVIOAmt1aVizVa0PgOvdNkLBxqO1uSXL668n+dqMfX525fFsJFtYbXOVtouA+tzEJB0hBtEduzLcjLcFT39pNE=; 24:zjPe5/OR8LqZGqSorqKAAsxlbK7Gsi4MF5mUPVpUpfo8oKfjyGB12MenozgZ6SoGUEBRqIiISHW6e2SdfDHn7MPieXUglW00ShL7LAzA9/M= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0701MB2924; 7:WKwQTAhodCPp7e2GN6eHEfEzDEVEBbU8E5xBPoykR6ESytqD/hnj67yYlcEBmBZ+HFpmITOIGeIJ0POgWBVbyeNHF+pNfPXz8RoSVili7cWxrTJf5M77BpGYpNwcl6F8ECTM51c8sLDa32QZYt4t7zL9fDQuTl+nPxt5dIAtOTmBPVQi/jBpzkd1mNlVOyHoKLbB4EWsC/+6KENPSjhlDtP/lKmkdxz+YzyJ6PdqVfbhga+/BXTarYfe6mpr2+A1InGp1mA3R0eO83YELebY7AgT//H0ZtqSnXcA8VJl3kAWkdAQZ8yQ/L3zyi15CUvmevZvSGVsZ0RALXxpXxp5yA5R+WB8ADfoBDbwCChq8SsP4WJKNWqgRPCqJsQcnV5O2bbdID6dpwXH+wQicar9j5XWvJM9VCugAGTPEb4NV/Qfi9aNdThA24p2D24d9l8ryCSQn2jVgEWPcV3HBpSSFBEiRU+VAfAq3cPVKPEReEiGi63PIzH1IxPC5KTuUl/x+C0TGhdzbFRhw6UbkDAGAw== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2017 12:54:10.1834 (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: HE1PR0701MB2924 Subject: [lng-odp] [API-NEXT PATCH 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 Mon Feb 13 12:53: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: 93881 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1080484qgi; Mon, 13 Feb 2017 04:54:39 -0800 (PST) X-Received: by 10.55.114.132 with SMTP id n126mr21173343qkc.112.1486990479467; Mon, 13 Feb 2017 04:54:39 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id z130si7157822qkb.80.2017.02.13.04.54.39; Mon, 13 Feb 2017 04:54:39 -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 0739F608B6; Mon, 13 Feb 2017 12:54:39 +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_H4, 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 B9ACE60698; Mon, 13 Feb 2017 12:54:32 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 86D79607F1; Mon, 13 Feb 2017 12:54:29 +0000 (UTC) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0103.outbound.protection.outlook.com [104.47.1.103]) by lists.linaro.org (Postfix) with ESMTPS id 2A9B360809 for ; Mon, 13 Feb 2017 12:54:11 +0000 (UTC) Received: from DB6PR07CA0103.eurprd07.prod.outlook.com (10.175.238.145) by DB5PR07MB0822.eurprd07.prod.outlook.com (10.161.196.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.5; Mon, 13 Feb 2017 12:54:08 +0000 Received: from AM5EUR03FT012.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::202) by DB6PR07CA0103.outlook.office365.com (2603:10a6:6:2c::17) 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; Mon, 13 Feb 2017 12:54:08 +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 AM5EUR03FT012.mail.protection.outlook.com (10.152.16.161) 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; Mon, 13 Feb 2017 12:54:08 +0000 Received: from fihe3nok1349.nsn-intra.net (10.158.36.137) by fihe3nok1346.nsn-intra.net (10.158.36.134) with Microsoft SMTP Server (TLS) id 15.1.466.34; Mon, 13 Feb 2017 14:54:04 +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; Mon, 13 Feb 2017 14:54:04 +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 v1DCrVZ9020111 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 13 Feb 2017 14:53:31 +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 v1DCrU2G020084 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Mon, 13 Feb 2017 14:53:31 +0200 X-HPESVCS-Source-Ip: 10.144.104.219 From: Petri Savolainen To: Date: Mon, 13 Feb 2017 14:53:30 +0200 Message-ID: <1486990410-14928-5-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1486990410-14928-1-git-send-email-petri.savolainen@linaro.org> References: <1486990410-14928-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)(39410400002)(39840400002)(39850400002)(39860400002)(39450400003)(2980300002)(189002)(199003)(97736004)(189998001)(76176999)(50986999)(86362001)(47776003)(92566002)(110136004)(81166006)(356003)(81156014)(38730400002)(50226002)(5660300001)(626004)(2906002)(8936002)(305945005)(8676002)(68736007)(53936002)(77096006)(22756006)(36756003)(33646002)(106466001)(50466002)(48376002)(5003940100001)(105596002)(2351001)(450100001)(2950100002)(6916009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR07MB0822; H:hybrid2.ext.net.nokia.com; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM5EUR03FT012; 1:OqQpN68pZMOhFxA9puaP2Gx++9doJbA84ywftkhoYBAneN6L+qjOJAPk1EnT6Ti9zRmW2WeilTYfKtap2wyhu4EkZUVtK2LWoVwKwdj/Fex/LkM/yCFsYc6fGWkd5a9W2xRbWMdsm4D2AIvI9pKJi5fgTQCVZ7TP0PKwn9gQyt7EZetKqkLITXU3310HYu6uO5KrR7CQIcN6uVUPBvVFutXBUWr1HEhwk69fKhDLEHp9ODYhGfWJyYuQiVCYnA+ERdFHtXpBu5ahrInI8gbvMcbtkjV+NbBGaIU03FIgnetI1fm/enex9ehXYDNkKHodP/vxSvy//zhS3JJrpc0ZmjW9TfgZcO6CDsBcwQbquU7Pf8a2xJWwIu87kBPfGZ138XZ6cg3Dp7Uqz+Ooyw4xbgSpfSqA7Seww3gqJ/mS0BRTBCfogfWfEo4+eKs47ffvgzc9hezyNF1bVRDEyOmSLw== X-MS-Office365-Filtering-Correlation-Id: 49827cf2-a53c-4b6a-81bb-08d4540f6675 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:DB5PR07MB0822; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0822; 3:/lbaU73vdv14JmgYql4weHf5R3Pi7wJltL7JapLgFMEV/CCm3h02SBN2VMAxFTISIJWbp532z7Dck2d5tZ9dqmWxhROS/Okdcfyh61aN/X5I7IQ4uIR9BIP4QLhQmNbSAmPWhUzA+vo/gedPGf77BQEtJMx+kbNG+cl28WTrM1HekHJtUjklxIqeGsMO0tkYHhZV6Zp6IpEogcCfwCoq+ojR0UoVYcOeic5z1H0QK9TbdF1UuePrcQ48oV8TY+ox3fphjn6mEMsxndSLSQD845y15GrBDsdAPxqJoaRHbrVMkotA/xjA9J2O0ErFdlhTIvB7rb5uOc0GOCCRbJWIcVOPMniBpVOocByClQtCv2inRhhN8J/xseqndHvdnfaS; 25:WO1fcLugFh2JSaTVvt9eOqVwKpSikhjYwFL+lnFScrc9s+4Nd7bfzhSyDs7eZwfQjlqYrZqqHdR1u6pzg3apkxb7XOS4VWueh6hge+TwcAzoz4JeYOmCaBfdZJLn4ORyb2aKwF1nD0dgI7I9e7p3R08ALTTjqCyRS76v/yKiEnJJKCx10BQcoD97wK/tjnGVmKfV7Ob90kB8Chz1mtv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lk+6dAQJuSJiqLScOFDGxTx3FqhM9ykUFc1IfsQzEWBC+50mVhZm3R59jamVc1noI8Z97PZpyTaz/QOTwECS4n2bYw09smA8+/gdnDX0tc6oCmiPuEvEbqwADInK7mDma+T8IAmivqjs= 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)(13016025)(5005006)(13018025)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123564025)(20161123562025)(20161123558025)(20161123560025)(6072148); SRVR:DB5PR07MB0822; BCL:0; PCL:0; RULEID:; SRVR:DB5PR07MB0822; X-Microsoft-Exchange-Diagnostics: 1; DB5PR07MB0822; 4:dM3FkPTfzFGjrLsb3YeB12ng9It5ZENCGYhu7ucHab5FVYTLgNoxDKS67i/XesCEWQS2kOlO3390HEQG7IHrduyG0KR3xPkdFPS6sUSDYammDcM6ypCtdtK5oceo8nL428EXfNf7AV/Obh7VoHseDgryr7LdzKO/Qfd1033yvr4Qke4QPAXnNlG/Q4Knuy7I9BADHNI9aN6xMJEFMTdzLf2Lpzni9x1rqWobigLV8L4cdQJAshaHaZ2oC4ASh5TrC2k5Cfbik7mgltSmtsUmYV+tFf9sSIoRCor/7dc5+rf4/Ho/N35ZY1Pfj8gx8eSof9RzQLl+uFwMFWBvWX1F9xRnhZUaSsivNwy89ZoWPUDr0YD3vbD5R/GxQ1BpQ1C/ehoaJmEuFmXHN/FWF09xTkZSCu8t3uwYMo5HBLqz59cII0YJ2MEpOT6mCJaJTi98D/SeZVsZNZJ+ASYct1OCXrYbEL0A4glMHyUgqJNr3ZgOsxM7A0NwxOYOvqZ5z4MHQT7GSC5+4tF/WVrM430/O8iPPBlQ6Ycu6G0w5CKtBkfCFgFWAVzzo1F76Ww4Q+TRysj3bvjCH1rHQ0hjiPH51DEg4RDX5K01wD7FesmXzsNbrIhkXzog45cVdJWcqGot4aXcq9QNST4Kb6Id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odGxUxiMycmQ1I2UqDy5AS60OvByHegCafi2WjkzkmxidA0xx6bt5ScFJ9+EPJcQCEBbdNqEU62BzpMkCSDxP+N8kp5B5bo/Vm2qgEOLYSMcmDjTAkuc91XOYOqK3WmiFbkSxwzeC2QE5rjOqFyqjY6Z1nGyeYFyBGbTi9VuYvZjw30GyejkkaVW78+sOxVUi0Tm87p9XpZg4TU4r0IrFmlRrIvAiR/WrZ1VddeCltLGRce8X0CLYvY63a2ObxSDCBoVn8MC1mcersc9iAtOYhCkw9fbT0noJs0mllmlOWR/p0oji3/l7HGgEJgsRwW/qR3HjNf/nvRXanh56opYqenolKhEYSYeTtOtBMr6nFy8ckTOaYSCMvB8j1uANas+J1Q9yCpAItGTTyMLeUxVoutghCUH1hTOQYyo824uRSYdzwCpG7q2r/IIjYu+pZA3IR7hZA== X-OriginatorOrg: nokia.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2017 12:54:08.5520 (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: DB5PR07MB0822 Subject: [lng-odp] [API-NEXT PATCH 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 | 78 +++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) -- 2.8.1 diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 024f694..1d2b506 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -2221,3 +2221,81 @@ 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) +{ + odp_packet_t new; + + new = odp_packet_copy(pkt, odp_packet_pool(pkt)); + + return new; +} + +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); +}