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

[Xen-devel] [PATCH v8 28/28] xen/arm: ITS: Add pci devices in ThunderX



From: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>

ITS initialization required for all PCI devices in
ThunderX platform are done by calling from specific
mapping function.

This patch can be reverted once XEN PCI passthrough
framework for arm64 is in available.

For now all the PCI devices are assigned to Dom0

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
v7: Calculate size of bdf[] instead of hardcoding count
---
 xen/arch/arm/platforms/Makefile   |    1 +
 xen/arch/arm/platforms/thunderx.c |  200 +++++++++++++++++++++++++++++++++++++
 2 files changed, 201 insertions(+)

diff --git a/xen/arch/arm/platforms/Makefile b/xen/arch/arm/platforms/Makefile
index e173fec..d9f98f9 100644
--- a/xen/arch/arm/platforms/Makefile
+++ b/xen/arch/arm/platforms/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_ARM_32) += sunxi.o
 obj-$(CONFIG_ARM_32) += rcar2.o
 obj-$(CONFIG_ARM_64) += seattle.o
 obj-$(CONFIG_ARM_64) += xgene-storm.o
+obj-$(CONFIG_ARM_64) += thunderx.o
diff --git a/xen/arch/arm/platforms/thunderx.c 
b/xen/arch/arm/platforms/thunderx.c
new file mode 100644
index 0000000..1557d98
--- /dev/null
+++ b/xen/arch/arm/platforms/thunderx.c
@@ -0,0 +1,200 @@
+/*
+ * xen/arch/arm/platforms/thunderx.c
+ *
+ * Cavium Thunder specific settings
+ *
+ * Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx>
+ * Copyright (c) 2015 Cavium Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ */
+
+#include <xen/config.h>
+#include <asm/platform.h>
+#include <asm/gic-its.h>
+
+struct pci_dev_list 
+{
+   uint32_t seg;
+   uint32_t bus;
+   uint32_t dev;
+   uint32_t func;
+};
+
+static struct pci_dev_list bdf[] =
+{
+    {0, 0, 1, 0},
+    {0, 0, 2, 0},
+    {0, 0, 6, 0},
+    {0, 0, 7, 0},
+    {0, 0, 10, 0},
+    {0, 0, 11, 0},
+    {0, 0, 14, 0},
+    {0, 0, 15, 0},
+    {0, 0, 16, 0},
+    {0, 1, 0, 0},
+    {0, 1, 0, 1},
+    {0, 1, 0, 5},
+    {0, 1, 1, 4},
+    {0, 1, 9, 0},
+    {0, 1, 9, 1},
+    {0, 1, 9, 2},
+    {0, 1, 9, 3},
+    {0, 1, 9, 4},
+    {0, 1, 9, 5},
+    {0, 1, 10, 0},
+    {0, 1, 10, 1},
+    {0, 1, 10, 2},
+    {0, 1, 10, 3},
+    {0, 1, 14, 0},
+    {0, 1, 14, 2},
+    {0, 1, 14, 4},
+    {0, 1, 16, 0},
+    {0, 1, 16, 1},
+    {0, 2, 0, 0},
+    {0, 3, 0, 0},
+    {0, 4, 0, 0},
+    {1, 0, 1, 0},
+    {1, 0, 4, 0},
+    {1, 0, 5, 0},
+    {1, 0, 6, 0},
+    {1, 0, 7, 0},
+    {1, 0, 8, 0},
+    {1, 0, 9, 0},
+    {1, 0, 10, 0},
+    {1, 0, 11, 0},
+    {2, 0, 1, 0},
+    {2, 0, 2, 0},
+    {2, 0, 3, 0},
+    {2, 1, 0, 0},
+    {2, 1, 0, 1},
+    {2, 1, 0, 2},
+    {2, 1, 0, 3},
+    {2, 1, 0, 4},
+    {2, 1, 0, 5},
+    {2, 1, 0, 6},
+    {2, 1, 0, 7},
+    {2, 1, 1, 0},
+    {2, 1, 1, 1},
+    {2, 1, 1, 2},
+    {2, 1, 1, 3},
+    {2, 1, 1, 4},
+    {2, 1, 1, 5},
+    {2, 1, 1, 6},
+    {2, 1, 1, 7},
+    {2, 1, 2, 0},
+    {2, 1, 2, 1},
+    {2, 1, 2, 2},
+    {2, 1, 2, 3},
+    {2, 1, 2, 4},
+    {2, 1, 2, 5},
+    {2, 1, 2, 6},
+    {2, 1, 2, 7},
+    {2, 1, 3, 0},
+    {2, 1, 3, 1},
+    {2, 1, 3, 2},
+    {2, 1, 3, 3},
+    {2, 1, 3, 4},
+    {2, 1, 3, 5},
+    {2, 1, 3, 6},
+    {2, 1, 3, 7},
+    {2, 1, 4, 0},
+    {2, 1, 4, 1},
+    {2, 1, 4, 2},
+    {2, 1, 4, 3},
+    {2, 1, 4, 4},
+    {2, 1, 4, 5},
+    {2, 1, 4, 6},
+    {2, 1, 4, 7},
+    {2, 1, 5, 0},
+    {2, 1, 5, 1},
+    {2, 1, 5, 2},
+    {2, 1, 5, 3},
+    {2, 1, 5, 4},
+    {2, 1, 5, 5},
+    {2, 1, 5, 6},
+    {2, 1, 5, 7},
+    {2, 1, 6, 0},
+    {2, 1, 6, 1},
+    {2, 1, 6, 2},
+    {2, 1, 6, 3},
+    {2, 1, 6, 4},
+    {2, 1, 6, 5},
+    {2, 1, 6, 6},
+    {2, 1, 6, 7},
+    {2, 1, 7, 0},
+    {2, 1, 7, 1},
+    {2, 1, 7, 2},
+    {2, 1, 7, 3},
+    {2, 1, 7, 4},
+    {3, 0, 1, 0},
+};
+
+#define BDF_TO_DEVID(seg, bus, dev, func) (seg << 16 | bus << 8 | dev << 3| 
func)
+
+/* TODO: add and assign devices using PCI framework */
+static int thunderx_specific_mapping(struct domain *d)
+{
+    struct dt_device_node *dt_its;
+    uint32_t devid, i;
+    int res;
+
+    static const struct dt_device_match its_device_ids[] __initconst =
+    {
+        DT_MATCH_GIC_ITS,
+        { /* sentinel */ },
+    };
+
+    for (dt_its = dt_find_matching_node(NULL, its_device_ids); dt_its;
+           dt_its = dt_find_matching_node(dt_its, its_device_ids))
+    {
+        break;
+    }
+
+    if ( dt_its == NULL )
+    {
+        dprintk(XENLOG_ERR, "ThunderX: ITS node not found to add device\n");
+        return 0;
+    }
+
+    for ( i = 0; i < ARRAY_SIZE(bdf); i++ )
+    {
+        devid = BDF_TO_DEVID(bdf[i].seg, bdf[i].bus,bdf[i].dev, bdf[i].func);
+        res = its_add_device(devid, 32, dt_its);
+        if ( res )
+            return res;
+        res = its_assign_device(d, devid, devid);
+        if ( res )
+            return res;
+    }
+
+    return 0;
+}
+
+static const char * const thunderx_dt_compat[] __initconst =
+{
+    "cavium,thunder-88xx",
+    NULL
+};
+
+PLATFORM_START(thunderx, "THUNDERX")
+    .compatible = thunderx_dt_compat,
+    .specific_mapping = thunderx_specific_mapping,
+PLATFORM_END
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.7.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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