[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN][RFC PATCH 11/13] tools/libs/ctrl: Implement new xc interfaces for fpga-add and fpga-del


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <fnu.vikram@xxxxxxxxxx>
  • Date: Wed, 1 Sep 2021 23:06:01 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6vRNUT8x84jkmg4e61wPSC8IbP4rdyDEfRG2ff/C/Jw=; b=JBGHCjEfJN7w/dKGMVnu9wvudHVio860healWWmpFiTxuP0vQ8rclTzp3VqJrrIluzImVYGDwVm8+ENZCeQtJ9LJktWjDSmJ65qSD/3tJ6ETgjEpIoyDUuqv3zPOglf2fpSWz7N7bNe8boXWH98nR1bVLSg1ZdRyyTm7qoGiWAdzNEyJxOnS1upCl3WuhptAsGsxq+jxW/skkfjLog2CCuPY1YyN7OqVEXca5FUULzEUr3lsCOYJRKCbSoqq4xM/1XPYPajy/Ba4OTYwyINvv7KsIxkVuv9QOL9FtJ8lnz9ZzWzYZzYCsKaRn8rB60+kIrld0xEhbpIAmP9CRa0lgQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wha1qfH0ZPATby9Q4mskRJHLQuUFsgYuFwayM2JLL9kFOEi6UTuLqfGD7h0DHAwEvM25P+v7FwjXuyf8LxrWZm+lLPC/JyxnMaLUs45BrdupAe0jyBpmKlBjoSuJWsik/UbiO+vbYwJ0hek69GpbGuFMtormyMIFSRCXRsMJhGspWj5k+2+KICf2Kx5bW+PxLfEjejhWYExkrM/y+r5acvQ/WI+lVWYzKSlwypNrCqMsJ9euHDgfCUbxaQwpTwrHqqdBhaaZcfaJAJmDJGz3SuJqxM+JSuQUYvKvQwdfL+6RRmaIMp7/hSd5tJqjJRd4FkSXYzwT5AHjn6L7OefJxg==
  • Cc: <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, Vikram Garhwal <fnu.vikram@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
  • Delivery-date: Thu, 02 Sep 2021 06:51:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

xc_domain_add_fpga() sends the device tree binary overlay and size of .dtbo to
xen.
xc_domain_del_fpga() sends full path for the node to be removed.

Signed-off-by: Vikram Garhwal <fnu.vikram@xxxxxxxxxx>
---
 tools/include/xenctrl.h   |  4 +++
 tools/libs/ctrl/Makefile  |  1 +
 tools/libs/ctrl/xc_fpga.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)
 create mode 100644 tools/libs/ctrl/xc_fpga.c

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index b77726e..d14b3df 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2679,6 +2679,10 @@ int xc_livepatch_replace(xc_interface *xch, char *name, 
uint32_t timeout, uint32
 int xc_domain_cacheflush(xc_interface *xch, uint32_t domid,
                          xen_pfn_t start_pfn, xen_pfn_t nr_pfns);
 
+int xc_domain_add_fpga(xc_interface *xch, void *pfdt, int pdft_size);
+int xc_domain_del_fpga(xc_interface *xch, char *full_dt_node_path);
+
+
 /* Compat shims */
 #include "xenctrl_compat.h"
 
diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile
index 519246b..95021b9 100644
--- a/tools/libs/ctrl/Makefile
+++ b/tools/libs/ctrl/Makefile
@@ -3,6 +3,7 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 SRCS-y       += xc_altp2m.c
 SRCS-y       += xc_cpupool.c
+SRCS-$(CONFIG_ARM) += xc_fpga.c
 SRCS-y       += xc_domain.c
 SRCS-y       += xc_evtchn.c
 SRCS-y       += xc_gnttab.c
diff --git a/tools/libs/ctrl/xc_fpga.c b/tools/libs/ctrl/xc_fpga.c
new file mode 100644
index 0000000..41c37b5
--- /dev/null
+++ b/tools/libs/ctrl/xc_fpga.c
@@ -0,0 +1,82 @@
+/*
+ *
+ * FPGA control functions.
+ * Copyright (C) 2021 Xilinx Inc.
+ * Author Vikram Garhwal <fnu.vikram@xxxxxxxxxx>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "xc_bitops.h"
+#include "xc_private.h"
+#include <xen/hvm/hvm_op.h>
+#include <libfdt.h>
+
+int xc_domain_add_fpga(xc_interface *xch, void *pfdt, int pfdt_size)
+{
+    int err;
+    DECLARE_DOMCTL;
+
+    DECLARE_HYPERCALL_BOUNCE(pfdt, pfdt_size, XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+    if ( (err = xc_hypercall_bounce_pre(xch, pfdt)) )
+        goto err;
+
+    domctl.cmd = XEN_DOMCTL_addfpga;
+    /* Adding the device to hardware domain by default. */
+    domctl.domain = 0;
+    domctl.u.fpga_add_dt.pfdt_size = pfdt_size;
+
+    set_xen_guest_handle(domctl.u.fpga_add_dt.pfdt, pfdt);
+
+    if ( (err = do_domctl(xch, &domctl)) != 0 )
+        PERROR("%s failed\n", __func__);
+
+err:
+    xc_hypercall_bounce_post(xch, pfdt);
+
+    return err;
+}
+
+int xc_domain_del_fpga(xc_interface *xch, char *full_dt_node_path)
+{
+    int err;
+    DECLARE_DOMCTL;
+    size_t size = strlen(full_dt_node_path) + 1;
+
+    DECLARE_HYPERCALL_BOUNCE(full_dt_node_path, size,
+                             XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+    if ( (err = xc_hypercall_bounce_pre(xch, full_dt_node_path)) )
+        goto err;
+
+    domctl.cmd = XEN_DOMCTL_delfpga;
+    /*
+     * Remove the device from the dt_host, setting hardware domain by
+     * default.
+     */
+    domctl.domain = 0;
+    domctl.u.fpga_del_dt.size = size;
+
+    set_xen_guest_handle(domctl.u.fpga_del_dt.full_dt_node_path,
+                         full_dt_node_path);
+
+    if ( (err = do_domctl(xch, &domctl)) != 0 )
+        PERROR("%s failed\n", __func__);
+
+err:
+    xc_hypercall_bounce_post(xch, full_dt_node_path);
+
+    return err;
+}
-- 
2.7.4




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.