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/tjnGVmKfV7Ob90kB8Chz1mtvkViJgbps+ZqEzQ40r3n8lyt5t/cbJc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ykUFc1IfsQzEWBC+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+TRysj3bvjCH1rHQ0hjiPH51DEg4RDX5K01wD7FesmXzsNbrIhkXzog45cVdJWcqGot4aXcq9QNST4Kb6Id5ywaEV747qMIEzORFgQn0V3oAWE= X-For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i2WjkzkmxidA0xx6bt5ScFJ9+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); +}