Source-Changes-HG archive

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

[src/netbsd-9]: src Pull up following revision(s) (requested by msaitoh in ti...



details:   https://anonhg.NetBSD.org/src/rev/7110a6ff4999
branches:  netbsd-9
changeset: 462322:7110a6ff4999
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Aug 09 16:06:39 2019 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #37):

        doc/3RDPARTY: revision 1.1641
        sys/dev/pci/if_ena.c: revision 1.16
        sys/arch/amd64/conf/GENERIC: revision 1.532

If the memory space's BAR and the MSI-X table is on the same BAR,
reserve the space. Almost the same as nvme_pci.c and xhci_pci.c.
Tested by ryoon@.

Add ena(4).

diffstat:

 doc/3RDPARTY                |  15 ++++++++++-
 sys/arch/amd64/conf/GENERIC |   5 ++-
 sys/dev/pci/if_ena.c        |  62 +++++++++++++++++++++++++++++++++++++-------
 3 files changed, 69 insertions(+), 13 deletions(-)

diffs (138 lines):

diff -r 3255e92331e5 -r 7110a6ff4999 doc/3RDPARTY
--- a/doc/3RDPARTY      Fri Aug 09 16:03:13 2019 +0000
+++ b/doc/3RDPARTY      Fri Aug 09 16:06:39 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: 3RDPARTY,v 1.1640 2019/07/30 14:57:06 joerg Exp $
+#      $NetBSD: 3RDPARTY,v 1.1640.2.1 2019/08/09 16:06:39 martin Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -2109,6 +2109,7 @@
 Use groff2netbsd from external/gpl2/groff/groff2netbsd to prepare the
 distribution for import.
 Update MDATE in src/external/gpl2/groff/Makefile.inc.
+
 Package:       gmake
 Version:       3.81 (Last GPlv2+ version)
 Current Vers:  4.2
@@ -2174,3 +2175,15 @@
 Location:      usr.bin/indent
 Notes:
 Tests are stored in tests/usr.bin/indent.
+
+Package:       ena
+Version:       0.8.1
+Current Vers:  2.0.0
+Maintainer:    Amazon.com
+Archive Site:  https://github.com/amzn/amzn-drivers/tree/master/kernel/fbsd/ena
+Home Page:     https://github.com/amzn/amzn-drivers/
+Mailing List:  none
+Responsible:
+License:       BSD-like (2 and 3-clause)
+Location:      sys/external/bsd/ena-com
+Notes:
diff -r 3255e92331e5 -r 7110a6ff4999 sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Fri Aug 09 16:03:13 2019 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Fri Aug 09 16:06:39 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.531.2.1 2019/08/09 15:59:52 martin Exp $
+# $NetBSD: GENERIC,v 1.531.2.2 2019/08/09 16:06:39 martin Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident         "GENERIC-$Revision: 1.531.2.1 $"
+#ident         "GENERIC-$Revision: 1.531.2.2 $"
 
 maxusers       64              # estimated number of users
 
@@ -771,6 +771,7 @@
 bwi*   at pci? dev ? function ?        # Broadcom BCM43xx wireless
 bwfm*  at pci? dev ? function ?        # Broadcom FullMAC
 dge*   at pci? dev ? function ?        # Intel 82597 10GbE LR
+ena*   at pci? dev ? function ?        # Amazon.com Elastic Network Adapter
 ep*    at pci? dev ? function ?        # 3Com 3c59x
 epic*  at pci? dev ? function ?        # SMC EPIC/100 Ethernet
 esh*   at pci? dev ? function ?        # Essential HIPPI card
diff -r 3255e92331e5 -r 7110a6ff4999 sys/dev/pci/if_ena.c
--- a/sys/dev/pci/if_ena.c      Fri Aug 09 16:03:13 2019 +0000
+++ b/sys/dev/pci/if_ena.c      Fri Aug 09 16:06:39 2019 +0000
@@ -31,7 +31,7 @@
 #if 0
 __FBSDID("$FreeBSD: head/sys/dev/ena/ena.c 333456 2018-05-10 09:37:54Z mw $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.15 2019/05/29 10:07:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ena.c,v 1.15.2.1 2019/08/09 16:06:39 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -273,15 +273,57 @@
 ena_allocate_pci_resources(struct pci_attach_args *pa,
     struct ena_adapter *adapter)
 {
-       bus_size_t size;
-
-       /*
-        * Map control/status registers.
-       */
-       pcireg_t memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, ENA_REG_BAR);
-       if (pci_mapreg_map(pa, ENA_REG_BAR, memtype, 0, &adapter->sc_btag,
-           &adapter->sc_bhandle, NULL, &size)) {
-               aprint_error(": can't map mem space\n");
+       pcireg_t memtype, reg;
+       bus_addr_t memaddr;
+       bus_size_t mapsize;
+       int flags, error;
+       int msixoff;
+
+       memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, ENA_REG_BAR);
+       if (PCI_MAPREG_TYPE(memtype) != PCI_MAPREG_TYPE_MEM) {
+               aprint_error_dev(adapter->pdev, "invalid type (type=0x%x)\n",
+                   memtype);
+               return ENXIO;
+       }
+       reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
+       if (((reg & PCI_COMMAND_MASTER_ENABLE) == 0) ||
+           ((reg & PCI_COMMAND_MEM_ENABLE) == 0)) {
+               /*
+                * Enable address decoding for memory range in case BIOS or
+                * UEFI didn't set it.
+                */
+               reg |= PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_MEM_ENABLE;
+               pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
+                   reg);
+       }
+
+       adapter->sc_btag = pa->pa_memt;
+       error = pci_mapreg_info(pa->pa_pc, pa->pa_tag, ENA_REG_BAR,
+           memtype, &memaddr, &mapsize, &flags);
+       if (error) {
+               aprint_error_dev(adapter->pdev, "can't get map info\n");
+               return ENXIO;
+       }
+
+       if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_MSIX, &msixoff,
+           NULL)) {
+               pcireg_t msixtbl;
+               uint32_t table_offset;
+               int bir;
+
+               msixtbl = pci_conf_read(pa->pa_pc, pa->pa_tag,
+                   msixoff + PCI_MSIX_TBLOFFSET);
+               table_offset = msixtbl & PCI_MSIX_TBLOFFSET_MASK;
+               bir = msixtbl & PCI_MSIX_PBABIR_MASK;
+               if (bir == PCI_MAPREG_NUM(ENA_REG_BAR))
+                       mapsize = table_offset;
+       }
+
+       error = bus_space_map(adapter->sc_btag, memaddr, mapsize, flags,
+           &adapter->sc_bhandle);
+       if (error != 0) {
+               aprint_error_dev(adapter->pdev,
+                   "can't map mem space (error=%d)\n", error);
                return ENXIO;
        }
 



Home | Main Index | Thread Index | Old Index