Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1625994ybd; Wed, 26 Jun 2019 22:03:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9g0hFOzHjXcWC2aMD23UPeUIgiEb4NnOIgtqNfJXowF70dDrmSIYRcOWsGlIZCex2Sr5h X-Received: by 2002:a17:902:3a5:: with SMTP id d34mr2261828pld.239.1561611780793; Wed, 26 Jun 2019 22:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561611780; cv=none; d=google.com; s=arc-20160816; b=KS6rjlEnno5hfMrz/tqnVP7h0aR2QygK19/6OezsgDvA3OzWUbTYO4g9prxTLOS1ll Cc40aV6+RpMtI5ACXC8rD2YU0F9QzJC5p7ZclTwXFRsLP7IlQYnnXqSKahzZOV/HGeTN c2cz5ktVuq1AtufnWFK9Orq5g4ubdwyVK2PmzJ8Bj+RBxahivMCCoDLW+wzIeytVmxBW J/1Qkhe54qu1/A6uE2OIAUoEA831HxDVIltMJuyCFZXmVbIjns3tz6D15fFqw5Svq3TR lMFSaoNzJji4bpdHzi/cCr0HMS/cBFDrDJ1u6bZgbnLRp0sSUQv/VTxmdBPv8io+PRmj X0OQ== 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=e9m49UxZXlV3aFqWjj/imLePy553m8Bs6DnLIx8g3hQ=; b=KdVV08R1PWBfXpBq60qco4MRJUghL89iyHvIQ8cVTxNy3Ec/uK9yK1HvO8N1YR+AzH fMuWLIxa+HqwRW7lXvuSoTnOy39vYAtqszjC3xFBXKZdtUCQ3vsZdf4tSsIK6Wi945Bk z/xiBEBt1elULaSlj8fqqpNncor4ka81ar61zKGZ33Nq4BR3uNjZufSzKXcE6NGLY3mm Xd9D5qnO8lLYct2f9TptaclqmS0jMNwkLxw92uERes3nJYVESLZdiE3+Xpp6SkYdA1iy GkYQJvIaVPpnMnDL4XLogQJWI2I8tppEJsHieHEnesvGA6kacdxKH/fFR6CqFS4K4EVv Hc0w== 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 j17si1413609pfa.198.2019.06.26.22.02.45; Wed, 26 Jun 2019 22:03:00 -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 S1727470AbfF0FCT (ORCPT + 99 others); Thu, 27 Jun 2019 01:02:19 -0400 Received: from mga11.intel.com ([192.55.52.93]:22943 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727460AbfF0FCS (ORCPT ); Thu, 27 Jun 2019 01:02:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2019 22:02:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,422,1557212400"; d="scan'208";a="173005168" Received: from hao-dev.bj.intel.com ([10.238.157.65]) by orsmga002.jf.intel.com with ESMTP; 26 Jun 2019 22:02:16 -0700 From: Wu Hao To: mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, yilun.xu@intel.com, hao.wu@intel.com, gregkh@linuxfoundation.org, atull@kernel.org, Luwei Kang Subject: [PATCH v4 14/15] fpga: dfl: fme: add capability sysfs interfaces Date: Thu, 27 Jun 2019 12:44:54 +0800 Message-Id: <1561610695-5414-15-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1561610695-5414-1-git-send-email-hao.wu@intel.com> References: <1561610695-5414-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 --- v3: replace scnprintf with sprintf in sysfs interfaces. update sysfs doc kernel version and date. v4: update sysfs doc date. --- 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..99cd3b2 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: June 2019 +KernelVersion: 5.3 +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: June 2019 +KernelVersion: 5.3 +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: June 2019 +KernelVersion: 5.3 +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 38c6342..2d69b8f 100644 --- a/drivers/fpga/dfl-fme-main.c +++ b/drivers/fpga/dfl-fme-main.c @@ -75,10 +75,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 const 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, }; -- 1.8.3.1