From patchwork Tue Dec 16 12:30:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taras Kondratiuk X-Patchwork-Id: 42328 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CDED72456A for ; Tue, 16 Dec 2014 12:31:51 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf8617273lam.6 for ; Tue, 16 Dec 2014 04:31:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state: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=LkzrvmqGSIRTxo+1Gr0jf5Y+qN4yu4J5D6IDEV50ZQg=; b=EWykYlYGYkD2qBbyyyJ3zaxUgfBBG5sKTCv8BB1+P+H3fwT4K/5cBD8yRnwr8Mc48R 0Fo4/VChqSeiM6rt4qu5ux+oCNqedxGM/PSKGymfQaOs1N3Ayy5bivN201JnnNdeRz0O fcCrseLCPXA+rXcAMDFDh1YDmM8NV9PUHjWwqnYvCEDUNoTdvTQMXUPwpWaoqy6LJ4I7 +Xql6ZN8KoBrg5jEE1pSxhlX20+WaSYoGKYXpzhKmEzfYBv3zTIi0jFGPSHBnt12BL2b 99x3yMdc2/RRhQhBzpdjgeNhbiw01dQCUJ3zwcd+I+ksHff1yiVh0sd1mRibBU62LZ6i tvzw== X-Gm-Message-State: ALoCoQkEBo+jMq4AUHSyXlpui/G9ZpVZdhjc1MVjw9fRY5HY+gmph6Mf5l9NJ0yVkNz4foXrV9kl X-Received: by 10.180.24.35 with SMTP id r3mr425101wif.0.1418733110758; Tue, 16 Dec 2014 04:31:50 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.44.135 with SMTP id e7ls621915lam.76.gmail; Tue, 16 Dec 2014 04:31:50 -0800 (PST) X-Received: by 10.152.19.7 with SMTP id a7mr23307442lae.16.1418733110450; Tue, 16 Dec 2014 04:31:50 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id ti8si620998lbb.95.2014.12.16.04.31.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Dec 2014 04:31:50 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id z11so10658203lbi.24 for ; Tue, 16 Dec 2014 04:31:50 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr35578364lal.29.1418733110303; Tue, 16 Dec 2014 04:31:50 -0800 (PST) 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.142.69 with SMTP id ru5csp1020030lbb; Tue, 16 Dec 2014 04:31:49 -0800 (PST) X-Received: by 10.140.95.52 with SMTP id h49mr60338492qge.97.1418733108423; Tue, 16 Dec 2014 04:31:48 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id i88si620931qgf.90.2014.12.16.04.31.47 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Dec 2014 04:31:48 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y0rI1-0006c6-R5; Tue, 16 Dec 2014 12:31:45 +0000 Received: from mail-lb0-f180.google.com ([209.85.217.180]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y0rHN-0006UW-G9 for lng-odp@lists.linaro.org; Tue, 16 Dec 2014 12:31:05 +0000 Received: by mail-lb0-f180.google.com with SMTP id l4so10949231lbv.11 for ; Tue, 16 Dec 2014 04:31:00 -0800 (PST) X-Received: by 10.152.2.165 with SMTP id 5mr35484233lav.40.1418733059919; Tue, 16 Dec 2014 04:30:59 -0800 (PST) Received: from uglx0153363.synapse.com ([195.238.92.128]) by mx.google.com with ESMTPSA id eg2sm169516lbb.29.2014.12.16.04.30.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Dec 2014 04:30:58 -0800 (PST) From: Taras Kondratiuk To: lng-odp@lists.linaro.org Date: Tue, 16 Dec 2014 14:30:38 +0200 Message-Id: <1418733042-18047-6-git-send-email-taras.kondratiuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418733042-18047-1-git-send-email-taras.kondratiuk@linaro.org> References: <1418733042-18047-1-git-send-email-taras.kondratiuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv5 5/9] api: packet: user context X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: taras.kondratiuk@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.217.179 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 From: Bill Fischofer Signed-off-by: Bill Fischofer Signed-off-by: Taras Kondratiuk --- example/ipsec/odp_ipsec.c | 4 +- platform/linux-generic/include/api/odp_packet.h | 44 ++++++++++++++++++---- .../linux-generic/include/odp_buffer_internal.h | 1 + platform/linux-generic/odp_packet.c | 30 ++++++++++----- 4 files changed, 59 insertions(+), 20 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 518c132..ae04a4e 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -167,7 +167,7 @@ static odp_buffer_pool_t ctx_pool = ODP_BUFFER_POOL_INVALID; static pkt_ctx_t *get_pkt_ctx_from_pkt(odp_packet_t pkt) { - return (pkt_ctx_t *)odp_packet_get_ctx(pkt); + return (pkt_ctx_t *)odp_packet_user_ptr(pkt); } /** @@ -191,7 +191,7 @@ pkt_ctx_t *alloc_pkt_ctx(odp_packet_t pkt) ctx = odp_buffer_addr(ctx_buf); memset(ctx, 0, sizeof(*ctx)); ctx->buffer = ctx_buf; - odp_packet_set_ctx(pkt, ctx); + odp_packet_user_ptr_set(pkt, ctx); return ctx; } diff --git a/platform/linux-generic/include/api/odp_packet.h b/platform/linux-generic/include/api/odp_packet.h index 96e1474..cb5f177 100644 --- a/platform/linux-generic/include/api/odp_packet.h +++ b/platform/linux-generic/include/api/odp_packet.h @@ -131,22 +131,50 @@ void odp_packet_set_len(odp_packet_t pkt, size_t len); size_t odp_packet_get_len(odp_packet_t pkt); /** - * Set packet user context + * User context pointer * - * @param buf Packet handle - * @param ctx User context + * Return previously stored user context pointer. * + * @param pkt Packet handle + * + * @return User context pointer + */ +void *odp_packet_user_ptr(odp_packet_t pkt); + +/** + * Set user context pointer + * + * Each packet has room for a user defined context. The context can be stored + * either as a pointer OR as a uint64_t value, but not both at the same time. + * The latest context set operation determines which one has been stored. + * + * @param pkt Packet handle + * @param ctx User context pointer */ -void odp_packet_set_ctx(odp_packet_t buf, const void *ctx); +void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx); /** - * Get packet user context + * User context data (uint64_t) * - * @param buf Packet handle + * Return previously stored user context uint64_t value. * - * @return User context + * @param pkt Packet handle + * + * @return User context data + */ +uint64_t odp_packet_user_u64(odp_packet_t pkt); + +/** + * Set user context data (uint64_t) + * + * Each packet has room for a user defined context. The context can be stored + * either as a pointer OR as a uint64_t value, but not both at the same time. + * The latest context set operation determines which one has been stored. + * + * @param pkt Packet handle + * @param ctx User context data */ -void *odp_packet_get_ctx(odp_packet_t buf); +void odp_packet_user_u64_set(odp_packet_t pkt, uint64_t ctx); /** * Packet buffer start address diff --git a/platform/linux-generic/include/odp_buffer_internal.h b/platform/linux-generic/include/odp_buffer_internal.h index 859633e..933097b 100644 --- a/platform/linux-generic/include/odp_buffer_internal.h +++ b/platform/linux-generic/include/odp_buffer_internal.h @@ -124,6 +124,7 @@ typedef struct odp_buffer_hdr_t { union { uint64_t buf_u64; /* user u64 */ void *buf_ctx; /* user context */ + const void *buf_cctx; /* const alias for ctx */ void *udata_addr; /* user metadata addr */ }; size_t udata_size; /* size of user metadata */ diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 783714b..e5899fd 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -103,6 +103,26 @@ void *odp_packet_data(odp_packet_t pkt) return packet_map(pkt_hdr, 0, NULL); } +void *odp_packet_user_ptr(odp_packet_t pkt) +{ + return odp_packet_hdr(pkt)->buf_hdr.buf_ctx; +} + +void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx) +{ + odp_packet_hdr(pkt)->buf_hdr.buf_cctx = ctx; +} + +uint64_t odp_packet_user_u64(odp_packet_t pkt) +{ + return odp_packet_hdr(pkt)->buf_hdr.buf_u64; +} + +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_l2_ptr(odp_packet_t pkt, uint32_t *len) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); @@ -407,16 +427,6 @@ int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src) return 0; } -void odp_packet_set_ctx(odp_packet_t pkt, const void *ctx) -{ - odp_packet_hdr(pkt)->user_ctx = (intptr_t)ctx; -} - -void *odp_packet_get_ctx(odp_packet_t pkt) -{ - return (void *)(intptr_t)odp_packet_hdr(pkt)->user_ctx; -} - int odp_packet_is_valid(odp_packet_t pkt) { odp_buffer_t buf = odp_packet_to_buffer(pkt);