From patchwork Thu Nov 24 08:24:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 83810 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp10434obn; Wed, 23 Nov 2016 23:35:20 -0800 (PST) X-Received: by 10.55.162.83 with SMTP id l80mr662758qke.168.1479972920722; Wed, 23 Nov 2016 23:35:20 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l125si21726107qkf.269.2016.11.23.23.35.20; Wed, 23 Nov 2016 23:35:20 -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 dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 3726062DE7; Thu, 24 Nov 2016 07:35:20 +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 C99B862EAD; Thu, 24 Nov 2016 07:26:38 +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 2DB1262EAC; Thu, 24 Nov 2016 07:26:35 +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 7B5E662DD4 for ; Thu, 24 Nov 2016 07:25:07 +0000 (UTC) Received: by mail-lf0-f49.google.com with SMTP id o141so21564813lff.1 for ; Wed, 23 Nov 2016 23:25:07 -0800 (PST) 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=N9WGcQcCl0/LQLvHZ7rUdKaMBxkqHRu077Yus5Et91w=; b=Gwo31s/vN+zeZNtHpdVSJ4Zp9H4GbMWQHvCS/q9qtzGbkaRNlMI5mbqOUozmWQSfRs dtQMKEPboWv9f8nfa8J8wf1+eUhbcO3Ad59adh2VBIQAYhSEv0l/ikZR5BjfQZFmLBij dskJJMmGb8SxkgLtiORIXaRU3j7N7FEHeN2RY8lhfxwOmZ6ux7XrUREdwrZLWxGrsAB9 +b23khNx1Cuivl2SEEM2eFawTJL2qzhFhXtBFK0GzqSCrdRZl2jncwKy80lU2pmuULlB mnUS3Il7isVsb9npow1gkcWLCnJF9zI1LqZ/j5gNqzVtNVyKctjybLZAPRSaqwyv42C1 fyKw== X-Gm-Message-State: AKaTC002vIt8ik6B2L5vcp4DXglTPq7g5s/0zZegUnDEpsRlURugNQZyserX1ysYT4omlhpB2Bo= X-Received: by 10.46.5.140 with SMTP id 134mr472186ljf.66.1479972306261; Wed, 23 Nov 2016 23:25:06 -0800 (PST) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-76-66.cust.bredband2.com. [83.233.76.66]) by smtp.gmail.com with ESMTPSA id 37sm7794110lfw.31.2016.11.23.23.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Nov 2016 23:25:05 -0800 (PST) From: Christophe Milard To: maxim.uvarov@linaro.com, mike.holmes@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Thu, 24 Nov 2016 09:24:28 +0100 Message-Id: <1479975872-4945-12-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479975872-4945-1-git-send-email-christophe.milard@linaro.org> References: <1479975872-4945-1-git-send-email-christophe.milard@linaro.org> Subject: [lng-odp] [API-NEXT PATCHv8 11/15] 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 | 31 +++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/platform/linux-generic/odp_shared_memory.c b/platform/linux-generic/odp_shared_memory.c index 2377f16..d2bb74c 100644 --- a/platform/linux-generic/odp_shared_memory.c +++ b/platform/linux-generic/odp_shared_memory.c @@ -24,6 +24,21 @@ 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_EXPORT : 0; + f |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0; + + return f; +} + int odp_shm_capability(odp_shm_capability_t *capa) { memset(capa, 0, sizeof(odp_shm_capability_t)); @@ -41,9 +56,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_EXPORT : 0; - flgs |= (flags & ODP_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0; + flgs = get_ishm_flags(flags); /* all mem reserved through this interface is requested to be locked: */ flgs |= (flags & _ODP_ISHM_LOCK); @@ -55,6 +68,18 @@ odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, return ODP_SHM_INVALID; } +odp_shm_t odp_shm_import(const char *remote_name, + odp_instance_t odp_inst, + const char *local_name) +{ + int ret; + + ret = _odp_ishm_find_exported(remote_name, (pid_t)odp_inst, + local_name); + + return to_handle(ret); +} + int odp_shm_free(odp_shm_t shm) { return _odp_ishm_free_by_index(from_handle(shm));