From patchwork Thu Nov 17 15:46:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 82758 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp1012623obn; Thu, 17 Nov 2016 09:21:01 -0800 (PST) X-Received: by 10.55.167.88 with SMTP id q85mr4451032qke.61.1479403261431; Thu, 17 Nov 2016 09:21:01 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m184si2605318qkb.181.2016.11.17.09.21.01; Thu, 17 Nov 2016 09:21:01 -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 0BA5F62ECB; Thu, 17 Nov 2016 17:20:09 +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=BAYES_00, RCVD_IN_DNSWL_NONE, 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 040C0634D5; Thu, 17 Nov 2016 16:24:22 +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 B855D60B14; Thu, 17 Nov 2016 14:47:18 +0000 (UTC) Received: from mail-qk0-f182.google.com (mail-qk0-f182.google.com [209.85.220.182]) by lists.linaro.org (Postfix) with ESMTPS id BBDD060AC5 for ; Thu, 17 Nov 2016 14:47:15 +0000 (UTC) Received: by mail-qk0-f182.google.com with SMTP id x190so222274803qkb.0 for ; Thu, 17 Nov 2016 06:47:15 -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=9C6kx9XxrqS4pMhOpCf7K0rfpsyHlNDy82aVP04QC8A=; b=SYvo4TkVuzMgSe+ak4Pepv4QaVR9uHRkXsvUTCNMsKaW5Mf53PXtW04HDCC+9eHfB1 nhBSmhA9g/dVtvlWXukTZ58IU5bepwL6in34l0jE1c++illqDwOt/zOnOG/r+Tjo7qbn hzBHGOrh5hIicmqJLk33MluwfeXO5sMR7D+Ybi6bI9drld65oaJW9qlLTbr1uw8tnnL1 dQSawQsDAFdk0Xc6wqF5hl4Xj1wxMJNMjVaO1zPOGT+HKIiC1DRO7FxZMfOhRkK+CDp0 qAjecFDk6Yo89HQ2KkrH2ud/V/FJNTp05tAcmoPjNqzZbLgRVlAD85R7DYBPB2Nn+M5f X62A== X-Gm-Message-State: AKaTC03uIZLGwibOPFA1ACGQvxhzKxbnqYmppayFYyNoa19mQsXMh+qKnju4vqjs7Ljp+WcKqgo= X-Received: by 10.46.32.26 with SMTP id g26mr1539787ljg.22.1479394035255; Thu, 17 Nov 2016 06:47:15 -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 h30sm860451lji.28.2016.11.17.06.47.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Nov 2016 06:47:14 -0800 (PST) From: Christophe Milard To: petri.savolainen@nokia.com, mike.holmes@linaro.org, bill.fischofer@linaro.org, lng-odp@lists.linaro.org Date: Thu, 17 Nov 2016 16:46:27 +0100 Message-Id: <1479397595-50258-6-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479397595-50258-1-git-send-email-christophe.milard@linaro.org> References: <1479397595-50258-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv7 05/13] api: shm: add flags to shm_reserve and function to find external mem 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" The ODP_SHM_SINGLE_VA flag is created: when set (at odp_shm_reserve()), this flag guarantees that all ODP threads sharing this memory block will see the block at the same address (regadless of ODP thread type -pthread vs process- or fork time) The flag ODP_SHM_EXPORT is added: when passed at odp_shm_reserve() time the memory block becomes visible to other ODP instances. The function odp_shm_import() is added: this function enables to reserve block of memories exported by other ODP instances (using the ODP_SHM_EXPORT flag). Signed-off-by: Christophe Milard --- include/odp/api/spec/shared_memory.h | 46 ++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) -- 2.7.4 Reviewed-by: Petri Savolainen diff --git a/include/odp/api/spec/shared_memory.h b/include/odp/api/spec/shared_memory.h index 8c76807..885751d 100644 --- a/include/odp/api/spec/shared_memory.h +++ b/include/odp/api/spec/shared_memory.h @@ -14,6 +14,7 @@ #ifndef ODP_API_SHARED_MEMORY_H_ #define ODP_API_SHARED_MEMORY_H_ #include +#include #ifdef __cplusplus extern "C" { @@ -43,12 +44,25 @@ extern "C" { #define ODP_SHM_NAME_LEN 32 /* - * Shared memory flags + * Shared memory flags: */ - -/* Share level */ -#define ODP_SHM_SW_ONLY 0x1 /**< Application SW only, no HW access */ -#define ODP_SHM_PROC 0x2 /**< Share with external processes */ +#define ODP_SHM_SW_ONLY 0x1 /**< Application SW only, no HW access */ +#define ODP_SHM_PROC 0x2 /**< Share with external processes */ +/** + * Single virtual address + * + * When set, this flag guarantees that all ODP threads sharing this + * memory block will see the block at the same address - regardless + * of ODP thread type (e.g. pthread vs. process (or fork process time)). + */ +#define ODP_SHM_SINGLE_VA 0x4 +/** + * Export memory + * + * When set, the memory block becomes visible to other ODP instances + * through odp_shm_import(). + */ +#define ODP_SHM_EXPORT 0x08 /** * Shared memory block info @@ -135,6 +149,28 @@ int odp_shm_free(odp_shm_t shm); */ odp_shm_t odp_shm_lookup(const char *name); +/** + * Import a block of shared memory, exported by another ODP instance + * + * This call creates a new handle for accessing a shared memory block created + * (with ODP_SHM_EXPORT flag) by another ODP instance. An instance may have + * only a single handle to the same block. Application must not access the + * block after freeing the handle. When an imported handle is freed, only + * the calling instance is affected. The exported block may be freed only + * after all other instances have stopped accessing the block. + * + * @param remote_name Name of the block, in the remote ODP instance + * @param odp_inst Remote ODP instance, as returned by odp_init_global() + * @param local_name Name given to the block, in the local ODP instance + * May be NULL, if the application doesn't need a name + * (for a lookup). + * + * @return A handle to access a block exported by another ODP instance. + * @retval ODP_SHM_INVALID on failure + */ +odp_shm_t odp_shm_import(const char *remote_name, + odp_instance_t odp_inst, + const char *local_name); /** * Shared memory block address