From patchwork Fri May 22 13:06:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 48888 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 17D572121F for ; Fri, 22 May 2015 13:06:46 +0000 (UTC) Received: by labcd2 with SMTP id cd2sf5097189lab.0 for ; Fri, 22 May 2015 06:06:45 -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: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=pIcnlhgqD7mk4Ne8GxYkPn3xSBf9w94TIdeodBA5ECk=; b=lbS69j7ZUl2zcCyEZuByIG9MQBusXi1WjCgoTM30cKksIt8Nq/mF/0KnE+FSj/Mpyc EKD+uATrQuaJwuq4234qhe2hqy0dC0rPhz4QyP3nVOFOEzzuV/v5G6alxFb2TJjotynY nedoOwdJ5tOvvPXbV5pzkguILH3e4J62qt9bh8PAeumBUb7hFw9vl0N0NYl9o0CZCc33 950689zD0fjdPj/1pDZn91eNZjqt0catq7TsdUMqi6mIYR7B+VfqSW0TLVg4B1A3Dp9q x6qF4b0xqV36nJL6E0pRztfDQ4Y5nfRYamZyKsvGwaRxj5KLQDHYgoN6IQreVTe4fsKz /rkQ== X-Gm-Message-State: ALoCoQmmcTLge4TiM6XOUJyhmY+Ik2xQmkiOz3HVZKWUlXqjY/go5wmRGmKLSOHILJyK+qlDQhxi X-Received: by 10.152.87.140 with SMTP id ay12mr7760554lab.8.1432300004954; Fri, 22 May 2015 06:06:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.163 with SMTP id an3ls510871lac.90.gmail; Fri, 22 May 2015 06:06:44 -0700 (PDT) X-Received: by 10.112.202.103 with SMTP id kh7mr6147893lbc.118.1432300004651; Fri, 22 May 2015 06:06:44 -0700 (PDT) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id dh4si1377324lac.35.2015.05.22.06.06.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 May 2015 06:06:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by laat2 with SMTP id t2so12181885laa.1 for ; Fri, 22 May 2015 06:06:44 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr4349155lbh.56.1432300004359; Fri, 22 May 2015 06:06:44 -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.108.230 with SMTP id hn6csp1385944lbb; Fri, 22 May 2015 06:06:43 -0700 (PDT) X-Received: by 10.140.192.83 with SMTP id n80mr11383714qha.1.1432300002593; Fri, 22 May 2015 06:06:42 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v94si2270069qge.82.2015.05.22.06.06.39; Fri, 22 May 2015 06:06:42 -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 6152B61F4A; Fri, 22 May 2015 13:06:39 +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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled 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 2403561F3F; Fri, 22 May 2015 13:06:30 +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 D4B9261F41; Fri, 22 May 2015 13:06:26 +0000 (UTC) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) by lists.linaro.org (Postfix) with ESMTPS id E58FC61F3F for ; Fri, 22 May 2015 13:06:24 +0000 (UTC) Received: by laat2 with SMTP id t2so12174535laa.1 for ; Fri, 22 May 2015 06:06:23 -0700 (PDT) X-Received: by 10.112.72.132 with SMTP id d4mr6322795lbv.1.1432299983157; Fri, 22 May 2015 06:06:23 -0700 (PDT) Received: from localhost.localdomain (78-82-119-245.tn.glocalnet.net. [78.82.119.245]) by mx.google.com with ESMTPSA id f2sm472559lah.39.2015.05.22.06.06.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 May 2015 06:06:22 -0700 (PDT) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Fri, 22 May 2015 15:06:00 +0200 Message-Id: <1432299960-25889-1-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [RFCv2] Add message bus (MBUS) API's 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: ola.liljedahl@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.53 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 Here is my second attempt at a standalone API for MBUS - message passing based IPC for a shared nothing architecture. The semantics of message passing is that sending a message to an endpoint will always look like it succeeds. The appearance of endpoints is explicitly notified through user-defined messages specified in the odp_mbus_lookup() call. Similarly, the disappearance (e.g. death or otherwise lost connection) is also explicitly notified through user-defined messages specified in the odp_mbus_monitor() call. The send call does not fail because the addressed endpoints has disappeared. Message delivery into the recipient address space is ordered (per priority) and reliable. Delivery of message N implies delivery of all messages --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) include/odp/api/mbus.h | 229 +++++++++++++++++++++ include/odp/api/message.h | 141 +++++++++++++ platform/linux-generic/include/odp/mbus.h | 40 ++++ platform/linux-generic/include/odp/message.h | 39 ++++ .../linux-generic/include/odp/plat/mbus_types.h | 59 ++++++ .../linux-generic/include/odp/plat/message_types.h | 47 +++++ 6 files changed, 555 insertions(+) create mode 100644 include/odp/api/mbus.h create mode 100644 include/odp/api/message.h create mode 100644 platform/linux-generic/include/odp/mbus.h create mode 100644 platform/linux-generic/include/odp/message.h create mode 100644 platform/linux-generic/include/odp/plat/mbus_types.h create mode 100644 platform/linux-generic/include/odp/plat/message_types.h diff --git a/include/odp/api/mbus.h b/include/odp/api/mbus.h new file mode 100644 index 0000000..60fdc62 --- /dev/null +++ b/include/odp/api/mbus.h @@ -0,0 +1,229 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP Message bus API + */ + +#ifndef ODP_API_MBUS_H_ +#define ODP_API_MBUS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @defgroup odp_mbus ODP MBUS + * @{ + */ + +/** + * @typedef odp_mbus_t + * ODP message bus handle + */ + +/** + * @def ODP_MBUS_ADDR_SIZE + * Size of the address of a message bus endpoint + */ + +/** + * @typedef odp_mbus_prio_t + * ODP MBUS message priority + */ + +/** + * @def ODP_MBUS_PRIO_HIGHEST + * Highest MBUS message priority + */ + +/** + * @def ODP_MBUS_PRIO_NORMAL + * Normal MBUS message priority + */ + +/** + * @def ODP_MBUS_PRIO_LOWEST + * Lowest MBUS message priority + */ + +/** + * @def ODP_MBUS_PRIO_DEFAULT + * Default MBUS message priority + */ + + +/** + * Create message bus endpoint + * + * Create an endpoint on the message bus. The scope of the message bus is + * not defined but it is expected that it encompasses the OS instance but + * no more. + * + * A unique address for the endpoint is created. + * + * @param name Name of our endpoint + * @param pool Pool (of type ODP_EVENT_MESSAGE) for incoming messages + * @param queue Handle for default input queue + * + * @return Message bus handle on success + * @retval ODP_MBUS_INVALID on failure and errno set + */ +odp_mbus_t odp_mbus_create(const char *name, + odp_pool_t pool, + odp_queue_t queue); + +/** + * Destroy message bus endpoint + * + * @param mbus Message bus handle + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_mbus_destroy(odp_mbus_t mbus); + +/** + * Set the default input queue for a message bus endpoint + * + * @param mbus Message bus handle + * @param queue Queue handle + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_mbus_inq_setdef(odp_mbus_t mbus, odp_queue_t queue); + +/** + * Set the input queue for a specific message priority + * + * @param mbus Message bus handle + * @param prio Message priority + * @param queue Queue handle + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_mbus_inq_set(odp_mbus_t mbus, odp_mbus_prio_t prio, odp_queue_t queue); + +/** + * Remove the default input queue + * + * Remove (disassociate) the default input queue from a message bus endpoint. + * The queue itself is not touched. + * + * @param mbus Message bus handle + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_mbus_inq_remdef(odp_mbus_t mbus); + +/** + * Remove the input queue for a specific message priority + * + * Remove (disassociate) the matching input queue from a message bus endpoint. + * The queue itself is not touched. + * + * @param mbus Message bus handle + * @param prio Message priority + * + * @retval 0 on success + * @retval <0 on failure + */ +int odp_mbus_inq_rem(odp_mbus_t mbus, odp_mbus_prio_t prio); + +/** + * Lookup endpoint by name + * + * Look up a current or future endpoint by name. + * When the endpoint exists, return the specified message with the endpoint + * as the sender. + * + * @param mbus Message bus handle + * @param name Name to look up + * @param msg Message to return + */ +void odp_mbus_lookup(odp_mbus_t mbus, + const char *name, + odp_message_t msg); + +/** + * Monitor endpoint + * + * Monitor an endpoint (which may already have disappeared). + * When the endpoint disappears, return the specified message with the endpoint + * as the sender. + * + * Unrecognized or invalid endpoint addresses are treated as non-existing + * endpoints. + * + * @param mbus Message bus handle + * @param addr Address of monitored endpoint + * @param msg Message to return + */ +void odp_mbus_monitor(odp_mbus_t mbus, + const uint8_t addr[ODP_MBUS_ADDR_SIZE], + odp_message_t msg); + +/** + * Send message + * + * Send a message to an endpoint (which may no longer exist). + * + * Message delivery into the recipient address space is ordered (per priority) + * and reliable. Delivery of message N implies delivery of all messages +#include +#include +#include +#include + +/** @ingroup odp_mbus + * @{ + */ + +/** + * @} + */ + +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/message.h b/platform/linux-generic/include/odp/message.h new file mode 100644 index 0000000..2a29f59 --- /dev/null +++ b/platform/linux-generic/include/odp/message.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2013, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Message Bus + */ + +#ifndef ODP_PLAT_MESSAGE_H_ +#define ODP_PLAT_MESSAGE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +/** @ingroup odp_message + * @{ + */ + +/** + * @} + */ + +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/plat/mbus_types.h b/platform/linux-generic/include/odp/plat/mbus_types.h new file mode 100644 index 0000000..a94a092 --- /dev/null +++ b/platform/linux-generic/include/odp/plat/mbus_types.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP Message bus types + */ + +#ifndef ODP_MBUS_TYPES_H_ +#define ODP_MBUS_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** @addtogroup odp_mbus ODP message bus + * Operations on a message bus. + * @{ + */ + +typedef int odp_mbus_prio_t; + +#define ODP_MBUS_PRIO_HIGHEST 0 + +#define ODP_MBUS_PRIO_NORMAL 1 + +#define ODP_MBUS_PRIO_LOWEST 3 + +#define ODP_MBUS_PRIO_DEFAULT ODP_MBUS_PRIO_NORMAL + +typedef ODP_HANDLE_T(odp_mbus_t); + +#define ODP_MBUS_INVALID _odp_cast_scalar(odp_mbus_t, 0xffffffff) + +#define ODP_MBUS_ADDR_SIZE 6 + +/** Get printable format of odp_mbus_t */ +static inline uint64_t odp_mbus_to_u64(odp_mbus_t hdl) +{ + return _odp_pri(hdl); +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/plat/message_types.h b/platform/linux-generic/include/odp/plat/message_types.h new file mode 100644 index 0000000..3a42064 --- /dev/null +++ b/platform/linux-generic/include/odp/plat/message_types.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP Message message type + */ + +#ifndef ODP_MESSAGE_TYPES_H_ +#define ODP_MESSAGE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** @addtogroup odp_message ODP message + * Operations on a message. + * @{ + */ + +typedef ODP_HANDLE_T(odp_message_t); + +#define ODP_MESSAGE_INVALID _odp_cast_scalar(odp_message_t, 0xffffffff) + +/** Get printable format of odp_message_t */ +static inline uint64_t odp_message_to_u64(odp_message_t hdl) +{ + return _odp_pri(hdl); +} + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif