Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp1519276ybh; Sun, 4 Aug 2019 03:40:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoHO2tOzljhu7SHj0HnrFf1xx0k3hpQJW3bu7QvTQsvHb7snqLkjg09ifWY0KFtppVcQmt X-Received: by 2002:a17:902:6a2:: with SMTP id 31mr132402610plh.296.1564915207688; Sun, 04 Aug 2019 03:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564915207; cv=none; d=google.com; s=arc-20160816; b=GwR+TYx95Pxl7Runo0Ujvv1zxjMAnvnvTvCx3lthUftYhkLysYVgKFkwqnWduwgDfz gmKv8puceo1IERj6I1wyheOXzXZftPfqu7qhfEonteBPUZnh1aQAI7A4qlgYLSllLZWV zV3DtvrPW9X2vSvgKmgJJbVorXn9rAspu/HG/4EoWRxsc9kSW0TrtuRizb/+V9IqHwst 3uQ5Gjt6vnmzN+MbYVkI0RW9ob8AQIE4gTQ4+Z04/AEeSf8vek71SWUZzFpRNZJEFECu yFGRRLcBGu4aSiVAgWox0JYCP7jDZKRXNQv9SxLZKF5gOk2dTgTeCQ33ELU6x/ZYmzYR 38hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=pccCi7ummbGF5FJ70Zx7aMc3Y5H6HDF/2uYtON2y534=; b=CihRXd9iu07PI1dQw3grhKi1uPGfpVyPBzdkzT83CFJEcwyVnW1H9PAvtt42pjfHOh JsxBD8o5T7APuZXvOHv/JfPsFT8vWdjkMnEg6xcHpBKV4umd/xQP+d9B0mXHQJM5vrKR 74atQJs8y3wSiXmhckX4kHSxBnSnVRpCN0ruRzm9mEWZBBr4t9tka99hVf8wdKYorkrL XryTvPTba/24qQFK3r0pSmHWgj3k03ScUey10OyCAUVSW26V/0vtTOZArEuKZFfsBExJ hc90ng+TDtOYqf0sSuQqKn+Kg5mAHBNjtOnCLR9MfCdjF9Iosg7BPiNb99MwQvm0mNx6 3tsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si43307747pfc.80.2019.08.04.03.39.22; Sun, 04 Aug 2019 03:40:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbfHDKiK (ORCPT + 99 others); Sun, 4 Aug 2019 06:38:10 -0400 Received: from mga01.intel.com ([192.55.52.88]:31912 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbfHDKiI (ORCPT ); Sun, 4 Aug 2019 06:38:08 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Aug 2019 03:38:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,345,1559545200"; d="scan'208";a="167678993" Received: from hao-dev.bj.intel.com ([10.238.157.65]) by orsmga008.jf.intel.com with ESMTP; 04 Aug 2019 03:38:05 -0700 From: Wu Hao To: gregkh@linuxfoundation.org, mdf@kernel.org, linux-fpga@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-doc@vger.kernel.org, atull@kernel.org, Wu Hao , Luwei Kang , Xu Yilun Subject: [PATCH v4 10/12] fpga: dfl: fme: add capability sysfs interfaces Date: Sun, 4 Aug 2019 18:20:20 +0800 Message-Id: <1564914022-3710-11-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1564914022-3710-1-git-send-email-hao.wu@intel.com> References: <1564914022-3710-1-git-send-email-hao.wu@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds 3 read-only sysfs interfaces for FPGA Management Engine (FME) block for capabilities including cache_size, fabric_version and socket_id. Signed-off-by: Luwei Kang Signed-off-by: Xu Yilun Signed-off-by: Wu Hao Acked-by: Alan Tull Signed-off-by: Moritz Fischer --- v2: rebased. v3: update kernel version and date in sysfs doc --- Documentation/ABI/testing/sysfs-platform-dfl-fme | 23 ++++++++++++ drivers/fpga/dfl-fme-main.c | 48 ++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-fme b/Documentation/ABI/testing/sysfs-platform-dfl-fme index 8fa4feb..65372aa 100644 --- a/Documentation/ABI/testing/sysfs-platform-dfl-fme +++ b/Documentation/ABI/testing/sysfs-platform-dfl-fme @@ -21,3 +21,26 @@ Contact: Wu Hao Description: Read-only. It returns Bitstream (static FPGA region) meta data, which includes the synthesis date, seed and other information of this static FPGA region. + +What: /sys/bus/platform/devices/dfl-fme.0/cache_size +Date: August 2019 +KernelVersion: 5.4 +Contact: Wu Hao +Description: Read-only. It returns cache size of this FPGA device. + +What: /sys/bus/platform/devices/dfl-fme.0/fabric_version +Date: August 2019 +KernelVersion: 5.4 +Contact: Wu Hao +Description: Read-only. It returns fabric version of this FPGA device. + Userspace applications need this information to select + best data channels per different fabric design. + +What: /sys/bus/platform/devices/dfl-fme.0/socket_id +Date: August 2019 +KernelVersion: 5.4 +Contact: Wu Hao +Description: Read-only. It returns socket_id to indicate which socket + this FPGA belongs to, only valid for integrated solution. + User only needs this information, in case standard numa node + can't provide correct information. diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c index 5fdce54..f033f1c 100644 --- a/drivers/fpga/dfl-fme-main.c +++ b/drivers/fpga/dfl-fme-main.c @@ -73,10 +73,58 @@ static ssize_t bitstream_metadata_show(struct device *dev, } static DEVICE_ATTR_RO(bitstream_metadata); +static ssize_t cache_size_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_CAP); + + return sprintf(buf, "%u\n", + (unsigned int)FIELD_GET(FME_CAP_CACHE_SIZE, v)); +} +static DEVICE_ATTR_RO(cache_size); + +static ssize_t fabric_version_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_CAP); + + return sprintf(buf, "%u\n", + (unsigned int)FIELD_GET(FME_CAP_FABRIC_VERID, v)); +} +static DEVICE_ATTR_RO(fabric_version); + +static ssize_t socket_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_CAP); + + return sprintf(buf, "%u\n", + (unsigned int)FIELD_GET(FME_CAP_SOCKET_ID, v)); +} +static DEVICE_ATTR_RO(socket_id); + static struct attribute *fme_hdr_attrs[] = { &dev_attr_ports_num.attr, &dev_attr_bitstream_id.attr, &dev_attr_bitstream_metadata.attr, + &dev_attr_cache_size.attr, + &dev_attr_fabric_version.attr, + &dev_attr_socket_id.attr, NULL, }; ATTRIBUTE_GROUPS(fme_hdr); -- 1.8.3.1