From owner-freebsd-net@FreeBSD.ORG Tue Apr 19 22:10:00 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B37F106564A for ; Tue, 19 Apr 2011 22:10:00 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-pv0-f182.google.com (mail-pv0-f182.google.com [74.125.83.182]) by mx1.freebsd.org (Postfix) with ESMTP id CE14F8FC16 for ; Tue, 19 Apr 2011 22:09:59 +0000 (UTC) Received: by pvg11 with SMTP id 11so94249pvg.13 for ; Tue, 19 Apr 2011 15:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:date:to:cc:subject:message-id:reply-to :references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=du4p4AkoKizRbgY1X3W3xM99OLdbQ0+isR8OAZp/NOg=; b=jCpj1DkGn2WZHc4Fpe0cqvU/BSH3r+u6xLLfekVwnX11Y23dKnRx6P13nhsJUBA15y XnhqJYWXHtoZwezVz6x9UX7rdQQ0DNTRU2/QJq8OuITpFqqZoI5ykVzJqKSzOOZY3usI IiemPud7KJqgQvEks3EuowSBuEbmUPal3EG90= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=XRFHnWFN8LKhoYJqrRRBlTPDR2uI8AxW3Tl7HChA4/mIc99f+IRhI36fpvKZx61L5A 85TrPXsYjuIEIOZyxE2in+XRNv0BimPV3I4ZNaSTIXloabBWsSkyu+/xzcWdqzv7uXRM Fec02zSLA+QhqzvLo4/9Gnhku65PzeqRKTGxI= Received: by 10.68.47.225 with SMTP id g1mr6008101pbn.17.1303250999412; Tue, 19 Apr 2011 15:09:59 -0700 (PDT) Received: from pyunyh@gmail.com ([174.35.1.224]) by mx.google.com with ESMTPS id a4sm192446pbf.56.2011.04.19.15.09.56 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 19 Apr 2011 15:09:58 -0700 (PDT) Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Tue, 19 Apr 2011 15:09:07 -0700 From: YongHyeon PYUN Date: Tue, 19 Apr 2011 15:09:07 -0700 To: Paul Thornton Message-ID: <20110419220907.GD1637@michelle.cdnetworks.com> References: <4DADD913.5010208@prt.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="EeQfGwPcQSOJBaQU" Content-Disposition: inline In-Reply-To: <4DADD913.5010208@prt.org> User-Agent: Mutt/1.4.2.3i Cc: freebsd-net@freebsd.org Subject: Re: Broadcom BCM57765 support? X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: pyunyh@gmail.com List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Apr 2011 22:10:00 -0000 --EeQfGwPcQSOJBaQU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Apr 19, 2011 at 07:48:51PM +0100, Paul Thornton wrote: > Hi, > > The bge driver doesn't support this chipset yet and I was wondering if > anyone has looked at implementing it. > > NetBSD looks like it has support for it. Now I may be wrong here, but > it appears that the BCM57765 is similar to other devices based on the > NetBSD if_bge.c source version 1.194. > > I've tried applying the NetBSD changes to the FreeBSD bge source but I > don't know enough about the hardware and the code is different enough > that I haven't made it very far. I can get a patched 8.2 kernel to > detect the device, complain that the ASIC is unknown, read the MAC > address correctly and determine there is link but as soon as you attempt > to ifconfig up the interface the machine locks up. > > I'm happy to try and port this over but need a nudge in the right > direction from someone who knows the code. > Here is experimental patch for BCM57765 family controllers. I don't have these controllers so the patch was not tested at all except compile. Recent Broadcom controllers like BCM57765 support EEE(Energy Efficient Ethernet) feature but it is not yet supported by the patch. Also it would good to see the output of "pciconf -lcbv" and dmesg after applying the patch. --EeQfGwPcQSOJBaQU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="bge.57765.diff" Index: sys/dev/bge/if_bgereg.h =================================================================== --- sys/dev/bge/if_bgereg.h (revision 220872) +++ sys/dev/bge/if_bgereg.h (working copy) @@ -223,6 +223,7 @@ #define BGE_PCI_ISR_MBX_LO 0xB4 #define BGE_PCI_PRODID_ASICREV 0xBC #define BGE_PCI_GEN2_PRODID_ASICREV 0xF4 +#define BGE_PCI_GEN15_PRODID_ASICREV 0xFC /* PCI Misc. Host control register */ #define BGE_PCIMISCCTL_CLEAR_INTA 0x00000001 @@ -318,6 +319,7 @@ #define BGE_CHIPID_BCM57780_A1 0x57780001 #define BGE_CHIPID_BCM5717_A0 0x05717000 #define BGE_CHIPID_BCM5717_B0 0x05717100 +#define BGE_CHIPID_BCM57765_A0 0x57785000 /* shorthand one */ #define BGE_ASICREV(x) ((x) >> 12) @@ -342,6 +344,7 @@ #define BGE_ASICREV_BCM5761 0x5761 #define BGE_ASICREV_BCM5784 0x5784 #define BGE_ASICREV_BCM5785 0x5785 +#define BGE_ASICREV_BCM57765 0x57785 #define BGE_ASICREV_BCM57780 0x57780 /* chip revisions */ @@ -381,6 +384,8 @@ #define BGE_PCIDMARWCTL_RD_CMD_SHIFT(x) ((x) << 24) #define BGE_PCIDMARWCTL_WR_CMD_SHIFT(x) ((x) << 28) +#define BGE_PCIDMARWCTL_CRDRDR_RDMA_MRRS_MSK 0x00000380 + #define BGE_PCI_READ_BNDRY_DISABLE 0x00000000 #define BGE_PCI_READ_BNDRY_16BYTES 0x00000100 #define BGE_PCI_READ_BNDRY_32BYTES 0x00000200 @@ -2298,9 +2303,15 @@ #define BCOM_DEVICEID_BCM5906 0x1712 #define BCOM_DEVICEID_BCM5906M 0x1713 #define BCOM_DEVICEID_BCM57760 0x1690 +#define BCOM_DEVICEID_BCM57761 0x16B0 +#define BCOM_DEVICEID_BCM57765 0x16B4 #define BCOM_DEVICEID_BCM57780 0x1692 +#define BCOM_DEVICEID_BCM57781 0x16B1 +#define BCOM_DEVICEID_BCM57785 0x16B5 #define BCOM_DEVICEID_BCM57788 0x1691 #define BCOM_DEVICEID_BCM57790 0x1694 +#define BCOM_DEVICEID_BCM57791 0x16B2 +#define BCOM_DEVICEID_BCM57795 0x16B6 /* * Alteon AceNIC PCI vendor/device ID. Index: sys/dev/bge/if_bge.c =================================================================== --- sys/dev/bge/if_bge.c (revision 220872) +++ sys/dev/bge/if_bge.c (working copy) @@ -214,9 +214,15 @@ { BCOM_VENDORID, BCOM_DEVICEID_BCM5906 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM5906M }, { BCOM_VENDORID, BCOM_DEVICEID_BCM57760 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM57761 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM57765 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM57780 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM57781 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM57785 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM57788 }, { BCOM_VENDORID, BCOM_DEVICEID_BCM57790 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM57791 }, + { BCOM_VENDORID, BCOM_DEVICEID_BCM57795 }, { SK_VENDORID, SK_DEVICEID_ALTIMA }, @@ -335,6 +341,7 @@ /* 5754 and 5787 share the same ASIC ID */ { BGE_ASICREV_BCM5787, "unknown BCM5754/5787" }, { BGE_ASICREV_BCM5906, "unknown BCM5906" }, + { BGE_ASICREV_BCM57765, "unknown BCM57765" }, { BGE_ASICREV_BCM57780, "unknown BCM57780" }, { BGE_ASICREV_BCM5717, "unknown BCM5717" }, @@ -1467,8 +1474,11 @@ if (sc->bge_asicrev == BGE_ASICREV_BCM5703 || sc->bge_asicrev == BGE_ASICREV_BCM5704) dma_rw_ctl &= ~BGE_PCIDMARWCTL_MINDMA; - if (BGE_IS_5717_PLUS(sc)) + if (BGE_IS_5717_PLUS(sc)) { dma_rw_ctl &= ~BGE_PCIDMARWCTL_DIS_CACHE_ALIGNMENT; + if (sc->bge_chipid == BGE_CHIPID_BCM57765_A0) + dma_rw_ctl &= ~BGE_PCIDMARWCTL_CRDRDR_RDMA_MRRS_MSK; + } pci_write_config(sc->bge_dev, BGE_PCI_DMA_RW_CTL, dma_rw_ctl, 4); /* @@ -1552,7 +1562,8 @@ } /* Configure mbuf pool watermarks */ - if (sc->bge_asicrev == BGE_ASICREV_BCM5717) { + if (sc->bge_asicrev == BGE_ASICREV_BCM5717 || + sc->bge_asicrev == BGE_ASICREV_BCM57765) { CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_READDMA_LOWAT, 0x0); if (sc->bge_ifp->if_mtu > ETHERMTU) { CSR_WRITE_4(sc, BGE_BMAN_MBUFPOOL_MACRX_LOWAT, 0x7e); @@ -1819,7 +1830,8 @@ limit = 16; } else if (!BGE_IS_5705_PLUS(sc)) limit = BGE_RX_RINGS_MAX; - else if (sc->bge_asicrev == BGE_ASICREV_BCM5755) + else if (sc->bge_asicrev == BGE_ASICREV_BCM5755 || + sc->bge_asicrev == BGE_ASICREV_BCM57765) limit = 4; else limit = 1; @@ -2180,6 +2192,15 @@ id = pci_read_config(dev, BGE_PCI_GEN2_PRODID_ASICREV, 4); break; + case BCOM_DEVICEID_BCM57761: + case BCOM_DEVICEID_BCM57765: + case BCOM_DEVICEID_BCM57781: + case BCOM_DEVICEID_BCM57785: + case BCOM_DEVICEID_BCM57791: + case BCOM_DEVICEID_BCM57795: + id = pci_read_config(dev, + BGE_PCI_GEN15_PRODID_ASICREV, 4); + break; default: id = pci_read_config(dev, BGE_PCI_PRODID_ASICREV, 4); @@ -2694,6 +2715,15 @@ sc->bge_chipid = pci_read_config(dev, BGE_PCI_GEN2_PRODID_ASICREV, 4); break; + case BCOM_DEVICEID_BCM57761: + case BCOM_DEVICEID_BCM57765: + case BCOM_DEVICEID_BCM57781: + case BCOM_DEVICEID_BCM57785: + case BCOM_DEVICEID_BCM57791: + case BCOM_DEVICEID_BCM57795: + sc->bge_chipid = pci_read_config(dev, + BGE_PCI_GEN15_PRODID_ASICREV, 4); + break; default: sc->bge_chipid = pci_read_config(dev, BGE_PCI_PRODID_ASICREV, 4); @@ -2750,9 +2780,11 @@ /* Save chipset family. */ switch (sc->bge_asicrev) { case BGE_ASICREV_BCM5717: + sc->bge_flags |= BGE_FLAG_SHORT_DMA_BUG; + case BGE_ASICREV_BCM57765: sc->bge_flags |= BGE_FLAG_5717_PLUS | BGE_FLAG_5755_PLUS | BGE_FLAG_575X_PLUS | BGE_FLAG_5705_PLUS | BGE_FLAG_JUMBO | - BGE_FLAG_SHORT_DMA_BUG | BGE_FLAG_JUMBO_FRAME; + BGE_FLAG_JUMBO_FRAME; break; case BGE_ASICREV_BCM5755: case BGE_ASICREV_BCM5761: @@ -2801,6 +2833,7 @@ sc->bge_asicrev != BGE_ASICREV_BCM5906 && sc->bge_asicrev != BGE_ASICREV_BCM5717 && sc->bge_asicrev != BGE_ASICREV_BCM5785 && + sc->bge_asicrev != BGE_ASICREV_BCM57765 && sc->bge_asicrev != BGE_ASICREV_BCM57780) { if (sc->bge_asicrev == BGE_ASICREV_BCM5755 || sc->bge_asicrev == BGE_ASICREV_BCM5761 || @@ -3466,6 +3499,9 @@ device_printf(dev, "firmware handshake timed out, found 0x%08x\n", val); + /* BCM57765 A0 needs additional time before accessing. */ + if (sc->bge_chipid == BGE_CHIPID_BCM57765_A0) + DELAY(10 * 1000); /* XXX */ } /* @@ -3506,7 +3542,7 @@ /* XXX: Broadcom Linux driver. */ if (sc->bge_flags & BGE_FLAG_PCIE && - sc->bge_asicrev != BGE_ASICREV_BCM5717 && + !BGE_IS_5717_PLUS(sc) && sc->bge_chipid != BGE_CHIPID_BCM5750_A0 && sc->bge_asicrev != BGE_ASICREV_BCM5785) { /* Enable Data FIFO protection. */ @@ -4739,7 +4775,10 @@ * this number of frames, it will drop subsequent incoming * frames until the MBUF High Watermark is reached. */ - CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2); + if (sc->bge_asicrev == BGE_ASICREV_BCM57765) + CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 1); + else + CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2); /* Clear MAC statistics. */ if (BGE_IS_5705_PLUS(sc)) --EeQfGwPcQSOJBaQU--