From patchwork Mon Sep 19 15:56:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 76560 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1031549qgf; Mon, 19 Sep 2016 08:57:54 -0700 (PDT) X-Received: by 10.200.37.205 with SMTP id f13mr31051386qtf.79.1474300673875; Mon, 19 Sep 2016 08:57:53 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w40si19740941qtc.82.2016.09.19.08.57.43; Mon, 19 Sep 2016 08:57:53 -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 12EED60732; Mon, 19 Sep 2016 15:57:18 +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 4E3EA6050F; Mon, 19 Sep 2016 15:57:14 +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 9FE1B6065B; Mon, 19 Sep 2016 15:57:12 +0000 (UTC) Received: from mail-lf0-f43.google.com (mail-lf0-f43.google.com [209.85.215.43]) by lists.linaro.org (Postfix) with ESMTPS id 637906050A for ; Mon, 19 Sep 2016 15:57:11 +0000 (UTC) Received: by mail-lf0-f43.google.com with SMTP id h127so117334469lfh.0 for ; Mon, 19 Sep 2016 08:57: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; bh=SfTD3mpjnVtl05vOrOor7MWNbfSW9hJ27nbbCawmUV0=; b=IXKoplRRTfDjv0n95PKq2ZOpcMfhgOj/VnoeEbVElgWQoUJEJJUkZExIS7NOBvuC/P a7gp3S6Q3Pe8DGTJ+Tsq9gCLe3XZlN2t0UQ3H+HX/ByKgcxQ5tPMs+ou8wRRPc5WLU2W Wkmt7XawcHT+onRkyy1fl3jnVgvXfqRb6EQw40nRqbU/W25jksLKsblU89z4FFH6QJ0V fdkeoOayO6Qz0m5T1QqN4xkdp9JvXTJxpF4ZoycwV89wepOze4aFIHFD9pP+PPrPIoNN SFcvlS8kwxiphozhX3KppAHH76d0EG648U+9+OVVbrVw/LHVPjeFArkztkZx+uaCp+vN 0ydQ== X-Gm-Message-State: AE9vXwMT4b1dpFMrmrOzUPX4o9OVTBG4rvLuliUso5wJgCbV4iR6QuR0BTTXQDQ5GzsimF0XNcw= X-Received: by 10.25.152.83 with SMTP id a80mr11347527lfe.144.1474300629964; Mon, 19 Sep 2016 08:57: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 s187sm4940467lfd.3.2016.09.19.08.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Sep 2016 08:57:09 -0700 (PDT) From: Christophe Milard To: lng-odp@lists.linaro.org, mike.holmes@linaro.org, bill.fischofer@linaro.org Date: Mon, 19 Sep 2016 17:56:57 +0200 Message-Id: <1474300617-19849-1-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [PATCH] linux-gen: using ODP instantiation pid as odp instance 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" Rather than using INSTANCE_ID (constant 0xdeadbeef), the ODP main instantiation process ID is used as instance ID in the linux-generic implementation. This is a simple way to guarantee instance uniqueness on linux systems. Signed-off-by: Christophe Milard --- platform/linux-generic/include/odp_internal.h | 1 - platform/linux-generic/odp_init.c | 7 +++---- platform/linux-generic/odp_traffic_mngr.c | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) -- 2.7.4 diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h index 8bad450..3429781 100644 --- a/platform/linux-generic/include/odp_internal.h +++ b/platform/linux-generic/include/odp_internal.h @@ -25,7 +25,6 @@ extern "C" { extern __thread int __odp_errno; -#define INSTANCE_ID 0xdeadbeef #define MAX_CPU_NUMBER 128 typedef struct { diff --git a/platform/linux-generic/odp_init.c b/platform/linux-generic/odp_init.c index f534759..77f4f8a 100644 --- a/platform/linux-generic/odp_init.c +++ b/platform/linux-generic/odp_init.c @@ -116,8 +116,7 @@ int odp_init_global(odp_instance_t *instance, goto init_failed; } - /* Dummy support for single instance */ - *instance = INSTANCE_ID; + *instance = (odp_instance_t)odp_global_data.main_pid; return 0; @@ -128,7 +127,7 @@ init_failed: int odp_term_global(odp_instance_t instance) { - if (instance != INSTANCE_ID) { + if (instance != (odp_instance_t)odp_global_data.main_pid) { ODP_ERR("Bad instance.\n"); return -1; } @@ -250,7 +249,7 @@ int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type) { enum init_stage stage = NO_INIT; - if (instance != INSTANCE_ID) { + if (instance != (odp_instance_t)odp_global_data.main_pid) { ODP_ERR("Bad instance.\n"); goto init_fail; } diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index 4fe07ef..85228cd 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -2317,7 +2317,8 @@ static void *tm_system_thread(void *arg) uint32_t destroying, work_queue_cnt, timer_cnt; int rc; - rc = odp_init_local(INSTANCE_ID, ODP_THREAD_WORKER); + rc = odp_init_local((odp_instance_t)odp_global_data.main_pid, + ODP_THREAD_WORKER); ODP_ASSERT(rc == 0); tm_group = arg;