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/rc9gMSTsOFCK6pxZy7cK7ZBq6CXZaFEgDlFf7bBCURwNKtY4Y; 25:suLi7AImXQjzxI1sShCaplwXS2dvJCFU2J1u1ZvbYcMZ64daDfx6ZSSUulu5Yo6ilnmm/6nwVaegcqhhkM2cSNuNiK8s0irvyz+Lcc45moGMCgLESOobuWmlYKw2TpASjzxu2tW4HNqaA5zgLVLJ5GLPF50KxKt0meibxMTzHgH/kpQG+/MOpPhXJapMHUoynHdT7JrbgOXWMXwSmbSq7XuasRLjMLfwrk+efp4dA+gyfmuiZz9Z1miAD0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YI6lS78CNMeH0Rrl32zBR622XSMAxXuSTcw+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/7yqTNp4OzgexgNZmSW0+5Y8vbltG4jup4oHUcIct0W0KVusOvQyqQaQFo2zkVrjgcNtiGM8u5I8uOORr8/DHx7FxrLUVU4GRKx47YipLoOp+CZ8GciSZBqtp/qOFs00q6YX6BW+sWgHamPGM8cFA88HYF4ShR2ucCB3nDEtU1KwTS0vwaKbTTmLEZIBFi/Bm9Pwm40Et0SI52r3Rd8USi5n6Y3TeDhd+sL8OydDCeHcM8N8= X-Forefront-PRVS: 021975AE46 X-Microsoft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peKsabuW7+wWakh8znf11iQjP6IAUHhGZhjdKcxD1NxsJZyG8zSIDaM1rb7/S8sPC0wrOFZkDkvt4kkl1+Dq8m3xM/y91wxbTXc3eQJ5n9gbud7vkBEinTxsvWK8mE X-Microsoft-Exchange-Diagnostics: 1; DB6PR0701MB1734; 6:6PIejtUF/R9kb+NHHS35aWpsAE1N091s34LF2+eCSgq8rmpEaY+Q+DlFvgxZWWkhHQBOReW4G+0PY9J1X4iNzmJSyv0HPjqTl8UAOCVfQF2pfzKasQiQuIskygNv2nbkJyl8fKcrfiMwSMHzlau6nc0xP8kW26el2mJMcP4bVE2PRVRwuA5KqRI0IBkfeH7hmXG9qeYp1antzn9JK3wqc1eNsgtGzBjKiCzf/E5GDbTOAdV/kqlq6EgQrrucAxhzkc/7tquQIzgEt6sPKdCzkoS/uPT/+Axtxm+3HhL3j7TQ968ETtTLzhY+zHulqMLUtUnwwNqLxcSyU8/fB0EONK3Oprd7P/mnyd0gOG2tZJ8x38HFjYgFlejbTHmdh/+adS/nbv1ECUcuJsyi8Kq43w+ncYlqhdi4aXc8o7WG3yc=; 5:yy6Y5KYioiLn2wr+5IX9ynQgXzK7kjJBeTjs/h+arFhQ1/BjP6X2NKKNP03Pe6mPTu8AxI3Chu10Ui0M+0ubp/QbsIFToVJ21E5fV4VvouNhouuOYWf/xmZ0dEEFIRaS97iNKdRxsAVG6GtS9VsGUA==; 24:fd8OZYXb8S04TbzKrbWUgnghx/VRe1I4u4qE05zQb1B+XQ7VKqadXz4ZxjVKGmM3qYc5Eln51jT98jOeOSqfa6TTCaRyT72iMm6DGywj3Fo= 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); +}