Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8318459ybi; Tue, 23 Jul 2019 06:34:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwINFy8eDkG/N09kdbF1GJjvjtJp5arnxmXmnsy2hP3PRe5T2kRK82VvI/axtw7j1zysKbv X-Received: by 2002:a63:e44b:: with SMTP id i11mr29145750pgk.297.1563888897462; Tue, 23 Jul 2019 06:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563888897; cv=none; d=google.com; s=arc-20160816; b=R/SAFkYOloydXH8rW5hYBnSwSCCyTOz32SidTxyU44IYdb50I7dtmhXvmtCP3a4vBR 06Nbzv94P8mmAog7gZozDuRNh8j8HZznAeHn3WpK44o4K8wCZG0/CHyALk5+mypgjrOO zBnC4vVaAzZMG314+b8mdrfvVKMP4qR6xTf0KHElSct7iB2LNNOHQoLw6dEdLSt7G1Nz MWiyAJBuhzNUZUjptnyKHKbZvJ0L0zeNDBEMYOyeykzWhtRVRQvvgT1oCBjBKpDR8QXu Ohj1UqK8vJC4tPPDSGjczBQRZevyuTeSXBUmlGGbBR/iB7k0/nFyt3rO5mB/pv9oTxq/ xo4Q== 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=YpdFrZuNPdPt71i+kZcC1LToKCXp1MUSMZfr+yOevrg=; b=Y3wry59W1M+HaU9Y46/li9xwAPMOdwM+lqaqKOiovqMgWoSiEtOV8lp+z3URTM7ngF +j3kZ6GA04rA2Y85qQ0fl3jaSG/4LPJCeRYmXyFKvbmkwSiohmJoEAHGAK7yFKJPdwg4 7BU/6in7mg9X5HZj4j8rRwlm4aHJK9E+um0nBSFRCr+XRxcCPGfARPos9nD6wR1pyN6y pVQKHq3ELwTh+S0CqDsRHTnsMSmsWpji+uHhdJ5SULk977mB5BjIEV5oudH/vM5o8iUg ZaqLBYEK+w40j9pRbU7dGbXxSytwbpM/owHbDG9WnA79BqN945CfeIzHrFhazpPFoK23 pRyw== 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 9si11916770pgo.283.2019.07.23.06.34.41; Tue, 23 Jul 2019 06:34:57 -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 S1732886AbfGWFKR (ORCPT + 99 others); Tue, 23 Jul 2019 01:10:17 -0400 Received: from mga05.intel.com ([192.55.52.43]:1868 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727735AbfGWFKP (ORCPT ); Tue, 23 Jul 2019 01:10:15 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jul 2019 22:10:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,297,1559545200"; d="scan'208";a="196992391" Received: from hao-dev.bj.intel.com ([10.238.157.65]) by fmsmga002.fm.intel.com with ESMTP; 22 Jul 2019 22:10:13 -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 v3 10/12] fpga: dfl: fme: add capability sysfs interfaces Date: Tue, 23 Jul 2019 12:51:33 +0800 Message-Id: <1563857495-26692-11-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1563857495-26692-1-git-send-email-hao.wu@intel.com> References: <1563857495-26692-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..269e807 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: July 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: July 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: July 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 e333f19..c8703c4 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