Author: arybchik
Date: Tue Nov 27 12:59:43 2018
New Revision: 341046
URL: https://svnweb.freebsd.org/changeset/base/341046

Log:
  sfxge(4): report memory BAR number
  
  Remove EFX_MEM_BAR define as it it is not correct on all platforms.
  
  Submitted by:   Andy Moreton <amoreton at solarflare.com>
  Sponsored by:   Solarflare Communications, Inc.
  Differential Revision:  https://reviews.freebsd.org/D18165

Modified:
  head/sys/dev/sfxge/common/efx.h
  head/sys/dev/sfxge/common/efx_nic.c
  head/sys/dev/sfxge/sfxge.c
  head/sys/dev/sfxge/sfxge.h

Modified: head/sys/dev/sfxge/common/efx.h
==============================================================================
--- head/sys/dev/sfxge/common/efx.h     Tue Nov 27 12:59:32 2018        
(r341045)
+++ head/sys/dev/sfxge/common/efx.h     Tue Nov 27 12:59:43 2018        
(r341046)
@@ -76,7 +76,8 @@ extern        __checkReturn   efx_rc_t
 efx_family(
        __in            uint16_t venid,
        __in            uint16_t devid,
-       __out           efx_family_t *efp);
+       __out           efx_family_t *efp,
+       __out           unsigned int *membarp);
 
 
 #define        EFX_PCI_VENID_SFC                       0x1924
@@ -102,7 +103,17 @@ efx_family(
 #define        EFX_PCI_DEVID_MEDFORD2                  0x0B03  /* SFC9250 PF */
 #define        EFX_PCI_DEVID_MEDFORD2_VF               0x1B03  /* SFC9250 VF */
 
-#define        EFX_MEM_BAR     2
+
+#define        EFX_MEM_BAR_SIENA                       2
+
+#define        EFX_MEM_BAR_HUNTINGTON_PF               2
+#define        EFX_MEM_BAR_HUNTINGTON_VF               0
+
+#define        EFX_MEM_BAR_MEDFORD_PF                  2
+#define        EFX_MEM_BAR_MEDFORD_VF                  0
+
+#define        EFX_MEM_BAR_MEDFORD2                    0
+
 
 /* Error codes */
 

Modified: head/sys/dev/sfxge/common/efx_nic.c
==============================================================================
--- head/sys/dev/sfxge/common/efx_nic.c Tue Nov 27 12:59:32 2018        
(r341045)
+++ head/sys/dev/sfxge/common/efx_nic.c Tue Nov 27 12:59:43 2018        
(r341046)
@@ -36,11 +36,13 @@ __FBSDID("$FreeBSD$");
 #include "efx.h"
 #include "efx_impl.h"
 
+
        __checkReturn   efx_rc_t
 efx_family(
        __in            uint16_t venid,
        __in            uint16_t devid,
-       __out           efx_family_t *efp)
+       __out           efx_family_t *efp,
+       __out           unsigned int *membarp)
 {
        if (venid == EFX_PCI_VENID_SFC) {
                switch (devid) {
@@ -50,12 +52,10 @@ efx_family(
                         * Hardware default for PF0 of uninitialised Siena.
                         * manftest must be able to cope with this device id.
                         */
-                       *efp = EFX_FAMILY_SIENA;
-                       return (0);
-
                case EFX_PCI_DEVID_BETHPAGE:
                case EFX_PCI_DEVID_SIENA:
                        *efp = EFX_FAMILY_SIENA;
+                       *membarp = EFX_MEM_BAR_SIENA;
                        return (0);
 #endif /* EFSYS_OPT_SIENA */
 
@@ -65,17 +65,16 @@ efx_family(
                         * Hardware default for PF0 of uninitialised Huntington.
                         * manftest must be able to cope with this device id.
                         */
-                       *efp = EFX_FAMILY_HUNTINGTON;
-                       return (0);
-
                case EFX_PCI_DEVID_FARMINGDALE:
                case EFX_PCI_DEVID_GREENPORT:
                        *efp = EFX_FAMILY_HUNTINGTON;
+                       *membarp = EFX_MEM_BAR_HUNTINGTON_PF;
                        return (0);
 
                case EFX_PCI_DEVID_FARMINGDALE_VF:
                case EFX_PCI_DEVID_GREENPORT_VF:
                        *efp = EFX_FAMILY_HUNTINGTON;
+                       *membarp = EFX_MEM_BAR_HUNTINGTON_VF;
                        return (0);
 #endif /* EFSYS_OPT_HUNTINGTON */
 
@@ -85,15 +84,14 @@ efx_family(
                         * Hardware default for PF0 of uninitialised Medford.
                         * manftest must be able to cope with this device id.
                         */
-                       *efp = EFX_FAMILY_MEDFORD;
-                       return (0);
-
                case EFX_PCI_DEVID_MEDFORD:
                        *efp = EFX_FAMILY_MEDFORD;
+                       *membarp = EFX_MEM_BAR_MEDFORD_PF;
                        return (0);
 
                case EFX_PCI_DEVID_MEDFORD_VF:
                        *efp = EFX_FAMILY_MEDFORD;
+                       *membarp = EFX_MEM_BAR_MEDFORD_VF;
                        return (0);
 #endif /* EFSYS_OPT_MEDFORD */
 
@@ -103,15 +101,10 @@ efx_family(
                         * Hardware default for PF0 of uninitialised Medford2.
                         * manftest must be able to cope with this device id.
                         */
-                       *efp = EFX_FAMILY_MEDFORD2;
-                       return (0);
-
                case EFX_PCI_DEVID_MEDFORD2:
-                       *efp = EFX_FAMILY_MEDFORD2;
-                       return (0);
-
                case EFX_PCI_DEVID_MEDFORD2_VF:
                        *efp = EFX_FAMILY_MEDFORD2;
+                       *membarp = EFX_MEM_BAR_MEDFORD2;
                        return (0);
 #endif /* EFSYS_OPT_MEDFORD2 */
 
@@ -124,6 +117,7 @@ efx_family(
        *efp = EFX_FAMILY_INVALID;
        return (ENOTSUP);
 }
+
 
 #if EFSYS_OPT_SIENA
 

Modified: head/sys/dev/sfxge/sfxge.c
==============================================================================
--- head/sys/dev/sfxge/sfxge.c  Tue Nov 27 12:59:32 2018        (r341045)
+++ head/sys/dev/sfxge/sfxge.c  Tue Nov 27 12:59:43 2018        (r341046)
@@ -651,11 +651,11 @@ sfxge_bar_init(struct sfxge_softc *sc)
 {
        efsys_bar_t *esbp = &sc->bar;
 
-       esbp->esb_rid = PCIR_BAR(EFX_MEM_BAR);
+       esbp->esb_rid = PCIR_BAR(sc->mem_bar);
        if ((esbp->esb_res = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY,
            &esbp->esb_rid, RF_ACTIVE)) == NULL) {
                device_printf(sc->dev, "Cannot allocate BAR region %d\n",
-                   EFX_MEM_BAR);
+                   sc->mem_bar);
                return (ENXIO);
        }
        esbp->esb_tag = rman_get_bustag(esbp->esb_res);
@@ -722,15 +722,15 @@ sfxge_create(struct sfxge_softc *sc)
        if ((error = sfxge_dma_init(sc)) != 0)
                goto fail;
 
+       error = efx_family(pci_get_vendor(dev), pci_get_device(dev),
+           &sc->family, &sc->mem_bar);
+       KASSERT(error == 0, ("Family should be filtered by sfxge_probe()"));
+
        /* Map the device registers. */
        DBGPRINT(sc->dev, "bar_init...");
        if ((error = sfxge_bar_init(sc)) != 0)
                goto fail;
 
-       error = efx_family(pci_get_vendor(dev), pci_get_device(dev),
-           &sc->family);
-       KASSERT(error == 0, ("Family should be filtered by sfxge_probe()"));
-
        DBGPRINT(sc->dev, "nic_create...");
 
        /* Create the common code nic object. */
@@ -1154,13 +1154,14 @@ sfxge_probe(device_t dev)
        uint16_t pci_vendor_id;
        uint16_t pci_device_id;
        efx_family_t family;
+       unsigned int mem_bar;
        int rc;
 
        pci_vendor_id = pci_get_vendor(dev);
        pci_device_id = pci_get_device(dev);
 
        DBGPRINT(dev, "PCI ID %04x:%04x", pci_vendor_id, pci_device_id);
-       rc = efx_family(pci_vendor_id, pci_device_id, &family);
+       rc = efx_family(pci_vendor_id, pci_device_id, &family, &mem_bar);
        if (rc != 0) {
                DBGPRINT(dev, "efx_family fail %d", rc);
                return (ENXIO);

Modified: head/sys/dev/sfxge/sfxge.h
==============================================================================
--- head/sys/dev/sfxge/sfxge.h  Tue Nov 27 12:59:32 2018        (r341045)
+++ head/sys/dev/sfxge/sfxge.h  Tue Nov 27 12:59:43 2018        (r341046)
@@ -280,6 +280,8 @@ struct sfxge_softc {
        struct task                     task_reset;
 
        efx_family_t                    family;
+       unsigned int                    mem_bar;
+
        caddr_t                         vpd_data;
        size_t                          vpd_size;
        efx_nic_t                       *enp;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to