From patchwork Fri Apr 10 15:52:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 47062 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A212D21416 for ; Fri, 10 Apr 2015 15:56:24 +0000 (UTC) Received: by lbdc7 with SMTP id c7sf3366842lbd.2 for ; Fri, 10 Apr 2015 08:56:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :mime-version:content-type:content-transfer-encoding:errors-to :sender:x-original-sender:x-original-authentication-results :mailing-list; bh=rcCc8FucsZvXDv3c9NheO8m4ocns3xzwsAQ10goFEw0=; b=VzO00fkO+X4Yz3TxWwy8pBgwpwrJ1xR/I1SxFPL47qZozzcC/7ijAwzs/FxJWgpNXz JMxHWLowEk/JC82Ok8+MLQutM7D/+NrMU1mBAq7VjL8K4eBQ0zkHPU/zG8a1Ob9cfbYX bo5QAwfoY9VJnMjfXeGrLsnJLqiZVa62VUUmlXs4qOwxW5ArX8zdYVVpV3qmp+rWZ5H2 HP9QJIv5ae3Fmko1YdmN+kkAU4Er7VumEr7biiO5sOfs2SUYSD5TB3VGd71nDAH9hRpM SE6LvEAsiP9JOelWQu9w2xTgHp8ZD6E30uh2aM0J8NABMKb7XlL4U1tIom2UvzQ2VDVS nMDA== X-Gm-Message-State: ALoCoQlDGqtt7J4cgYg5CQjY3yFuwCQnUJEMm8cdF+xn8slcWcELu9WaYEf2KgUSudZyFyE8JzmL X-Received: by 10.180.211.168 with SMTP id nd8mr625919wic.4.1428681383589; Fri, 10 Apr 2015 08:56:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.69 with SMTP id kw5ls431827lac.86.gmail; Fri, 10 Apr 2015 08:56:23 -0700 (PDT) X-Received: by 10.152.19.199 with SMTP id h7mr2101563lae.32.1428681383427; Fri, 10 Apr 2015 08:56:23 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id ut15si1784520lbb.101.2015.04.10.08.56.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Apr 2015 08:56:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labbd9 with SMTP id bd9so16391720lab.2 for ; Fri, 10 Apr 2015 08:56:23 -0700 (PDT) X-Received: by 10.112.140.231 with SMTP id rj7mr1996812lbb.76.1428681383327; Fri, 10 Apr 2015 08:56:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp1190558lbt; Fri, 10 Apr 2015 08:56:22 -0700 (PDT) X-Received: by 10.140.93.72 with SMTP id c66mr2554874qge.0.1428681382181; Fri, 10 Apr 2015 08:56:22 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n90si2199290qkh.13.2015.04.10.08.56.21; Fri, 10 Apr 2015 08:56:22 -0700 (PDT) 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; Received: by lists.linaro.org (Postfix, from userid 109) id 868EB650F8; Fri, 10 Apr 2015 15:56:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id CF78665023; Fri, 10 Apr 2015 15:53: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 18C11650FB; Fri, 10 Apr 2015 15:53:33 +0000 (UTC) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by lists.linaro.org (Postfix) with ESMTPS id 067A0650FE for ; Fri, 10 Apr 2015 15:52:33 +0000 (UTC) Received: by oblw8 with SMTP id w8so21563075obl.0 for ; Fri, 10 Apr 2015 08:52:32 -0700 (PDT) X-Received: by 10.182.60.197 with SMTP id j5mr2678606obr.85.1428681152581; Fri, 10 Apr 2015 08:52:32 -0700 (PDT) Received: from localhost.localdomain (cpe-24-28-70-239.austin.res.rr.com. [24.28.70.239]) by mx.google.com with ESMTPSA id ke9sm1895845obb.9.2015.04.10.08.52.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Apr 2015 08:52:32 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Fri, 10 Apr 2015 10:52:17 -0500 Message-Id: <1428681138-24954-6-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1428681138-24954-1-git-send-email-bill.fischofer@linaro.org> References: <1428681138-24954-1-git-send-email-bill.fischofer@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv4 5/6] linux-generic: packet: add user metadata support X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bill.fischofer@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_packet.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index c5a3f7d..2abb465 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -239,6 +239,16 @@ void odp_packet_user_u64_set(odp_packet_t pkt, uint64_t ctx) odp_packet_hdr(pkt)->buf_hdr.buf_u64 = ctx; } +void *odp_packet_user_data(odp_packet_t pkt) +{ + return odp_packet_hdr(pkt)->buf_hdr.udata_addr; +} + +uint32_t odp_packet_user_data_size(odp_packet_t pkt) +{ + return odp_packet_hdr(pkt)->buf_hdr.udata_size; +} + void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); @@ -409,6 +419,14 @@ odp_packet_t odp_packet_add_data(odp_packet_t pkt, uint32_t offset, odp_packet_hdr_t *new_hdr = odp_packet_hdr(newpkt); new_hdr->input = pkt_hdr->input; new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64; + if (new_hdr->buf_hdr.udata_addr != NULL && + pkt_hdr->buf_hdr.udata_addr != NULL) + memcpy(new_hdr->buf_hdr.udata_addr, + pkt_hdr->buf_hdr.udata_addr, + new_hdr->buf_hdr.udata_size <= + pkt_hdr->buf_hdr.udata_size ? + new_hdr->buf_hdr.udata_size : + pkt_hdr->buf_hdr.udata_size); odp_atomic_store_u32( &new_hdr->buf_hdr.ref_count, odp_atomic_load_u32( @@ -445,6 +463,14 @@ odp_packet_t odp_packet_rem_data(odp_packet_t pkt, uint32_t offset, odp_packet_hdr_t *new_hdr = odp_packet_hdr(newpkt); new_hdr->input = pkt_hdr->input; new_hdr->buf_hdr.buf_u64 = pkt_hdr->buf_hdr.buf_u64; + if (new_hdr->buf_hdr.udata_addr != NULL && + pkt_hdr->buf_hdr.udata_addr != NULL) + memcpy(new_hdr->buf_hdr.udata_addr, + pkt_hdr->buf_hdr.udata_addr, + new_hdr->buf_hdr.udata_size <= + pkt_hdr->buf_hdr.udata_size ? + new_hdr->buf_hdr.udata_size : + pkt_hdr->buf_hdr.udata_size); odp_atomic_store_u32( &new_hdr->buf_hdr.ref_count, odp_atomic_load_u32( @@ -600,6 +626,14 @@ void _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt) dsthdr->input = srchdr->input; dsthdr->buf_hdr.buf_u64 = srchdr->buf_hdr.buf_u64; + if (dsthdr->buf_hdr.udata_addr != NULL && + srchdr->buf_hdr.udata_addr != NULL) + memcpy(dsthdr->buf_hdr.udata_addr, + srchdr->buf_hdr.udata_addr, + dsthdr->buf_hdr.udata_size <= + srchdr->buf_hdr.udata_size ? + dsthdr->buf_hdr.udata_size : + srchdr->buf_hdr.udata_size); odp_atomic_store_u32( &dsthdr->buf_hdr.ref_count, odp_atomic_load_u32(