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/466391f7adf3
branches:  netbsd-9
changeset: 963515:466391f7adf3
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jan 21 11:55:57 2020 +0000

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

        sys/arch/amd64/conf/GENERIC: revision 1.552
        sys/dev/pci/if_casreg.h: revision 1.2
        sys/dev/pci/if_cas.c: revision 1.37
        share/man/man4/cas.4: revision 1.4
        sys/dev/pci/if_casvar.h: revision 1.7

 Update supported device list with part number. From FreeBSD.

 Fix a bug that the driver sometimes incorrectly attach gentbi(4) instead of
gphyter(4) on non-fiber device.

Tested with Sun Quad GigaSwift Ethernet UTP (QGE) (part no. 501-6522) on
amd64. On this environment, the problem frequently had occurred. I also
tested with other 4 cas(4) variants.

 Add cas(4).

diffstat:

 share/man/man4/cas.4        |   21 +++-
 sys/arch/amd64/conf/GENERIC |    5 +-
 sys/dev/pci/if_cas.c        |  173 ++++++++++++++++++++++++++++++++++---------
 sys/dev/pci/if_casreg.h     |   15 +++-
 sys/dev/pci/if_casvar.h     |   13 +++-
 5 files changed, 178 insertions(+), 49 deletions(-)

diffs (truncated from 422 to 300 lines):

diff -r 47be2e57825a -r 466391f7adf3 share/man/man4/cas.4
--- a/share/man/man4/cas.4      Tue Jan 21 11:43:27 2020 +0000
+++ b/share/man/man4/cas.4      Tue Jan 21 11:55:57 2020 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: cas.4,v 1.3 2010/01/15 19:24:49 joerg Exp $
+.\" $NetBSD: cas.4,v 1.3.50.1 2020/01/21 11:55:58 martin Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd January 7, 2010
+.Dd December 25, 2019
 .Dt CAS 4
 .Os
 .Sh NAME
@@ -44,13 +44,22 @@
 and Sun GigaSwift PCI cards.
 .Pp
 Cards supported by this driver include:
-.Bl -bullet -compact -offset indent
+.Bl -bullet -compact
 .It
-Sun Gigaswift Ethernet (SX fibre variants)
+Sun GigaSwift Ethernet 1.0 MMF (Cassini Kuheen)
+(part no.\& 501-5524)
+.It
+Sun GigaSwift Ethernet 1.0 UTP (Cassini)
+(part no.\& 501-5902)
 .It
-Sun Gigaswift Ethernet (UTP variants)
+Sun GigaSwift Ethernet UTP (GCS)
+(part no.\& 501-6719)
 .It
-Sun quad Gigaswift Ethernet
+Sun Quad GigaSwift Ethernet UTP (QGE)
+(part no.\& 501-6522)
+.It
+Sun Quad GigaSwift Ethernet PCI-X (QGE-X)
+(part no.\& 501-6738)
 .El
 .Sh SEE ALSO
 .Xr brgphy 4 ,
diff -r 47be2e57825a -r 466391f7adf3 sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Tue Jan 21 11:43:27 2020 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Tue Jan 21 11:55:57 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.531.2.6 2019/11/25 20:47:24 martin Exp $
+# $NetBSD: GENERIC,v 1.531.2.7 2020/01/21 11:55:57 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.6 $"
+#ident         "GENERIC-$Revision: 1.531.2.7 $"
 
 maxusers       64              # estimated number of users
 
@@ -770,6 +770,7 @@
 bnx*   at pci? dev ? function ?        # Broadcom NetXtremeII gigabit Ethernet
 bwi*   at pci? dev ? function ?        # Broadcom BCM43xx wireless
 bwfm*  at pci? dev ? function ?        # Broadcom FullMAC
+cas*   at pci? dev ? function ?        # Sun Cassini/Cassini+ Ethernet
 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
diff -r 47be2e57825a -r 466391f7adf3 sys/dev/pci/if_cas.c
--- a/sys/dev/pci/if_cas.c      Tue Jan 21 11:43:27 2020 +0000
+++ b/sys/dev/pci/if_cas.c      Tue Jan 21 11:55:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cas.c,v 1.35.2.1 2019/11/26 08:20:47 martin Exp $   */
+/*     $NetBSD: if_cas.c,v 1.35.2.2 2020/01/21 11:55:58 martin Exp $   */
 /*     $OpenBSD: if_cas.c,v 1.29 2009/11/29 16:19:38 kettenis Exp $    */
 
 /*
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.35.2.1 2019/11/26 08:20:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cas.c,v 1.35.2.2 2020/01/21 11:55:58 martin Exp $");
 
 #ifndef _MODULE
 #include "opt_inet.h"
@@ -114,7 +114,7 @@
     cas_match, cas_attach, cas_detach, NULL, NULL, NULL,
     DVF_DETACH_SHUTDOWN);
 
-int    cas_pci_enaddr(struct cas_softc *, struct pci_attach_args *, uint8_t *);
+int    cas_pci_readvpd(struct cas_softc *, struct pci_attach_args *, uint8_t *);
 
 void           cas_config(struct cas_softc *, const uint8_t *);
 void           cas_start(struct ifnet *);
@@ -163,18 +163,32 @@
 #define        DPRINTF(sc, x)  /* nothing */
 #endif
 
+static const struct cas_pci_dev {
+       uint16_t cpd_vendor;
+       uint16_t cpd_device;
+       int cpd_variant;
+} cas_pci_devlist[] = {
+       { PCI_VENDOR_SUN, PCI_PRODUCT_SUN_CASSINI, CAS_CAS },
+       { PCI_VENDOR_NS, PCI_PRODUCT_NS_SATURN, CAS_SATURN },
+       { 0, 0, 0 }
+};
+
+#define        CAS_LOCAL_MAC_ADDRESS   "local-mac-address"
+#define        CAS_PHY_INTERFACE       "phy-interface"
+#define        CAS_PHY_TYPE            "phy-type"
+#define        CAS_PHY_TYPE_PCS        "pcs"
+
 int
 cas_match(device_t parent, cfdata_t cf, void *aux)
 {
        struct pci_attach_args *pa = aux;
+       int i;
 
-       if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN &&
-           (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_SUN_CASSINI))
-               return 1;
-
-       if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NS &&
-           (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NS_SATURN))
-               return 1;
+       for (i = 0; cas_pci_devlist[i].cpd_vendor != 0; i++) {
+               if ((PCI_VENDOR(pa->pa_id) == cas_pci_devlist[i].cpd_vendor) &&
+                   (PCI_PRODUCT(pa->pa_id) == cas_pci_devlist[i].cpd_device))
+                       return 1;
+       }
 
        return 0;
 }
@@ -205,7 +219,7 @@
 
 #define CAS_LMA_MAXNUM 4
 int
-cas_pci_enaddr(struct cas_softc *sc, struct pci_attach_args *pa,
+cas_pci_readvpd(struct cas_softc *sc, struct pci_attach_args *pa,
     uint8_t *enaddr)
 {
        struct pci_vpd_largeres *res;
@@ -214,9 +228,10 @@
        bus_space_tag_t romt;
        bus_size_t romsize = 0;
        uint8_t enaddrs[CAS_LMA_MAXNUM][ETHER_ADDR_LEN];
+       bool pcs[4] = {false, false, false, false};
        uint8_t buf[32], *desc;
        pcireg_t address;
-       int dataoff, vpdoff, len, lma = 0;
+       int dataoff, vpdoff, len, lma = 0, phy = 0;
        int i, rv = -1;
 
        if (pci_mapreg_map(pa, PCI_MAPREG_ROM, PCI_MAPREG_TYPE_MEM, 0,
@@ -261,6 +276,20 @@
                goto next;
 
        case PCI_VPDRES_TYPE_VPD:
+#ifdef CAS_DEBUG
+       printf("\n");
+       for (i = 0; i < len; i++) {
+               uint8_t byte;
+               if (i % 16 == 0)
+                       printf("%04x :", i);
+               byte = bus_space_read_1(romt, romh, vpdoff + i);
+               printf(" %02x", byte);
+               if (i % 16 == 15)
+                       printf("\n");
+       }
+       printf("\n");
+#endif
+
                while (len > 0) {
                        bus_space_read_region_1(romt, romh, vpdoff,
                             buf, sizeof(buf));
@@ -284,26 +313,57 @@
                                continue;
                        desc += 3;
 
-                       /*
-                        * ...that's a byte array with the proper
-                        * length for a MAC address...
-                        */
-                       if (desc[0] != 'B' || desc[1] != ETHER_ADDR_LEN)
+                       if (desc[0] == 'B' || desc[1] == ETHER_ADDR_LEN) {
+                               /*
+                                * ...that's a byte array with the proper
+                                * length for a MAC address...
+                                */
+                               desc += 2;
+
+                               /*
+                                * ...named "local-mac-address".
+                                */
+                               if (strcmp(desc, CAS_LOCAL_MAC_ADDRESS) != 0)
+                                       continue;
+                               desc += sizeof(CAS_LOCAL_MAC_ADDRESS);
+
+                               if (lma == CAS_LMA_MAXNUM)
+                                       continue;
+
+                               memcpy(enaddrs[lma], desc, ETHER_ADDR_LEN);
+                               lma++;
+                               rv = 0;
                                continue;
-                       desc += 2;
+                       } else if (desc[0] == 'S') {
+                               size_t k;
 
-                       /*
-                        * ...named "local-mac-address".
-                        */
-                       if (strcmp(desc, "local-mac-address") != 0)
+                               /* String */
+                               desc += 2;
+#ifdef CAS_DEBUG
+                               /* ...named "pcs". */
+                               printf("STR: \"%s\"\n", desc);
+                               if (strcmp(desc, CAS_PHY_TYPE_PCS) != 0)
+                                       continue;
+                               desc += sizeof(CAS_PHY_TYPE_PCS);
+                               printf("STR: \"%s\"\n", desc);
+#endif
+                               /* ...named "phy-interface" or "phy-type". */
+                               if (strcmp(desc, CAS_PHY_INTERFACE) == 0)
+                                       k = sizeof(CAS_PHY_INTERFACE);
+                               else if (strcmp(desc, CAS_PHY_TYPE) == 0)
+                                       k = sizeof(CAS_PHY_TYPE);
+                               else
+                                       continue;
+
+                               desc += k;
+#ifdef CAS_DEBUG
+                               printf("STR: \"%s\"\n", desc);
+#endif
+                               if (strcmp(desc, CAS_PHY_TYPE_PCS) == 0)
+                                       pcs[phy] = true;
+                               phy++;
                                continue;
-                       desc += strlen("local-mac-address") + 1;
-
-                       memcpy(enaddrs[lma], desc, ETHER_ADDR_LEN);
-                       lma++;
-                       rv = 0;
-                       if (lma == CAS_LMA_MAXNUM)
-                               break;
+                       }
                }
                break;
 
@@ -311,7 +371,6 @@
                goto fail;
        }
 
-       i = 0;
        /*
         * Multi port card has bridge chip. The device number is fixed:
         * e.g.
@@ -320,10 +379,15 @@
         * p2: 006:02:0
         * p3: 006:03:0
         */
-       if ((lma > 1) && (pa->pa_device < CAS_LMA_MAXNUM)
-           && (pa->pa_device < lma))
-               i = pa->pa_device;
-       memcpy(enaddr, enaddrs[i], ETHER_ADDR_LEN);
+       if (enaddr != 0) {
+               i = 0;
+               if ((lma > 1) && (pa->pa_device < CAS_LMA_MAXNUM)
+                   && (pa->pa_device < lma))
+                       i = pa->pa_device;
+               memcpy(enaddr, enaddrs[i], ETHER_ADDR_LEN);
+       }
+       if (pcs[pa->pa_device])
+               sc->sc_flags |= CAS_SERDES;
  fail:
        if (romsize != 0)
                bus_space_unmap(romt, romh, romsize);
@@ -340,6 +404,7 @@
 {
        struct pci_attach_args *pa = aux;
        struct cas_softc *sc = device_private(self);
+       int i;
        prop_data_t data;
        uint8_t enaddr[ETHER_ADDR_LEN];
 
@@ -348,6 +413,20 @@
        sc->sc_rev = PCI_REVISION(pa->pa_class);
        sc->sc_dmatag = pa->pa_dmat;
 
+       sc->sc_variant = CAS_UNKNOWN;
+       for (i = 0; cas_pci_devlist[i].cpd_vendor != 0; i++) {
+               if ((PCI_VENDOR(pa->pa_id) == cas_pci_devlist[i].cpd_vendor) &&
+                   (PCI_PRODUCT(pa->pa_id) == cas_pci_devlist[i].cpd_device)) {
+                       sc->sc_variant = cas_pci_devlist[i].cpd_variant;



Home | Main Index | Thread Index | Old Index