linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russ Weight <russell.h.weight@intel.com>
To: mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com,
	hao.wu@intel.com, matthew.gerlach@intel.com,
	Russ Weight <russell.h.weight@intel.com>
Subject: [PATCH v15 5/6] fpga: image-load: create status sysfs node
Date: Wed,  8 Sep 2021 19:18:45 -0700	[thread overview]
Message-ID: <20210909021846.681121-6-russell.h.weight@intel.com> (raw)
In-Reply-To: <20210909021846.681121-1-russell.h.weight@intel.com>

Extend the FPGA Image Load class driver to include a status sysfs node that
can be viewed to determine from the command line if an image load is in
progress. Status will be one of: idle, starting, preparing, writing, or
programming.

Signed-off-by: Russ Weight <russell.h.weight@intel.com>
---
v15:
 - Compare to previous patch:
     [PATCH v14 3/6] fpga: sec-mgr: expose sec-mgr update status
 - Changed file, symbol, and config names to reflect the new driver name
 - Removed signed-off/reviewed-by tags
v14:
 - Updated ABI documentation date and kernel version
v13:
  - No change
v12:
  - Updated Date and KernelVersion fields in ABI documentation
  - Changed syntax of sec_mgr_prog_str[] array definition from:
	"idle",			/* FPGA_SEC_PROG_IDLE */
    to:
	[FPGA_SEC_PROG_IDLE]	    = "idle",
v11:
  - No change
v10:
  - Rebased to 5.12-rc2 next
  - Updated Date and KernelVersion in ABI documentation
v9:
  - Updated Date and KernelVersion in ABI documentation
v8:
  - No change
v7:
  - Changed Date in documentation file to December 2020
v6:
  - No change
v5:
  - Use new function sysfs_emit() in the status_show() function
v4:
  - Changed from "Intel FPGA Security Manager" to FPGA Security Manager"
    and removed unnecessary references to "Intel".
  - Changed: iops -> sops, imgr -> smgr, IFPGA_ -> FPGA_, ifpga_ to fpga_
v3:
  - Use a local variable to read progress once in status_show()
  - Use dev_err to report invalid progress status
v2:
  - Bumped documentation date and version
  - Changed progress state "read_file" to "reading"
---
 .../ABI/testing/sysfs-class-fpga-image-load   |  7 ++++
 MAINTAINERS                                   |  1 +
 drivers/fpga/fpga-image-load.c                | 33 +++++++++++++++++++
 3 files changed, 41 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-image-load

diff --git a/Documentation/ABI/testing/sysfs-class-fpga-image-load b/Documentation/ABI/testing/sysfs-class-fpga-image-load
new file mode 100644
index 000000000000..6c04a49f01cc
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-class-fpga-image-load
@@ -0,0 +1,7 @@
+What: 		/sys/class/fpga_image_load/fpga_imageX/status
+Date:		Aug 2021
+KernelVersion:	5.15
+Contact:	Russ Weight <russell.h.weight@intel.com>
+Description:	Read-only. Returns a string describing the current status
+		of an FPGA image upload. The string will be one of the
+		following: idle, starting, preparing, writing, programming.
diff --git a/MAINTAINERS b/MAINTAINERS
index 637bc003ca81..e3fbc1bde9bc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7362,6 +7362,7 @@ FPGA SECURITY MANAGER DRIVERS
 M:	Russ Weight <russell.h.weight@intel.com>
 L:	linux-fpga@vger.kernel.org
 S:	Maintained
+F:	Documentation/ABI/testing/sysfs-class-fpga-image-load
 F:	Documentation/fpga/fpga-image-load.rst
 F:	drivers/fpga/fpga-image-load.c
 F:	include/linux/fpga/fpga-image-load.h
diff --git a/drivers/fpga/fpga-image-load.c b/drivers/fpga/fpga-image-load.c
index 99a47b21c995..6ec0a39f07b3 100644
--- a/drivers/fpga/fpga-image-load.c
+++ b/drivers/fpga/fpga-image-load.c
@@ -236,6 +236,38 @@ static const struct file_operations fpga_image_load_fops = {
 	.unlocked_ioctl = fpga_image_load_ioctl,
 };
 
+static const char * const image_load_prog_str[] = {
+	[FPGA_IMAGE_PROG_IDLE]	      = "idle",
+	[FPGA_IMAGE_PROG_STARTING]    = "starting",
+	[FPGA_IMAGE_PROG_PREPARING]   = "preparing",
+	[FPGA_IMAGE_PROG_WRITING]     = "writing",
+	[FPGA_IMAGE_PROG_PROGRAMMING] = "programming"
+};
+
+static ssize_t
+status_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct fpga_image_load *imgld = to_image_load(dev);
+	const char *status = "unknown-status";
+	enum fpga_image_prog progress;
+
+	progress = imgld->progress;
+	if (progress < FPGA_IMAGE_PROG_MAX)
+		status = image_load_prog_str[progress];
+	else
+		dev_err(dev, "Invalid status during secure update: %d\n",
+			progress);
+
+	return sysfs_emit(buf, "%s\n", status);
+}
+static DEVICE_ATTR_RO(status);
+
+static struct attribute *fpga_image_load_attrs[] = {
+	&dev_attr_status.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(fpga_image_load);
+
 /**
  * fpga_image_load_register - create and register an FPGA Image Load Device
  *
@@ -373,6 +405,7 @@ static int __init fpga_image_load_class_init(void)
 	if (ret)
 		goto exit_destroy_class;
 
+	fpga_image_load_class->dev_groups = fpga_image_load_groups;
 	fpga_image_load_class->dev_release = fpga_image_load_dev_release;
 
 	return 0;
-- 
2.25.1


  parent reply	other threads:[~2021-09-09  2:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  2:18 [PATCH v15 0/6] FPGA Image Load (previously Security Manager) Russ Weight
2021-09-09  2:18 ` [PATCH v15 1/6] fpga: image-load: fpga image load class driver Russ Weight
2021-09-10  6:46   ` Xu Yilun
2021-09-10 20:47     ` Russ Weight
2021-09-09  2:18 ` [PATCH v15 2/6] fpga: image-load: enable image loads Russ Weight
2021-09-10  8:22   ` Xu Yilun
2021-09-10 23:18     ` Russ Weight
2021-09-13  6:48       ` Xu Yilun
2021-09-13  9:36         ` Xu Yilun
2021-09-21 19:08           ` Russ Weight
2021-09-09  2:18 ` [PATCH v15 3/6] fpga: image-load: signal eventfd when complete Russ Weight
2021-09-09  2:18 ` [PATCH v15 4/6] fpga: image-load: add status ioctl Russ Weight
2021-09-10  8:50   ` Xu Yilun
2021-09-10 23:23     ` Russ Weight
2021-09-11 18:12       ` Tom Rix
2021-09-13  8:24         ` Xu Yilun
2021-09-09  2:18 ` Russ Weight [this message]
2021-09-10  8:52   ` [PATCH v15 5/6] fpga: image-load: create status sysfs node Xu Yilun
2021-09-10 23:30     ` Russ Weight
2021-09-11 17:58       ` Tom Rix
2021-09-13  8:27         ` Xu Yilun
2021-09-09  2:18 ` [PATCH v15 6/6] fpga: image-load: enable cancel of image upload Russ Weight
2021-09-10 14:55   ` Xu Yilun
2021-09-10 23:38     ` Russ Weight
2021-09-11 13:13       ` Tom Rix
2021-09-13 10:00         ` Xu Yilun
2021-09-21 20:43           ` Russ Weight
     [not found] ` <20210912023739.4078-1-hdanton@sina.com>
2021-09-21 18:36   ` [PATCH v15 2/6] fpga: image-load: enable image loads Russ Weight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909021846.681121-6-russell.h.weight@intel.com \
    --to=russell.h.weight@intel.com \
    --cc=hao.wu@intel.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.gerlach@intel.com \
    --cc=mdf@kernel.org \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).