Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/pci Add MSI-X support.



details:   https://anonhg.NetBSD.org/src/rev/1f5ed447d281
branches:  trunk
changeset: 445520:1f5ed447d281
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Oct 31 15:42:17 2018 +0000

description:
Add MSI-X support.

diffstat:

 sys/arch/arm/pci/pci_msi_machdep.c |  32 +++++++++++++++++++++++++++-----
 sys/arch/arm/pci/pci_msi_machdep.h |   3 ++-
 2 files changed, 29 insertions(+), 6 deletions(-)

diffs (87 lines):

diff -r db4fb49e1a69 -r 1f5ed447d281 sys/arch/arm/pci/pci_msi_machdep.c
--- a/sys/arch/arm/pci/pci_msi_machdep.c        Wed Oct 31 14:15:12 2018 +0000
+++ b/sys/arch/arm/pci/pci_msi_machdep.c        Wed Oct 31 15:42:17 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_msi_machdep.c,v 1.1 2018/10/21 00:42:06 jmcneill Exp $ */
+/* $NetBSD: pci_msi_machdep.c,v 1.2 2018/10/31 15:42:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.1 2018/10/21 00:42:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.2 2018/10/31 15:42:17 jmcneill Exp $");
 
 #include <sys/kernel.h>
 #include <sys/kmem.h>
@@ -81,6 +81,28 @@
        return 0;
 }
 
+static int
+arm_pci_msix_alloc_common(pci_intr_handle_t **ihps, u_int *table_indexes, int *count, const struct pci_attach_args *pa, bool exact)
+{
+       pci_intr_handle_t *vectors;
+       struct arm_pci_msi *msi;
+
+       if ((pa->pa_flags & PCI_FLAGS_MSIX_OKAY) == 0)
+               return ENODEV;
+
+       msi = SIMPLEQ_FIRST(&arm_pci_msi_list);         /* XXX multiple frame support */
+       if (msi == NULL || msi->msix_alloc == NULL)
+               return EINVAL;
+
+       vectors = msi->msix_alloc(msi, table_indexes, count, pa, exact);
+       if (vectors == NULL)
+               return ENOMEM;
+
+       *ihps = vectors;
+
+       return 0;
+}
+
 /*
  * arm_pci_msi MD API
  */
@@ -125,19 +147,19 @@
 int
 pci_msix_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, int *count)
 {
-       return EOPNOTSUPP;
+       return arm_pci_msix_alloc_common(ihps, NULL, count, pa, false);
 }
 
 int
 pci_msix_alloc_exact(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, int count)
 {
-       return EOPNOTSUPP;
+       return arm_pci_msix_alloc_common(ihps, NULL, &count, pa, true);
 }
 
 int
 pci_msix_alloc_map(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, u_int *table_indexes, int count)
 {
-       return EOPNOTSUPP;
+       return arm_pci_msix_alloc_common(ihps, table_indexes, &count, pa, true);
 }
 
 int
diff -r db4fb49e1a69 -r 1f5ed447d281 sys/arch/arm/pci/pci_msi_machdep.h
--- a/sys/arch/arm/pci/pci_msi_machdep.h        Wed Oct 31 14:15:12 2018 +0000
+++ b/sys/arch/arm/pci/pci_msi_machdep.h        Wed Oct 31 15:42:17 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_msi_machdep.h,v 1.1 2018/10/21 00:42:06 jmcneill Exp $ */
+/* $NetBSD: pci_msi_machdep.h,v 1.2 2018/10/31 15:42:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -42,6 +42,7 @@
        void *                  msi_priv;
 
        pci_intr_handle_t *     (*msi_alloc)(struct arm_pci_msi *, int *, const struct pci_attach_args *, bool);
+       pci_intr_handle_t *     (*msix_alloc)(struct arm_pci_msi *, u_int *, int *, const struct pci_attach_args *, bool);
        void *                  (*msi_intr_establish)(struct arm_pci_msi *,
                                    pci_intr_handle_t, int, int (*)(void *), void *);
        void                    (*msi_intr_release)(struct arm_pci_msi *,



Home | Main Index | Thread Index | Old Index