summaryrefslogtreecommitdiffstats
path: root/sys/dev/bce/if_bce.c
Commit message (Collapse)AuthorAgeFilesLines
* Rework link state tracking and remove superfluous link UP/DOWNyongari2011-12-131-53/+54
| | | | | | | | | | | | | | | | | | | | | | | | messages. o Add check for actually resolved speed in miibus_statchg callback instead of blindly reprogramming BCE_EMAC_MODE register. The callback may be called multiple times(e.g. link UP, link transition, auto-negotiate complete etc) while auto-negotiation is in progress. All unresolved link state changes are ignored now and setting BCE_EMAC_MODE after link establishment is done once. o bce(4) is careful enough not to drive MII_TICK if driver got a valid link. To detect lost link, bce(4) relied on link state change interrupt and if driver see the interrupt, it forced to drive MII_TICK by calling bce_tick() in interrupt handler. Because bce(4) generates multiple link state change interrupts while auto-negotiation is in progress, bce_tick() would be called multiple times and this resulted in generating multiple link UP/DOWN messages. With this change, bce_tick() is not called in interrupt handler anymore such that miibus_statchg callback handles link state changes with consistent manner. Reviewed by: davidch
* - There's no need to overwrite the default device method with the defaultmarius2011-11-221-5/+1
| | | | | | | | | | one. Interestingly, these are actually the default for quite some time (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9) since r52045) but even recently added device drivers do this unnecessarily. Discussed with: jhb, marcel - While at it, use DEVMETHOD_END. Discussed with: jhb - Also while at it, use __FBSDID.
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.ed2011-11-071-1/+1
| | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static.
* BCE_MISC_ID register of BCM5716 returns the same id of BCM5709 soyongari2011-10-081-50/+25
| | | | | | | | | | | | | | remove explicit checks for BCM5716. The BCM5709 and BCM5716 chips are virtually indistinguishable by software except for the PCI device ID. The two chips differ in that BCM5709 supports TCP/IP and iSCSI offload in Windows while the BCM5716 doesn't. While I'm here remove now unused definition of BCE_CHIP_NUM_5716 and BCE_CHIP_ID_5716_C0. Reported by: sbruno Reviewed by: davidch Tested by: davidch
* - Remove attempts to implement setting of BMCR_LOOP/MIIF_NOLOOPmarius2011-05-031-6/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (reporting IFM_LOOP based on BMCR_LOOP is left in place though as it might provide useful for debugging). For most mii(4) drivers it was unclear whether the PHYs driven by them actually support loopback or not. Moreover, typically loopback mode also needs to be activated on the MAC, which none of the Ethernet drivers using mii(4) implements. Given that loopback media has no real use (and obviously hardly had a chance to actually work) besides for driver development (which just loopback mode should be sufficient for though, i.e one doesn't necessary need support for loopback media) support for it is just dropped as both NetBSD and OpenBSD already did quite some time ago. - Let mii_phy_add_media() also announce the support of IFM_NONE. - Restructure the PHY entry points to use a structure of entry points instead of discrete function pointers, and extend this to include a "reset" entry point. Make sure any PHY-specific reset routine is always used, and provide one for lxtphy(4) which disables MII interrupts (as is done for a few other PHYs we have drivers for). This includes changing NIC drivers which previously just called the generic mii_phy_reset() to now actually call the PHY-specific reset routine, which might be crucial in some cases. While at it, the redundant checks in these NIC drivers for mii->mii_instance not being zero before calling the reset routines were removed because as soon as one PHY driver attaches mii->mii_instance is incremented and we hardly can end up in their media change callbacks etc if no PHY driver has attached as mii_attach() would have failed in that case and not attach a miibus(4) instance. Consequently, NIC drivers now no longer should call mii_phy_reset() directly, so it was removed from EXPORT_SYMS. - Add a mii_phy_dev_attach() as a companion helper to mii_phy_dev_probe(). The purpose of that function is to perform the common steps to attach a PHY driver instance and to hook it up to the miibus(4) instance and to optionally also handle the probing, addition and initialization of the supported media. So all a PHY driver without any special requirements has to do in its bus attach method is to call mii_phy_dev_attach() along with PHY-specific MIIF_* flags, a pointer to its PHY functions and the add_media set to one. All PHY drivers were updated to take advantage of mii_phy_dev_attach() as appropriate. Along with these changes the capability mask was added to the mii_softc structure so PHY drivers taking advantage of mii_phy_dev_attach() but still handling media on their own do not need to fiddle with the MII attach arguments anyway. - Keep track of the PHY offset in the mii_softc structure. This is done for compatibility with NetBSD/OpenBSD. - Keep track of the PHY's OUI, model and revision in the mii_softc structure. Several PHY drivers require this information also after attaching and previously had to wrap their own softc around mii_softc. NetBSD/OpenBSD also keep track of the model and revision on their mii_softc structure. All PHY drivers were updated to take advantage as appropriate. - Convert the mebers of the MII data structure to unsigned where appropriate. This is partly inspired by NetBSD/OpenBSD. - According to IEEE 802.3-2002 the bits actually have to be reversed when mapping an OUI to the MII ID registers. All PHY drivers and miidevs where changed as necessary. Actually this now again allows to largely share miidevs with NetBSD, which fixed this problem already 9 years ago. Consequently miidevs was synced as far as possible. - Add MIIF_NOMANPAUSE and mii_phy_flowstatus() calls to drivers that weren't explicitly converted to support flow control before. It's unclear whether flow control actually works with these but typically it should and their net behavior should be more correct with these changes in place than without if the MAC driver sets MIIF_DOPAUSE. Obtained from: NetBSD (partially) Reviewed by: yongari (earlier version), silence on arch@ and net@
* Do a sweep of the tree replacing calls to pci_find_extcap() with calls tojhb2011-03-231-4/+4
| | | | pci_find_cap() instead.
* - Added error checking to nvram read functions.davidch2011-02-101-40/+45
| | | | | | | - Minor style updates. Submitted by: gcooper@freebsd.org MFC after: 2 weeks
* - Added systcls for header splitting, RX/TX buffer count, interruptdavidch2011-02-071-544/+950
| | | | | | | | | | | | | coalescing, strict RX MTU, verbose output, and shared memory debug. - Added additional debug counters (VLAN tags and split header frames). - Updated debug counters to 64 bit definitions. - Updated l2fhdr bit definitions. - Combined RX buffer sizing into a single function. - Added buffer size and interrupt coalescing settings to adapter info printout. Submitted by: davidch MFC after: 2 weeks
* sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.mdf2011-01-121-11/+11
| | | | Commit the rest of the devices.
* o Flesh out the generic IEEE 802.3 annex 31B full duplex flow controlmarius2010-11-141-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | support in mii(4): - Merge generic flow control advertisement (which can be enabled by passing by MIIF_DOPAUSE to mii_attach(9)) and parsing support from NetBSD into mii_physubr.c and ukphy_subr.c. Unlike as in NetBSD, IFM_FLOW isn't implemented as a global option via the "don't care mask" but instead as a media specific option this. This has the following advantages: o allows flow control advertisement with autonegotiation to be turned on and off via ifconfig(8) with the default typically being off (though MIIF_FORCEPAUSE has been added causing flow control to be always advertised, allowing to easily MFC this changes for drivers that previously used home-grown support for flow control that behaved that way without breaking POLA) o allows to deal with PHY drivers where flow control advertisement with manual selection doesn't work or at least isn't implemented, like it's the case with brgphy(4), e1000phy(4) and ip1000phy(4), by setting MIIF_NOMANPAUSE o the available combinations of media options are readily available from the `ifconfig -m` output - Add IFM_FLOW to IFM_SHARED_OPTION_DESCRIPTIONS and IFM_ETH_RXPAUSE and IFM_ETH_TXPAUSE to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so these are understood by ifconfig(8). o Make the master/slave support in mii(4) actually usable: - Change IFM_ETH_MASTER from being implemented as a global option via the "don't care mask" to a media specific one as it actually is only applicable to IFM_1000_T to date. - Let mii_phy_setmedia() set GTCR_MAN_MS in IFM_1000_T slave mode to actually configure manually selected slave mode (like we also do in the PHY specific implementations). - Add IFM_ETH_MASTER to IFM_SUBTYPE_ETHERNET_OPTION_DESCRIPTIONS so it is understood by ifconfig(8). o Switch bge(4), bce(4), msk(4), nfe(4) and stge(4) along with brgphy(4), e1000phy(4) and ip1000phy(4) to use the generic flow control support instead of home-grown solutions via IFM_FLAGs. This includes changing these PHY drivers and smcphy(4) to no longer unconditionally advertise support for flow control but only if the selected media has IFM_FLOW set (or MIIF_FORCEPAUSE is set) and implemented for these media variants, i.e. typically only for copper. o Switch brgphy(4), ciphy(4), e1000phy(4) and ip1000phy(4) to report and set IFM_1000_T master mode via IFM_ETH_MASTER instead of via IFF_LINK0 and some IFM_FLAGn. o Switch brgphy(4) to add at least the the supported copper media based on the contents of the BMSR via mii_phy_add_media() instead of hardcoding them. The latter approach seems to have developed historically, besides causing unnecessary code duplication it was also undesirable because brgphy_mii_phy_auto() already based the capability advertisement on the contents of the BMSR though. o Let brgphy(4) set IFM_1000_T master mode on all supported PHY and not just BCM5701. Apparently this was a misinterpretation of a workaround in the Linux tg3 driver; BCM5701 seem to require RGPHY_1000CTL_MSE and BRGPHY_1000CTL_MSC to be set when configuring autonegotiation but this doesn't mean we can't set these as well on other PHYs for manual media selection. o Let ukphy_status() report IFM_1000_T master mode via IFM_ETH_MASTER so IFM_1000_T master mode support now is generally available with all PHY drivers. o Don't let e1000phy(4) set master/slave bits for IFM_1000_SX as it's not applicable there. Reviewed by: yongari (plus additional testing) Obtained from: NetBSD (partially), OpenBSD (partially) MFC after: 2 weeks
* Converted the remainder of the NIC drivers to use the mii_attach()marius2010-10-151-6/+7
| | | | | | | introduced in r213878 instead of mii_phy_probe(). Unlike r213893 these are only straight forward conversions though. Reviewed by: yongari
* Make sure to not use stale ip/tcp header pointers. The ip/tcpyongari2010-10-141-0/+2
| | | | | | | | | | | header parser uses m_pullup(9) to get access to mbuf chain. m_pullup(9) can allocate new mbuf chain and free old one if the space left in the mbuf chain is not enough to hold requested contiguous bytes. Previously drivers can use stale ip/tcp header pointer if m_pullup(9) returned new mbuf chain. Reported by: Andrew Boyer (aboyer <> averesystems dot com) MFC after: 10 days
* Add the capability to read the complete contents of the NVRAM via sysctlambrisko2010-10-061-0/+67
| | | | | | | | | | | | | | | dev.bce.<unit>.nvram_dump Add the capability to write the complete contents of the NVRAM via sysctl dev.bce.<unit>.nvram_write These are only available if the kernel option BCE_DEBUG is enabled. The nvram_write sysctl also requires the kernel option BCE_NVRAM_WRITE_SUPPORT to be enabled. These are to be used at your own caution. Since the MAC addresses are stored in the NVRAM, if you dump one NIC and restore it on another NIC the destination NIC's MAC addresses will not be preserved. A tool can be made using these sysctl's to manage the on-chip firmware. Reviewed by: davidch, yongari
* Fix an apparent typo.jkim2010-07-261-1/+1
| | | | | Found by: clang Reviewed by: davidch, yongari
* Specify BCE_RX_BUF_ALIGN alignment for RX buffers. All bce(4)yongari2010-07-191-1/+1
| | | | | | controllers require RX buffers aligned on BCE_RX_BUF_ALIGN bytes. Reviewed by: davidch
* Specify BUS_DMA_ZERO flag to bus_dmamem_alloc(9) and remove bzero()yongari2010-07-191-19/+14
| | | | | | | | calls. Also add BUS_DMA_COHERENT flag to bus_dmamem_alloc(9) to take advantage of efficient synchronization for architectures that support that feature. Reviewed by: davidch
* Use bus_get_dma_tag() to get parent tag. Also useyongari2010-07-191-3/+3
| | | | | | | BUS_SPACE_MAXSIZE_32BIT to specify sum of all segment lengths. Previously it used MAXBSIZE which was wrong. Reviewed by: davidch
* Add KASSERT to check number of returned DMA segments.yongari2010-07-191-0/+2
| | | | Reviewed by: davidch
* Do not report current link state if interface is not UP.yongari2010-07-191-0/+4
| | | | Reviewed by: davidch
* Correctly check the result of media selection. Previously it alwaysyongari2010-07-191-5/+9
| | | | | | returned success. Reviewed by: davidch
* Don't change current media in bce_stop(). There is no need to doyongari2010-07-191-24/+0
| | | | | | this here. Reviewed by: davidch
* Have bce_init_ctx() return error code and make caller check theyongari2010-07-191-18/+22
| | | | | | | | return code. If context was not setup correctly give up initialization. While I'm here move variable declarations to the beginning of the function. Reviewed by: davidch
* When we didn't find a matching flash device, do not touch flashyongari2010-07-191-4/+3
| | | | | | | config data. While I'm here, use return code of bce_init_nvram() to set error instead of directly setting ENODEV. Reviewed by: davidch
* Add a fastpath to allocate from packet zone when using m_getjcl.fabient2010-05-071-5/+2
| | | | | | | This will add support for packet zone for at least igb and ixgbe and will avoid to check for that in bce and mxge. MFC after: 1 week
* - Enable flow control.davidch2010-04-301-489/+642
| | | | | | | | | | | | | | | - Print device details only when verbose boot is enabled. - Add debug output for shared memory access. - Add debug statistics (checksum offload & VLAN frame counters). - Modify TX path to update consumer index for each frame completed rather than updating the consumer index only once for a group of frames to improve small packet performance. - Print driver/firmware pulse messages only when verbose boot is enabled. - Add debug sysctl to clear statistics. - Fix more style(9) violations. MFC after: 2 weeks
* - Fixed 5708S 2.5G support broken in last commit.davidch2010-04-061-2048/+2279
| | | | | | | | - Added some new debug helper routines to systcl. - Fixed many of the style(9) violations that have crept into the code due to my use of a "smart" editor. MFC after: 2 weeks
* - Added support for 5709S/5716S PHYs.davidch2010-03-181-373/+285
| | | | | | | | - Update copyright to 2010. - Add new debug code for RV2P block. - Improve output formatting for various debug functions. MFC after: 2 weeks
* Add TSO support on VLANs. bce(4) controllers require VLAN hardwareyongari2010-02-261-2/+10
| | | | | | | tagging to make TSO work on VLANs so explicitly disable TSO on VLAN if VLAN hardware tagging is disabled. Reviewed by: davidch
* Move TSO setup to new function bce_tso_setup(). Also remove VLANyongari2010-02-261-69/+114
| | | | | | | | | | | | parsing code in TSO path as the controller requires VLAN hardware tagging to make TSO work over VLANs. While parsing the mbuf in TSO patch, always perform check for writable mbuf as bce(4) have to reset IP length and IP checksum field of IP header and make sure to ensure contiguous buffer before accessing IP/TCP headers. While I'm here replace magic number 40 to more readable sizeof(struct ip) + sizeof(struct tcphdr). Reviewed by: davidch
* Prefer m_collapse(9) over m_defrag(9).yongari2010-02-261-1/+1
| | | | Reviewed by: davidch
* Make toggling TSO, VLAN hardware checksum offloading work. Also fixyongari2010-02-261-14/+16
| | | | | | | | | TX/RX checksum handler to set/clear relavant assist bits which was used to cause unexpected results. With this change, bce(4) can be bridged with other interfaces that lack TSO, VLAN checksum offloading. Reviewed by: davidch
* Make sure to stop controller first before changing MTU. And ifyongari2010-02-261-7/+14
| | | | | | | interface is not running don't initialize controller. While here remove unnecessary update of error variable. Reviewed by: davidch
* Allow disabling VLAN hardware tag stripping with software workyongari2010-02-261-20/+40
| | | | | | | | | | around. Management firmware(ASF/IPMI/UMP) requires the VLAN hardware tag stripping so don't actually disable VLAN hardware tag stripping. If VLAN hardware tag stripping was disabled, bce(4) manually reconstruct VLAN frame by appending stripped VLAN tag. Also remove unnecessary IFCAP_VLAN_MTU message. Reviewed by: davidch
* - Added a workaround for NC-SI management firmware that would allowdavidch2010-01-201-29/+133
| | | | | | | | frames to be accepted while the driver is resetting the hardware. This failure is generally observed when broadcast frames are received during driver load and will generate "Unable to write CTX memory" errors. - Small changes to driver flags display.
* - Introduce new option BCE_JUMBO_HDRSPLIT that allows user to enable headerstas2009-10-211-37/+37
| | | | | | | | splitting in bce(4) instead of (ab)using ZERO_COPY_SOCKETS that was not propagated into if_bce.c anyway. It is disabled by default. Approved by: davidch MFC after: 3 days
* Revert previous commit and add myself to the list of people who shouldphk2009-09-081-4/+4
| | | | know better than to commit with a cat in the area.
* Add necessary include.phk2009-09-081-4/+4
|
* Use if_maddr_rlock()/if_maddr_runlock() rather than IF_ADDR_LOCK()/rwatson2009-06-261-2/+2
| | | | | | | | | | | | | IF_ADDR_UNLOCK() across network device drivers when accessing the per-interface multicast address list, if_multiaddrs. This will allow us to change the locking strategy without affecting our driver programming interface or binary interface. For two wireless drivers, remove unnecessary locking, since they don't actually access the multicast address list. Approved by: re (kib) MFC after: 6 weeks
* - Added code to read bootcode firwmare version.davidch2009-06-231-41/+120
| | | | | | - Created dedicated shared memory access routines. MFC after: One week
* DMA synchronization fixes:delphij2009-05-181-16/+13
| | | | | | | | | | | | | | | - In bce_rx_intr(), use BUS_DMASYNC_POSTREAD instead of BUS_DMASYNC_POSTWRITE, as we want to "read" from the rx page chain pages. - Document why we need to do PREWRITE after we have updated the rx page chain pages. - In bce_intr(), use BUS_DMASYNC_POSTREAD and BUS_DMASYNC_PREREAD when before and after CPU "reading" the status block. - Adjust some nearby style mismatches/etc. Pointed out by: yongari Approved by: davidch (no objection) but bugs are mine :)
* - Fixed incorrect packet length problem caused be earlier change todavidch2009-05-081-2/+4
| | | | | | | support ZERO_COPY_SOCKETS. - Created #define for context initialization retry count. MFC after: 1 week
* - Updated firmware to latest 4.6.X release.davidch2009-03-041-115/+178
| | | | | | | | - Added missing firmware for 5709 A1 controllers. - Changed some debug statistic variable names to be more consistent. Submitted by: davidch MFC after: Two weeks
* - Update copyright to 2009.davidch2009-02-271-39/+38
| | | | | | | | - Only enable split header operation when ZERO_COPY_SOCKETS is enabled in the kernel. Submitted by: davidch MFC after: 1 week
* Changes to match "Marketing Description" from Broadcom for HP servers.delphij2009-01-151-12/+14
| | | | | Submitted by: davidch MFC after: 2 months
* Remove intermediate variable busaddr and have bus_* operate directly ondelphij2009-01-131-13/+6
| | | | | | | softc members upon initialization. Reviewed by: davidch MFC after: 1 month
* Add several HP OEM parts' PCI IDs.delphij2009-01-131-0/+22
| | | | MFC after: 2 months
* Don't count InFramesL2FilterDiscards into Ierr. This value does not representdelphij2008-12-161-1/+0
| | | | | | | | | a real packet error but simply indicate that an unexpected unicast or multicast error was received by the NIC, which was not counted in the past as well. Reported by: many (on -stable@) Reviewed by: davidch MFC after: 3 days
* Test whether sc->tx_mbuf_map[i], not whether sc->tx_mbuf_map is NULL beforedelphij2008-12-161-1/+1
| | | | | | doing bus_dmamap_sync() since it operates on the former, not the latter. Reviewed by: davidch
* Don't attempt to clear status updates if we did not do a link statedelphij2008-12-031-5/+6
| | | | | | | | change. As a side effect, this makes the excessive interrupts to disappear which has been observed as a regression in recent stable/7. Reported by: many (on -stable@) Reviewed by: davidch
* Correct a logic error when testing BCE_PHY_SERDES_FLAG.delphij2008-11-191-1/+1
| | | | | | | PR: kern/128801 Pointed out by: Adam Morrison Ok'ed by: davidch MFC after: 3 days
OpenPOWER on IntegriCloud