From patchwork Wed Oct 19 15:29:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 78287 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp312438qge; Wed, 19 Oct 2016 08:39:03 -0700 (PDT) X-Received: by 10.200.54.79 with SMTP id n15mr6463637qtb.50.1476891543403; Wed, 19 Oct 2016 08:39:03 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k71si24678026qke.306.2016.10.19.08.39.03; Wed, 19 Oct 2016 08:39:03 -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; 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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 07FCB61705; Wed, 19 Oct 2016 15:39: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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL 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 5AA0F6173D; Wed, 19 Oct 2016 15:31:20 +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 5BD0161736; Wed, 19 Oct 2016 15:30:55 +0000 (UTC) Received: from mail-lf0-f49.google.com (mail-lf0-f49.google.com [209.85.215.49]) by lists.linaro.org (Postfix) with ESMTPS id 019FD61710 for ; Wed, 19 Oct 2016 15:30:11 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id b81so29761053lfe.1 for ; Wed, 19 Oct 2016 08:30:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cOX8fqbUiAbvzabdh6tOw1N/qATOepFzI9C1aFg5MBY=; b=P24vO282Vdc2x0wXuYd9RvbMjbheLwfOG4O5wB4dEoTIb8pzH7iqOUleYDfOLgr1Kz oS2IDA3tUaBGYUPBWFajebUxjQlATKo7RWZXpiAR91vN+dtnjI5udYyjh9ke8KuH+d3Z +AQpeyLAtaaeVeHnXiN4kEw+iVjyH/1IM5Ha1i8jDHQ2QbxDFPOr33qKnVVOMoeCJDnU vTvEY0fL2BKzHzttiPCHG22+5MsY0E9INY3K7JCNG1XLwzUgj79aedQy+zQMiQ8BRDH5 cpprzI8NUqCn8gxEEyNuEsQLCqY1NEpvQ0Vps8U/3zXDr3kPzHRD44ykOrMR7G6/nSO9 4CKQ== X-Gm-Message-State: AA6/9RmlNWPNE1A4MyvPq9C1UGGhuJBUACFv1joaNeIsmjUChM3zk6gJJ8Z76Nudke7XJi56+j0= X-Received: by 10.25.138.215 with SMTP id m206mr6108768lfd.30.1476891009669; Wed, 19 Oct 2016 08:30:09 -0700 (PDT) Received: from localhost.localdomain (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id w65sm10805536lff.16.2016.10.19.08.30.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Oct 2016 08:30:09 -0700 (PDT) From: Christophe Milard To: mike.holmes@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Wed, 19 Oct 2016 17:29:47 +0200 Message-Id: <1476890991-4693-13-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476890991-4693-1-git-send-email-christophe.milard@linaro.org> References: <1476890991-4693-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv3 12/16] linux-gen: shm: add flag and function to share memory between ODP instances 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" Implemented by calling the related functions from _ishm. Signed-off-by: Christophe Milard --- platform/linux-generic/odp_shared_memory.c | 37 ++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 30ef9d9..1603cdb 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -24,6 +24,22 @@ static inline odp_shm_t to_handle(uint32_t index) return _odp_cast_scalar(odp_shm_t, index + 1); } +static uint32_t get_ishm_flags(uint32_t flags) +{ + uint32_t f = 0; /* internal ishm flags */ + + /* set internal ishm flags according to API flags: + * note that both ODP_SHM_PROC and ODP_SHM_EXPORT maps to + * _ODP_ISHM_LINK as in the linux-gen implementation there is + * no difference between exporting to another ODP instance or + * another linux process */ + f |= (flags & (ODP_SHM_PROC | ODP_SHM_EXPORT)) ? _ODP_ISHM_LINK : 0; + f |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0; + f |= (flags & ODP_SHM_LOCK) ? _ODP_ISHM_LOCK : 0; + + return f; +} + int odp_shm_capability(odp_shm_capability_t *capa) { memset(capa, 0, sizeof(odp_shm_capability_t)); @@ -41,10 +57,7 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, int block_index; int flgs = 0; /* internal ishm flags */ - /* set internal ishm flags according to API flags: */ - flgs |= (flags & ODP_SHM_PROC) ? _ODP_ISHM_LINK : 0; - flgs |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0; - flgs |= (flags & ODP_SHM_LOCK) ? _ODP_ISHM_LOCK : 0; + flgs = get_ishm_flags(flags); block_index = _odp_ishm_reserve(name, size, -1, align, flgs, flags); if (block_index >= 0) @@ -53,6 +66,22 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, return ODP_SHM_INVALID; } +odp_shm_t odp_shm_reserve_exported(const char *remote_name, + odp_instance_t odp_inst, + const char *local_name, + uint64_t align, uint32_t flags) +{ + int ret; + int i_flgs; /* internal ishm flags */ + + i_flgs = get_ishm_flags(flags); + + ret = _odp_ishm_reserve_exported(remote_name, (pid_t)odp_inst, + local_name, align, i_flgs, flags); + + return to_handle(ret); +} + int odp_shm_free(odp_shm_t shm) { return _odp_ishm_free_by_index(from_handle(shm));