Received: by 10.223.185.116 with SMTP id b49csp3393576wrg; Tue, 13 Feb 2018 01:43:32 -0800 (PST) X-Google-Smtp-Source: AH8x225y+vuK1yjpKg/enXDXU8hsiSTzk0micvoxlXlzJ7iUy7WM9Z8Qa3ZNeWY3AHHxfgbHY9qp X-Received: by 2002:a17:902:1486:: with SMTP id k6-v6mr593265pla.376.1518515012881; Tue, 13 Feb 2018 01:43:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518515012; cv=none; d=google.com; s=arc-20160816; b=MWkhzh01Nz7crdliXEHUBtIBeQN/pv+RKoFLjqKSBrzlvVSDl9kxj43nPnFoG82EmV cdA78WE+IuaLIRA/H2TadJBcPP6NAz75djDW+f6lbk/qtADPrT3CvF2CrE42fqBPZe/P Y2/0SQtulbSPtHOrypXGJVqFcfff8oncz3nwuST0NptxGfoKGqlHBQNVO3fqYqVDGtgL ce7E0HJeNa0BTAEzKXKKPSbmvWhEWBFqZfegLG8jkplre6FADdzDdEw+H0hZWm0Vu68G 8o/r1rTwtMhfQJJTW8iiwFyeE56fEO2ikhCWH4uX5KjTM+PLVwwwNR6vVqU8jbK635wT SaeA== 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:arc-authentication-results; bh=aoB1YYrU0svJ6GbmpW8SXocdmNm2WM8QVYHW3qUKh1s=; b=mWfkIWf2o10rHWGB5+cF1y9hLFCFuwhC9YhiBEbAv3blJ3iXgIEY1OgGWxcRTC586X 9Hr97BgK0QRzKUb+986sR5icLk7drvu+66+PAvvF2h01K6bejAHSHIeQQlUiN6ylvz4a cgZLZENmbBh0lMeWLhQvX1X9z7yX1uYmdItxBUTJjiMlFjeRo8Y1S0C8z/WQ4acTgvIm IQU2xpD4sYCmxwO2+A6+sUiS+n2yZrzZP50/FpDMRPyD3VU4c7AZ0Vs7MAdS/V4E+co9 WjTMyJOcztl7NX/wveEq1kb5jUhBb/RUGK+apPH+D/FMe4AJKVCFWmHLHLL/6alsjxXi +R1A== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k72si978190pge.131.2018.02.13.01.43.18; Tue, 13 Feb 2018 01:43:32 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934648AbeBMJll (ORCPT + 99 others); Tue, 13 Feb 2018 04:41:41 -0500 Received: from mga03.intel.com ([134.134.136.65]:27130 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934640AbeBMJfl (ORCPT ); Tue, 13 Feb 2018 04:35:41 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2018 01:35:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,507,1511856000"; d="scan'208";a="26889557" Received: from hao-dev.bj.intel.com ([10.238.157.61]) by FMSMGA003.fm.intel.com with ESMTP; 13 Feb 2018 01:35:38 -0800 From: Wu Hao To: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, luwei.kang@intel.com, yi.z.zhang@intel.com, hao.wu@intel.com, Tim Whisonant , Enno Luebbers , Shiva Rao , Christopher Rauer , Xiao Guangrong Subject: [PATCH v4 11/24] fpga: dfl: fme: add header sub feature support Date: Tue, 13 Feb 2018 17:24:40 +0800 Message-Id: <1518513893-4719-12-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518513893-4719-1-git-send-email-hao.wu@intel.com> References: <1518513893-4719-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 From: Kang Luwei The Header Register set is always present for FPGA Management Engine (FME), this patch implements init and uinit function for header sub feature and introduce several read-only sysfs interfaces for the capability and status. Sysfs interfaces: * /sys/class/fpga_region///ports_num Read-only. Number of ports implemented * /sys/class/fpga_region///bitstream_id Read-only. Blue Bitstream (static FPGA region) identifier number. It contains the detailed version and other information of this static FPGA region. * /sys/class/fpga_region///bitstream_metadata Read-only. Blue Bitstream (static FPGA region) meta data. It contains the synthesis date, seed and other information of this static FPGA region. Signed-off-by: Tim Whisonant Signed-off-by: Enno Luebbers Signed-off-by: Shiva Rao Signed-off-by: Christopher Rauer Signed-off-by: Kang Luwei Signed-off-by: Xiao Guangrong Signed-off-by: Wu Hao --- v2: add sysfs documentation v3: rename driver to fpga-dfl-fme. improve sysfs doc and commit description. replace bitfield. v4: rebase and switch to use id for sub feature matching. add more description for bitstream_id/metadata. --- Documentation/ABI/testing/sysfs-platform-dfl-fme | 23 ++++++++ drivers/fpga/dfl-fme-main.c | 68 ++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-platform-dfl-fme diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-fme b/Documentation/ABI/testing/sysfs-platform-dfl-fme new file mode 100644 index 0000000..23a13a5 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-platform-dfl-fme @@ -0,0 +1,23 @@ +What: /sys/bus/platform/devices/dfl-fme.0/ports_num +Date: February 2018 +KernelVersion: 4.16 +Contact: Wu Hao +Description: Read-only. One DFL FPGA device may have more than 1 + port/Accelerator Function Unit (AFU). It returns the + number of ports on the FPGA device when read it. + +What: /sys/bus/platform/devices/dfl-fme.0/bitstream_id +Date: February 2018 +KernelVersion: 4.16 +Contact: Wu Hao +Description: Read-only. It returns Blue Bitstream (static FPGA region) + identifier number, which includes the detailed version + and other information of this static FPGA region. + +What: /sys/bus/platform/devices/dfl-fme.0/bitstream_meta +Date: February 2018 +KernelVersion: 4.16 +Contact: Wu Hao +Description: Read-only. It returns Blue Bitstream (static FPGA region) + meta data, which includes the synthesis date, seed and other + information of this static FPGA region. diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c index ebe6b52..056ae24 100644 --- a/drivers/fpga/dfl-fme-main.c +++ b/drivers/fpga/dfl-fme-main.c @@ -19,9 +19,76 @@ #include "dfl.h" +static ssize_t ports_num_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_CAP); + + return scnprintf(buf, PAGE_SIZE, "%u\n", + (unsigned int)FIELD_GET(FME_CAP_NUM_PORTS, v)); +} +static DEVICE_ATTR_RO(ports_num); + +/* + * Blue Bitstream (static FPGA region) identifier number. It contains the + * detailed version and other information of this static FPGA region. + */ +static ssize_t bitstream_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_BITSTREAM_ID); + + return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v); +} +static DEVICE_ATTR_RO(bitstream_id); + +/* + * Blue Bitstream (static FPGA region) meta data. It contains the synthesis + * date, seed and other information of this static FPGA region. + */ +static ssize_t bitstream_metadata_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + void __iomem *base; + u64 v; + + base = get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER); + + v = readq(base + FME_HDR_BITSTREAM_MD); + + return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v); +} +static DEVICE_ATTR_RO(bitstream_metadata); + +static const struct attribute *fme_hdr_attrs[] = { + &dev_attr_ports_num.attr, + &dev_attr_bitstream_id.attr, + &dev_attr_bitstream_metadata.attr, + NULL, +}; + static int fme_hdr_init(struct platform_device *pdev, struct feature *feature) { + void __iomem *base = feature->ioaddr; + int ret; + dev_dbg(&pdev->dev, "FME HDR Init.\n"); + dev_dbg(&pdev->dev, "FME cap %llx.\n", + (unsigned long long)readq(base + FME_HDR_CAP)); + + ret = sysfs_create_files(&pdev->dev.kobj, fme_hdr_attrs); + if (ret) + return ret; return 0; } @@ -29,6 +96,7 @@ static int fme_hdr_init(struct platform_device *pdev, struct feature *feature) static void fme_hdr_uinit(struct platform_device *pdev, struct feature *feature) { dev_dbg(&pdev->dev, "FME HDR UInit.\n"); + sysfs_remove_files(&pdev->dev.kobj, fme_hdr_attrs); } static const struct feature_ops fme_hdr_ops = { -- 2.7.4