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

[Minios-devel] [UNIKRAFT PATCH v2 04/12] plat/xen/drivers: Add skeleton for netfront driver


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Mon, 1 Apr 2019 16:42:44 +0300
  • Cc: felipe.huici@xxxxxxxxx, Razvan Cojocaru <razvan.cojocaru93@xxxxxxxxx>, Florian.Schmidt@xxxxxxxxx, sharan.santhanam@xxxxxxxxx, simon.kuenzer@xxxxxxxxx, yuri.volchkov@xxxxxxxxx
  • Delivery-date: Mon, 01 Apr 2019 13:43:04 +0000
  • Ironport-phdr: 9a23:Loy//hCsuINrSDyGtCtnUyQJP3N1i/DPJgcQr6AfoPdwSP36r86wAkXT6L1XgUPTWs2DsrQY0rKQ4vyrBzBIyK3CmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TW94jEIBxrwKxd+KPjrFY7OlcS30P2594HObwlSizexfK9+IA+yoAjeucUbgIRvIbstxxXUpXdFZ/5Yzn5yK1KJmBb86Maw/Jp9/ClVpvks6c1OX7jkcqohVbBXAygoPG4z5M3wqBnMVhCP6WcGUmUXiRVHHQ7I5wznU5jrsyv6su192DSGPcDzULs5Vyiu47ttRRT1kyoMKSI3/3/LhcxxlKJboQyupxpjw47PfYqZMONycr7Bcd8GQGZMWNtaWS5cDYOmd4YBD/QPM/tWoYf+oFUBrxW+CBKwCO/z0DJEmmX70bEm3+knDArI3BYgH9ULsHnMstj1M7wSUfy0zKnO0D7Nae5W2S/g6IPVdR0uvfaMXalsccrQz0kjDQfFjkiIqYz4JD6ayv8Nv3KD7+p9Tu2jkXQnqwZorzWp28wiiZHJi5oIxl3L6Cl12oU4KN2iREJlf9KpEoFcui+CO4drTc4uXntktSU6x7Ecp5K2ciYHxI46yxPQdfCKdZWD7Aj5W+aLOzh4gWpoeLe4hxmv70et0vb8Vsyo0FZSqSpFj8XMumgN1xPN7siHTeNw/lmk2TmV1gDT7vtILlwvlabBM54h36U/moAJsUTEBiP2mUP2g7GKdkg85+Sl5Pnrbq/lq5KcLYN4lB/yP6Y0lsGxGeg4NxIBX2mf+eSyzr3j+kj5Ta1Wgf0xianZrJHaJcIBqq69Hg9Vypsj5g2jADe9ytgYhWQHI0lfdBKdiIjlI0vOL+zgDfejn1Ssly9mx+rcMbzgHJXCNH7DnK39crZ66U5czxY8wspF55JJDrwMLun+WkD0tNPCDx85Nxa4zPrgCNV4zokeQ36AAreFMKPOtl+F/ucvI+iKZI8Uvzb9MOEp6OPwgn8nh1AdebKk3Z8WaHCjAvRmOF+VYHXyjdcHC2sKuRA+TOPygl2YTTFTf2qyX7475jwjCIymCYDDRpqsgLOb2ie3BIBYaXxGClCJEHfnapmEVuwKaC2MPsBhliYLWqO7R4A/yBGkrBX6xKZ/LurI5i0Ysoru1NZr6O3XlBEy7SJ7A96d02GQTmF7gmIISiQw3K9hvUN9zk2M3rNij/NGCNxZ/+lJXRsiNZ7A0+x6DMj/WhnBftiTUlapWNOmDSsqTt0rxd8Of0Z9FM+kjh/Z2iqnGLkVmKKXC5ww6K3TxGL9KNhgy3zezqkuk0EmQtdTNW2hnqN/7AnTB4vOk0Wfjaqqdrkc0zDL9GaC02WOplpVUAhuXqrZWXAQfFDZoc7n6UPfV7WuE6goMhNdyc6eLatHct3ojUhcRPfiItjefWWxm2OsChaIxbOMa5Tqdn4b3CrDFEcElxoc8m2cOQcgGyfy617ZWTlvE1PoeAbg/PdzrFu/T1Qo1EeaYksn0KC6qTAPgvnJYPQIwrMC8AM8syg8SF26xM7XDZyEuhJ8VK5HJ8sg6hFd0jSK5ERGIpW8IvU61RYleANtsharjk0vBw==
  • Ironport-sdr: l51AVOy+UCRsIoPdfqZiS5kxVEglA/APjOvo2Y5RJzTGUsdyMxfM1e86QYY1JmxAhBzcXhqb5j os4iQiX1nrLQ==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

This patch introduces the netfront driver skeleton.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
Signed-off-by: Razvan Cojocaru <razvan.cojocaru93@xxxxxxxxx>
---
 plat/xen/Config.uk                 | 10 ++++++
 plat/xen/Makefile.uk               | 10 ++++++
 plat/xen/drivers/net/exportsyms.uk |  1 +
 plat/xen/drivers/net/netfront.c    | 73 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+)
 create mode 100644 plat/xen/drivers/net/exportsyms.uk
 create mode 100644 plat/xen/drivers/net/netfront.c

diff --git a/plat/xen/Config.uk b/plat/xen/Config.uk
index 23bdf35a..e81455d8 100644
--- a/plat/xen/Config.uk
+++ b/plat/xen/Config.uk
@@ -68,4 +68,14 @@ menuconfig XEN_XENBUS
        help
                Registers Xenbus as bus driver to libukbus and provides a
                XenStore communication API for Xen drivers
+
+if (XEN_XENBUS)
+       config XEN_NETFRONT
+               bool "Xenbus Netfront Driver"
+               default n
+               select LIBUKNETDEV
+               select XEN_GNTTAB
+               help
+                       Driver for netfront devices
+endif
 endif
diff --git a/plat/xen/Makefile.uk b/plat/xen/Makefile.uk
index 3642c5b2..e920a13e 100644
--- a/plat/xen/Makefile.uk
+++ b/plat/xen/Makefile.uk
@@ -10,6 +10,7 @@ $(eval $(call addplat_s,xen,$(CONFIG_PLAT_XEN)))
 ##
 $(eval $(call addplatlib,xen,libxenplat))
 $(eval $(call addplatlib_s,xen,libxenbus,$(CONFIG_XEN_XENBUS)))
+$(eval $(call addplatlib_s,xen,libxennetfront,$(CONFIG_XEN_NETFRONT)))
 
 ##
 ## Xen platform compilation settings
@@ -97,3 +98,12 @@ LIBXENBUS_SRCS-y               += 
$(LIBXENPLAT_BASE)/xenbus/xs_comms.c
 LIBXENBUS_SRCS-y               += $(LIBXENPLAT_BASE)/xenbus/xs_watch.c
 LIBXENBUS_SRCS-y               += $(LIBXENPLAT_BASE)/xenbus/xs.c
 endif
+
+ifeq ($(CONFIG_XEN_NETFRONT),y)
+LIBXENNETFRONT_EXPORTS          = $(LIBXENPLAT_BASE)/drivers/net/exportsyms.uk
+LIBXENNETFRONT_ASFLAGS-y       += $(LIBXENPLAT_ASFLAGS-y)
+LIBXENNETFRONT_ASINCLUDES-y    += $(LIBXENPLAT_ASINCLUDES-y)
+LIBXENNETFRONT_CFLAGS-y        += $(LIBXENPLAT_CFLAGS-y)
+LIBXENNETFRONT_CINCLUDES-y     += $(LIBXENPLAT_CINCLUDES-y)
+LIBXENNETFRONT_SRCS-y          += $(LIBXENPLAT_BASE)/drivers/net/netfront.c
+endif
diff --git a/plat/xen/drivers/net/exportsyms.uk 
b/plat/xen/drivers/net/exportsyms.uk
new file mode 100644
index 00000000..c86c3f35
--- /dev/null
+++ b/plat/xen/drivers/net/exportsyms.uk
@@ -0,0 +1 @@
+none
\ No newline at end of file
diff --git a/plat/xen/drivers/net/netfront.c b/plat/xen/drivers/net/netfront.c
new file mode 100644
index 00000000..203ffeae
--- /dev/null
+++ b/plat/xen/drivers/net/netfront.c
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Costin Lupu <costin.lupu@xxxxxxxxx>
+ *          Razvan Cojocaru <razvan.cojocaru93@xxxxxxxxx>
+ *
+ * Copyright (c) 2019, NEC Europe Ltd., NEC Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+#include <xenbus/xenbus.h>
+
+
+#define DRIVER_NAME  "xen-netfront"
+
+static struct uk_alloc *drv_allocator;
+
+
+static int netfront_add_dev(struct xenbus_device *xendev)
+{
+       int rc = 0;
+
+       UK_ASSERT(xendev != NULL);
+
+       return rc;
+}
+
+static int netfront_drv_init(struct uk_alloc *allocator)
+{
+       /* driver initialization */
+       if (!allocator)
+               return -EINVAL;
+
+       drv_allocator = allocator;
+       return 0;
+}
+
+static const xenbus_dev_type_t netfront_devtypes[] = {
+       xenbus_dev_vif,
+       xenbus_dev_none
+};
+
+static struct xenbus_driver netfront_driver = {
+       .device_types = netfront_devtypes,
+       .init         = netfront_drv_init,
+       .add_dev      = netfront_add_dev
+};
+XENBUS_REGISTER_DRIVER(&netfront_driver);
-- 
2.11.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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