From patchwork Wed Jan 20 09:20:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Zhang X-Patchwork-Id: 60018 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3067625lbb; Wed, 20 Jan 2016 01:38:43 -0800 (PST) X-Received: by 10.140.226.8 with SMTP id w8mr34690630qhb.83.1453282723017; Wed, 20 Jan 2016 01:38:43 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j125si42739723qhd.110.2016.01.20.01.38.42; Wed, 20 Jan 2016 01:38:42 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 98224610E1; Wed, 20 Jan 2016 09:38:42 +0000 (UTC) Authentication-Results: lists.linaro.org; dkim=fail reason="verification failed; unprotected key" header.d=linaro.org header.i=@linaro.org header.b=GEI489MB; dkim-adsp=none (unprotected policy); dkim-atps=neutral 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.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,T_DKIM_INVALID,URIBL_BLOCKED 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 171F861736; Wed, 20 Jan 2016 09:36: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 3FB6B61784; Wed, 20 Jan 2016 09:36:05 +0000 (UTC) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by lists.linaro.org (Postfix) with ESMTPS id D87666178A for ; Wed, 20 Jan 2016 09:35:31 +0000 (UTC) Received: by mail-pa0-f53.google.com with SMTP id cy9so2056279pac.0 for ; Wed, 20 Jan 2016 01:35:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9dVXO7i8RHmFYzD51kdmCZDO7WCxYu/vwX8Y0WzbF80=; b=GEI489MBu3bK8wq3V/Zh3/fEqdc17Kb1bOlEiPMIUMSkj4RWXC1qjBIeom7OwedhHh Oyxlbdr8BM5gXh0y0maYGRyt6D9z+HFa3pVQ0DEJCszA9x9JkvU3+OgjciI2kN/Uj5RM koTt4i1/ESHHL30oO/pScy41eFsUNYXZhGbYo= 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=9dVXO7i8RHmFYzD51kdmCZDO7WCxYu/vwX8Y0WzbF80=; b=mLVd7AsBPzArcbpjQijt3jZLVruB6oDat1R5hg2vtDU9lEQT7pc0ipuGCifzYzkR0t rOTvnie6lvvseRU9XmSzE2mYWKB5chhnJHc/5NJEs+Ua1nQWLzzzXPsiYHtXhIwZuvKU 8lRvz5uCDHs1FGGjbbgbD5Cg4cUaKv9sROmwYzpNeQY6AW7rsJwwtlU1dL2coO9WwP/n rz6qU2hXJ61RKjT2CjElyDX26CDLgHB6YhxV3tF4B97VjtWKtZncwhQQ3RyzpvXFVTXK a/9UBld7J46xCle1yMFFu0lNWXsL/mtq0F7O9PJatY0yJQrzLz8VeGjK5FJy8UfbN4wj 1tRA== X-Gm-Message-State: ALoCoQkj0Slved5zfxwLCK3JeS15ox+xmAV44Fzm331aBEV0y5BtHmAXmv0Bp5PCvHhZeS7EXoba3F9CW7P/eGrT20yf/HAuMg== X-Received: by 10.66.163.7 with SMTP id ye7mr49941460pab.55.1453282531220; Wed, 20 Jan 2016 01:35:31 -0800 (PST) Received: from ubuntu1504.ap.freescale.net (gate-zmy3.freescale.com. [192.88.167.1]) by smtp.gmail.com with ESMTPSA id xz6sm47592797pab.42.2016.01.20.01.35.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Jan 2016 01:35:30 -0800 (PST) From: hongbo.zhang@linaro.org To: lng-odp@lists.linaro.org Date: Wed, 20 Jan 2016 17:20:55 +0800 Message-Id: <1453281662-31499-6-git-send-email-hongbo.zhang@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1453281662-31499-1-git-send-email-hongbo.zhang@linaro.org> References: <1453281662-31499-1-git-send-email-hongbo.zhang@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v7 API-NEXT 05/12] linux-generic: sysinfo: move MIPS system info codes to its plarform file 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Hongbo Zhang This patch moves the MIPS system info codes into the newly added MIPS specific platform file. Signed-off-by: Hongbo Zhang --- platform/linux-generic/Makefile.am | 1 + .../linux-generic/arch/mips64/odp_sysinfo_parse.c | 53 ++++++++++++++++++++++ platform/linux-generic/odp_system_info.c | 47 ------------------- 3 files changed, 54 insertions(+), 47 deletions(-) create mode 100644 platform/linux-generic/arch/mips64/odp_sysinfo_parse.c diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index de43eff..d3802f8 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -165,6 +165,7 @@ __LIB__libodp_la_SOURCES = \ EXTRA_DIST = \ arch/linux/odp_cpu_arch.c \ arch/mips64/odp_cpu_arch.c \ + arch/mips64/odp_sysinfo_parse.c \ arch/x86/odp_cpu_arch.c \ arch/x86/odp_sysinfo_parse.c diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c new file mode 100644 index 0000000..264ab28 --- /dev/null +++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c @@ -0,0 +1,53 @@ +/* Copyright (c) 2016, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) +{ + char str[1024]; + char *pos; + double mhz = 0.0; + int model = 0; + int count = 2; + + while (fgets(str, sizeof(str), file) != NULL && count > 0) { + if (!mhz) { + pos = strstr(str, "BogoMIPS"); + + if (pos) + if (sscanf(pos, "BogoMIPS : %lf", &mhz) == 1) + count--; + } + + if (!model) { + pos = strstr(str, "cpu model"); + + if (pos) { + int len; + + pos = strchr(str, ':'); + strncpy(sysinfo->model_str[0], pos + 2, + sizeof(sysinfo->model_str[0])); + len = strlen(sysinfo->model_str[0]); + sysinfo->model_str[0][len - 1] = 0; + model = 1; + count--; + } + } + } + + /* bogomips seems to be 2x freq */ + sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0 / 2.0); + + return 0; +} + +uint64_t odp_cpu_hz_current(int id ODP_UNUSED) +{ + return -1; +} diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index d2b0a68..2b8e2b8 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -121,53 +121,6 @@ static uint64_t odp_cpu_hz_current(int id ODP_UNUSED) return -1; } -#elif defined __OCTEON__ - -static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) -{ - char str[1024]; - char *pos; - double mhz = 0.0; - int model = 0; - int count = 2; - - while (fgets(str, sizeof(str), file) != NULL && count > 0) { - if (!mhz) { - pos = strstr(str, "BogoMIPS"); - - if (pos) { - sscanf(pos, "BogoMIPS : %lf", &mhz); - count--; - } - } - - if (!model) { - pos = strstr(str, "cpu model"); - - if (pos) { - int len; - pos = strchr(str, ':'); - strncpy(sysinfo->model_str[0], pos + 2, - sizeof(sysinfo->model_str[0])); - len = strlen(sysinfo->model_str[0]); - sysinfo->model_str[0][len - 1] = 0; - model = 1; - count--; - } - } - } - - /* bogomips seems to be 2x freq */ - sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0 / 2.0); - - return 0; -} - -static uint64_t odp_cpu_hz_current(int id ODP_UNUSED) -{ - return -1; -} - #elif defined __powerpc__ static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo) {