From patchwork Mon Nov 7 00:13:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 9414201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2323A6022E for ; Mon, 7 Nov 2016 00:16:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1518A28EB9 for ; Mon, 7 Nov 2016 00:16:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0978928EBB; Mon, 7 Nov 2016 00:16:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0E77E28EBA for ; Mon, 7 Nov 2016 00:16:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3XaM-0004am-K8; Mon, 07 Nov 2016 00:14:50 +0000 Received: from mail-pf0-x232.google.com ([2607:f8b0:400e:c00::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c3XZa-0004KZ-LD for linux-arm-kernel@lists.infradead.org; Mon, 07 Nov 2016 00:14:04 +0000 Received: by mail-pf0-x232.google.com with SMTP id d2so81627688pfd.0 for ; Sun, 06 Nov 2016 16:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ettus-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6mZZOJQQz5cvFU1EFHAIejc8j02YxgPYIHbB1P1s2Fo=; b=YgNmYyqoZJv2TMIMKnWIDYGkLGWm0KzTG8a+mfQtqEgZ99TPULcjGOQTvEibqvovm5 A0hSNd/x9OnN8Cs+Lx0BxECwpSBBGExh8fz4VAYlABjCCO40LAoHM72xUo3zt2vQYJmp RToAZbADHPmjnk7AtLV4nHy4MP10XqGwujw5JfdGYy4fN7or96uTscGKQdPqybfwon0i KotET420OhpbP3puEy9ykHQ9JicGPmpcLRDEGvpRjoDzCufPxOJV8/3nA1VwMRZRbGXy mgPbDKMvL5wEPo1Q1ZdmNeSB06yntpJ7m1m4HqukEXsN/bbErLuQiRwBs49j0pjF29pQ To5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6mZZOJQQz5cvFU1EFHAIejc8j02YxgPYIHbB1P1s2Fo=; b=BsEXywAS1dE+bL9PKfZFY/KnIKW+WCwkeE7FMvq0+ZQeOYSIPKPyAwb98xEj1Q3n9Z 1wg7ij23oxKT6fCikxP1BNrphRufdNzRmh4tRlQI0jMcxTOvBiBthj9mU+/IzSS3B4f5 +AKYBUKAXHbAz4bkU5tI87nNT7rg1mt+YJEBhyHQpQXi30SuNp7WjLWpL4lCqI1ZnWj+ IZYsanz1RWFStU0CdakQofkljHY1atVSBRdyNcoEWGRTtu7hRFtCGL1aa4z+gqg+gLv6 yYZaBClP/b+eRm2JRH75L2t6qP2+kYm22AgbY+OkiResF6AkGF45EtUyAw//FAVLw9ou cLgw== X-Gm-Message-State: ABUngvdus+GuZv3Am86LS+orW9JfMFSgqGdD9GJoty/QStHwJgJCzDAC/fMEE2kY0I2WAoNr X-Received: by 10.98.85.135 with SMTP id j129mr8399985pfb.28.1478477621283; Sun, 06 Nov 2016 16:13:41 -0800 (PST) Received: from archbook.lan ([2601:647:4b00:de01::921]) by smtp.gmail.com with ESMTPSA id t5sm35117798pfb.58.2016.11.06.16.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 06 Nov 2016 16:13:40 -0800 (PST) From: Moritz Fischer To: linux-kernel@vger.kernel.org Subject: [PATCH 2/4] fpga mgr: Expose FPGA capabilities to userland via sysfs Date: Sun, 6 Nov 2016 17:13:24 -0700 Message-Id: <20161107001326.7395-3-moritz.fischer@ettus.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161107001326.7395-1-moritz.fischer@ettus.com> References: <20161107001326.7395-1-moritz.fischer@ettus.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161106_161402_933406_01238565 X-CRM114-Status: GOOD ( 11.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Moritz Fischer , julia@ni.com, atull@opensource.altera.com, michal.simek@xilinx.com, soren.brinkmann@xilinx.com, moritz.fischer.private@gmail.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Expose FPGA capabilities to userland via sysfs. Add Documentation for currently supported capabilities that get exported via sysfs. Signed-off-by: Moritz Fischer Cc: Alan Tull Cc: Michal Simek Cc: Sören Brinkmann Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org --- Documentation/ABI/testing/sysfs-class-fpga-manager | 16 ++++++++++++++++ drivers/fpga/fpga-mgr.c | 20 ++++++++++++++++++++ include/linux/fpga/fpga-mgr.h | 2 ++ 3 files changed, 38 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-fpga-manager b/Documentation/ABI/testing/sysfs-class-fpga-manager index 23056c5..d9aee21 100644 --- a/Documentation/ABI/testing/sysfs-class-fpga-manager +++ b/Documentation/ABI/testing/sysfs-class-fpga-manager @@ -35,3 +35,19 @@ Description: Read fpga manager state as a string. * write complete = Doing post programming steps * write complete error = Error while doing post programming * operating = FPGA is programmed and operating + +What: /sys/class/fpga_manager/fpga/capabilities +Date: November 2016 +KernelVersion: 4.9 +Contact: Moritz Fischer +Description: Read fpga manager capabilities as a string. + The intent is to provide userspace with information on what + operations the particular instance can execute. + + Each line expresses a capability that is available on the + particular instance of an fpga manager. + Supported so far: + + * Full reconfiguration + * Partial reconfiguration + * Decrypt bitstream on the fly diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index ed57c17..98230b7 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -167,6 +167,11 @@ static const char * const state_str[] = { [FPGA_MGR_STATE_OPERATING] = "operating", }; +static const char * const cap_str[] = { + [FPGA_MGR_CAP_FULL_RECONF] = "Full reconfiguration", + [FPGA_MGR_CAP_PARTIAL_RECONF] = "Partial reconfiguration", +}; + static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -183,10 +188,25 @@ static ssize_t state_show(struct device *dev, return sprintf(buf, "%s\n", state_str[mgr->state]); } +static ssize_t capabilities_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fpga_manager *mgr = to_fpga_manager(dev); + char *start = buf; + enum fpga_mgr_capability cap; + + for_each_fpga_mgr_cap_mask(cap, mgr->caps) + buf += sprintf(buf, "%s\n", cap_str[cap]); + + return buf - start; +} + +static DEVICE_ATTR_RO(capabilities); static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RO(state); static struct attribute *fpga_mgr_attrs[] = { + &dev_attr_capabilities.attr, &dev_attr_name.attr, &dev_attr_state.attr, NULL, diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index e73429c..9bb96a5 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h @@ -108,6 +108,8 @@ static inline void __fpga_mgr_cap_set(enum fpga_mgr_capability cap, set_bit(cap, mask->bits); } +#define for_each_fpga_mgr_cap_mask(cap, mask) \ + for_each_set_bit(cap, mask.bits, FPGA_MGR_CAP_END) /** * struct fpga_manager_ops - ops for low level fpga manager drivers