aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
Commit message (Collapse)AuthorAgeFilesLines
* MFC r203082:Pyun YongHyeon2010-02-021-1/+8
| | | | | | | | | | Add initial support for RTL8103E PCIe fastethernet. PR: kern/142974 Approved by: re (kensmith) Notes: svn path=/stable/7/; revision=203383
* MFC 203070:John Baldwin2010-02-011-8/+8
| | | | | | | | | | Initialize the ifnet before calling mii_phy_probe() as some phy drivers (e.g. e1000phy(4)) expect if_dname to be valid when they are probed. Approved by: re (kensmith) Notes: svn path=/stable/7/; revision=203362
* MFC: Disable the alignment restrictions in the bus dma tags for RX and TXJohn Baldwin2010-02-011-2/+2
| | | | | | | | | | buffers. Recent fixes to bus dma exposed a bug somewhere (igb?) that caused igb(4) to no longer receive packets without this change. Approved by: re (kib) Notes: svn path=/stable/7/; revision=203353
* MFC r202863Navdeep Parhar2010-01-231-0/+2
| | | | | | | Don't forget to release the adapter lock for a no-op. Notes: svn path=/stable/7/; revision=202875
* MFC r202268:Xin LI2010-01-232-1/+4
| | | | | | | | | | | | | o Add PCI ID for BCM 5756. o Don't enable BGE_FLAG_BER_BUG on both 5722 and 5756, and based on their PCI IDs rather than their chip IDs. Reported by: several PC-BSD users via kmoore Reviewed by: yongari, imp, jhb, davidch Sponsored by: iXsystems, Inc. Notes: svn path=/stable/7/; revision=202861
* MFC r202567: acpi_ec: remove redundant acpi_disabled checkAndriy Gapon2010-01-221-2/+1
| | | | Notes: svn path=/stable/7/; revision=202793
* MFC r202558: acpi_ec: clean up 'private' ivar when freeing memoryAndriy Gapon2010-01-221-0/+1
| | | | Notes: svn path=/stable/7/; revision=202791
* Remove debug printf.Navdeep Parhar2010-01-221-2/+0
| | | | Notes: svn path=/stable/7/; revision=202775
* MFC 189696,189697:John Baldwin2010-01-211-10/+20
| | | | | | | | | | | | | | | | | | | | | | | | Add a new internal mount flag (MNTK_EXTENDED_SHARED) to indicate that a filesystem supports additional operations using shared vnode locks. Currently this is used to enable shared locks for open() and close() of read-only file descriptors. - When an ISOPEN namei() request is performed with LOCKSHARED, use a shared vnode lock for the leaf vnode only if the mount point has the extended shared flag set. - Set LOCKSHARED in vn_open_cred() for requests that specify O_RDONLY but not O_CREAT. - Use a shared vnode lock around VOP_CLOSE() if the file was opened with O_RDONLY and the mountpoint has the extended shared flag set. - Adjust md(4) to upgrade the vnode lock on the vnode it gets back from vn_open() since it now may only have a shared vnode lock. - Don't enable shared vnode locks on FIFO vnodes in ZFS and UFS since FIFO's require exclusive vnode locks for their open() and close() routines. (My recent MPSAFE patches for UDF and cd9660 already included this change.) - Enable extended shared operations on UFS, cd9660, and UDF. Notes: svn path=/stable/7/; revision=202750
* MFC ↵Navdeep Parhar2010-01-2114-3226/+5068
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r194917,r194918,r197043,r197791,r199239,r199240,r200003,r201907,r202671,r202678: r194917: About to add 10Gbase-T to known media types, this is just a whitespace cleanup before that commit. No functional impact. r194918: Add 10Gbase-T to known ethernet media types Some parts of r194521 (convert the port and adapter locks from sx_locks to regular mutexes). r197043: There is no need to log anything for a ctrlq stall or restart. These are normal events. r197791: cxgb(4) updates, including: - support for the new Gen-2, BT, and LP-CR cards. - T3 firmware 7.7.0 - shared "common code" updates. r199239: The 10GBASE-T card should use an IPG of 1. Also enable the check for low power startup on this card. r199240: Don't disable the XGMAC's tx on ifconfig down. It is unnecessary and can cause false backpressure in the chip. Fix a us/ms mixup while here. r200003: T3 firmware 7.8.0 for cxgb(4) r201907: Extra parantheses to keep certain compilers happy. r202671: Fix for a cxgb(4) panic. cxgb_ioctl can be called by the IP and IPv6 layers with non-sleepable locks held. Don't (potentially) sleep in those situations. r202678: Complain if freelist queue sizes are significantly less than desired. Notes: svn path=/stable/7/; revision=202745
* MFC r202406:Pyun YongHyeon2010-01-211-5/+2
| | | | | | | | | | | | | | Don't free mbuf chains when bge(4) fails to collapse the mbuf chains. This part of code is to enhance performance so failing the collapsing should not free TX frames. Otherwise bge(4) will unnecessarily drop frames which in turn can freeze the network connection. Reported by: Igor Sysoev (is <> rambler-co dot ru) Tested by: Igor Sysoev (is <> rambler-co dot ru) Notes: svn path=/stable/7/; revision=202731
* MFC r202294:Pyun YongHyeon2010-01-211-0/+1
| | | | | | | | | | | | | Add check for fiber mode for BCM5714 PHY. This PHY supports both copper and fiber interfaces over GMII so an explicit check is necessary to know whether it was configured for fiber interface. This change make BCM5715S work. Tested by: olli PR: kern/122551 Notes: svn path=/stable/7/; revision=202729
* MFC r202293:Pyun YongHyeon2010-01-212-12/+23
| | | | | | | | | | | | | | | | | For controllers that has dual mode PHY(copper or fiber) interfaces over GMII, make sure to enable GMII. With this change brgphy(4) is used to handle the dual mode PHY. Since we still don't have a sane way to pass PHY specific information to mii(4) layer special handling is needed in brgphy(4) to determine which mode of PHY was configured in parent interface. This change make BCM5715S work. Tested by: olli Obtained from: OpenBSD PR: kern/122551 Notes: svn path=/stable/7/; revision=202727
* MFC r202269:Pyun YongHyeon2010-01-212-0/+2
| | | | | | | Add BCM5754 PHY id that is found on Dell Studio XPS 16. Notes: svn path=/stable/7/; revision=202725
* MFC r201605: Update acpi_ibm syctl nodes on resume.Mitsuru IWASAKI2010-01-171-0/+30
| | | | Notes: svn path=/stable/7/; revision=202456
* MFC: r201009Marius Strobl2010-01-152-6/+2
| | | | | | | | | Remove clause 3 from Izumi Tsutsui's licenses. Obtained from: NetBSD Notes: svn path=/stable/7/; revision=202396
* MFC: r201008Marius Strobl2010-01-153-25/+31
| | | | | | | | | Style changes Obtained from: NetBSD (mc146818reg.h) Notes: svn path=/stable/7/; revision=202394
* MFC: r201005, r201371Marius Strobl2010-01-152-4/+12
| | | | | | | | | - Take advantage of bus_{read,write}_*(9). - Set dow = -1 in mk48txx_gettime() because some drivers (for example the NetBSD and OpenBSD mk48txx(4)) don't set it correctly. Notes: svn path=/stable/7/; revision=202385
* MFC: r201004Marius Strobl2010-01-153-24/+3
| | | | | | | | | Remove clause 3 and 4 from TNF licenses. Obtained from: NetBSD Notes: svn path=/stable/7/; revision=202383
* MFC: r201003Marius Strobl2010-01-153-78/+78
| | | | | | | Style changes Notes: svn path=/stable/7/; revision=202381
* MFC r200950,200955,200965-200966,201767-201768Pyun YongHyeon2010-01-142-70/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r200950: Implement RX interrupt moderation using one-shot timer interrupt. Unlike TX interrupt, ST201 does not provide any mechanism to suppress RX interrupts. ste(4) can generate more than 70k RX interrupts under heavy RX traffics such that these excessive interrupts make system useless to process other useful things. Maybe this was the major reason why polling support code was introduced to ste(4). The STE_COUNTDOWN register provides a programmable counter that will generate an interrupt upon its expiration. We program STE_DMACTL register to use 3.2us clock rate to drive the counter register. Whenever ste(4) serves RX interrupt, the driver rearm the timer to expire after STE_IM_RX_TIMER_DEFAULT time and disables further generation of RX interrupts. This trick seems to work well and ste(4) generates less than 8k RX interrupts even under 64 bytes UDP torture test. Combined with TX interrupts, the total number of interrupts are less than 10k which looks reasonable on heavily loaded controller. The default RX interrupt moderation time is 150us. Users can change the value at any time with dev.ste.%d.int_rx_mod sysctl node. Setting it 0 effectively disables the RX interrupt moderation feature. Now we have both TX/RX interrupt moderation code so remove loop of interrupt handler which resulted in sub-optimal performance as well as more register accesses. r200955: Add suspend/resume support as well as basic WOL. While I'm here simplify SIOCSIFCAP handler. r200965: Update if_iqdrops in case of RX buffer allocation failure. r200966: ether_ifattach sets if_mtu, remove unnecessary code. r201767: Fix EEPROM access code to return data in host byte order. EEPROM on ST201 always returns 16bits data with little endian format so conversion to host order is required. This change fixes inversed ethernet address on sparc64. r201768: Make sure to store dma address of RX buffer in little endian form. This fixes the last bug which keeps ste(4) from working on sparc64. Notes: svn path=/stable/7/; revision=202319
* MFC r200904-200908,200910-200913Pyun YongHyeon2010-01-142-128/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r200904: Don't reinitialize controller if driver is already running. This reduces number of link state UP/DOWN changes. r200905: Reimplement controller reset. Datasheet says full reset takes about 1ms. Since we switched to memory register mapping make sure to flush PCI posted write by reading the register again. While I'm here add additional delays in loop while driver waits the completion of the reset. r200906: Overhaul RX filter programming. o Let RX filter handler program promiscuous/multicast filter as well as broadcasting. o Remove unnecessary register access. o Simplify ioctl handler and have set_rxfilter to handle IFF_PROMISC and IFF_ALLMULTI change instead of directly programming the controller. o Removed unnecessary error variable reinitialization in ioctl handler. o Add IFF_DRV_RUNNING check before programming multicast filter. o Configure maximum allowed frame length before enabling MAC. Datasheet didn't say the exact ordering of programming sequence but it looks more natural to set maximum allowed frame length first prior to enabling controller. r200907: Don't report link status if driver is not running. r200908: Report the correct result of mii_mediachg(). Previously it always used to return success without respect to the result. While I'm here use mii_mediachg() in ste_init_locked which allows driver to use currently configured media. ste_ifmedia_upd() is supposed to be called whenever user changes current media settings. r200910: Implement hardware MAC statistics counter support. The counters could be accessed with dev.ste.0.stats sysctl node. r200911: Remove unused duplicated register definition. It seems the definition was made to access STE_ASICCTL register as 16bits but ste(4) always access the register as 32bits so it was never used before. r200912: Correct STE_COUNTDOWN register offset. The datasheet was wrong. r200913: We don't need to generate DMA complete interrupt for every transmitted frames. So request interrupt for every 16th frames. Due to the limitation of hardware we can't suppress the interrupt as driver should have to check TX status register. The TX status register can store up to 31 TX status so driver can't send more than 31 frames without reading TX status register. With this change controller would not generate TX completion interrupt for every frame, so reclaim transmitted frames in ste_tick(). Notes: svn path=/stable/7/; revision=202315
* MFC r200854,200856,200865,200873,200875,200877,200884Pyun YongHyeon2010-01-142-127/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r200854: Add minimal dealy while ste(4) is waiting for the end of active DMA cycle. r200856: Introduce sc_flags member variable and use it to keep track of link state and PHY related information. Remove ste_link and ste_one_phy variable of softc as it's not used anymore. While I'm here add IFF_DRV_RUNNING check in ste_start_locked(). r200865: Reimplement miibus_statchg method. Don't rely on link state change interrupt. If we want to use link state change interrupt ste(4) should also implement auto-negotiation complete handler as well as various PHY access handling. Now link state change is handled by mii(4) polling so it will automatically update link state UP/DOWN events which in turn make ste(4) usable with lagg(4). r199559 added a private timer to drive watchdog and the timer also used to drive MAC statistics update. Because the MAC statistics update is called whenever statistics counter reaches near-full, it drove watchdog timer too fast such that it caused false watchdog timeouts under heavy TX traffic conditions. Fix the regression by separating ste_stats_update() from driving watchdog timer and introduce a new function ste_tick() that handles periodic job such as driving watchdog, MAC statistics update and link state check etc. While I'm here clear armed watchdog timer in ste_stop(). r200873: Instead of relying on hard resetting of controller to stop receiving incoming traffics, try harder to gracefully stop active DMA cycles and then stop MACs. This is the way what datasheet recommends and seems to work reliably. Resetting controller while active DMAs are in progress is bad thing as we can't predict how DMAs touche allocated TX/RX buffers. This change ensures controller stop state before attempting to release allocated TX/RX buffers. Also update MAC statistics which could have been updated during the wait time of MAC stop. While I'm here remove unnecessary controller resets in various location. ste(4) no longer relies on hard controller reset to stop controller and resetting controller also clears all configured settings which makes it hard to implement WOL in near future. Now resetting a controller is performed in ste_init_locked(). r200875: Prefer memory space register mapping over io space. If memory space mapping fails fall back to old io space mapping. While I'm here use PCIR_BAR macro. r200877: Prefer bus_write_{1,2,4}/bus_read_{1,2,4} to bus_space_write_{1,2,4}/bus_space_read_{1,2,4}. Remove unused ste_bhandle and ste_btag in softc. r200884: Reimplement Tx status error handler as recommended by datasheet. If ste(4) encounter TX underrun or excessive collisions the TX MAC of controller is stalled so driver should wake it up again. TX underrun requires increasing TX threshold value to minimize further TX underruns. Previously ste(4) used to reset controller to recover from TX underrun, excessive collision and reclaiming error. However datasheet says only TX underrun requires resetting entire controller. So implement ste_restart_tx() that restarts TX MAC and do not perform full reset except TX underrun case. Now ste(4) uses CSR_READ_2 instead of CSR_READ_1 to read STE_TX_STATUS register. This way ste(4) will also read frame id value and we can write the same value back to STE_TX_FRAMEID register instead of overwriting it to 0. The datasheet was wrong in write back of STE_TX_STATUS so add some comments why we do so. Also always invoke ste_txeoc() after ste_txeof() in ste_poll as without reading TX status register can stall TX MAC. Notes: svn path=/stable/7/; revision=202313
* MFC r200853:Pyun YongHyeon2010-01-142-247/+550
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add bus_dma(9) and endianness support to ste(4). o Sorted includes and added missing header files. o Added basic endianness support. In theory ste(4) should work on any architectures. o Remove the use of contigmalloc(9), contigfree(9) and vtophys(9). o Added 8 byte alignment limitation of TX/RX descriptor. o Added 1 byte alignment requirement for TX/RX buffers. o ste(4) controllers does not support DAC. Limit DMA address space to be within 32bit address. o Added spare DMA map to gracefully recover from DMA map failure. o Removed dead code for checking STE_RXSTAT_DMADONE bit. The bit was already checked in each iteration of loop so it can't be true. o Added second argument count to ste_rxeof(). It is used to limit number of iterations done in RX handler. ATM polling is the only consumer. o Removed ste_rxeoc() which was added to address RX stuck issue (cvs rev 1.66). Unlike TX descriptors, ST201 supports chaining descriptors to form a ring for RX descriptors. If RX descriptor chaining is not supported it's possible for controller to stop receiving incoming frames once controller pass the end of RX descriptor which in turn requires driver post new RX descriptors to receive more frames. For TX descriptors which does not support chaning, we exactly do manual chaining in driver by concatenating new descriptors to the end of previous TX chain. Maybe the workaround was borrowed from other drivers that does not support RX descriptor chaining, which is not valid for ST201 controllers. I still have no idea how this address RX stuck issue and I can't reproduce the RX stuck issue on DFE-550TX controller. o Removed hw.ste_rxsyncs sysctl as the workaround was removed. o TX/RX side bus_dmamap_load_mbuf_sg(9) support. o Reimplemented optimized ste_encap(). o Simplified TX logic of ste_start_locked(). o Added comments for TFD/RFD requirements. o Increased number of RX descriptors to 128 from 64. 128 gave much better performance than 64 under high network loads. Notes: svn path=/stable/7/; revision=202310
* MFC r200798,200801,200803-200804,200808,200810Pyun YongHyeon2010-01-142-301/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | r200798: Use ANSI function definations. r200801: o Remove unnecessary return statement. o Remove register keyword. r200803: s/u_intXX_t/uintXX_t/g r200804: Remove trailing white spaces. r200808: style(9) r200810: Sort function prototyes. Also remove mergeinfo recorded in if_ste.c/if_stereg.h. Notes: svn path=/stable/7/; revision=202308
* MFC: r194747,r202120:Andrew Gallatin2010-01-144-32615/+33883
| | | | | | | Update mxge(4) firmware to 1.4.48b (latest available) from Myricom. Notes: svn path=/stable/7/; revision=202306
* MFC r202121:Andrew Gallatin2010-01-141-2/+2
| | | | | | | Use better default RSS hash (src + dst, rather than just src port) Notes: svn path=/stable/7/; revision=202304
* MFC 202119: Fix reporting of 10G Twinax mediaAndrew Gallatin2010-01-141-1/+2
| | | | Notes: svn path=/stable/7/; revision=202300
* Partial merge r199559:Pyun YongHyeon2010-01-142-11/+11
| | | | | | | | | | - Add a private timer to drive the transmit watchdog instead of using if_watchdog and if_timer. - Fix some issues in detach for sn(4), ste(4), and ti(4). Primarily this means calling ether_ifdetach() before anything else. Notes: svn path=/stable/7/; revision=202298
* MFC r181739:Pyun YongHyeon2010-01-142-0/+2302
| | | | | | | Move the ste driver from sys/pci to sys/dev/ste. Notes: svn path=/stable/7/; revision=202296
* MFC: r200926Marius Strobl2010-01-132-2/+3
| | | | | | | Recognize the NS16552 found in PCIe-based sun4u machines. Notes: svn path=/stable/7/; revision=202263
* MFC: r200815, r200816Marius Strobl2010-01-131-3/+5
| | | | | | | Provide and consume missing module dependency information. Notes: svn path=/stable/7/; revision=202224
* MFC: Merge older mxge(4) fixes/improvements from head:Andrew Gallatin2010-01-112-6/+73
| | | | | | | | | | r193250: Set an rx jumbo cluster to the correct size for bus_dmamap_load_mbuf_sg() r194836: Initial mtu r195818: Rename hw.mxge.rss_hash_type -> hw.mxge.rss_hashtype r197391: Add support for TX throttling Notes: svn path=/stable/7/; revision=202117
* MFC 201151:Fabien Thomas2010-01-101-0/+6
| | | | | | | Use VFS_{LOCK,UNLOCK}_GIANT() around the call to vrele(). Notes: svn path=/stable/7/; revision=202016
* MFC 201023:Fabien Thomas2010-01-101-8/+8
| | | | | | | | | | * Support the L1D_CACHE_LD event on Core2 processors. * Correct a group of typos: for Core2 programmable events, check user supplied umask values against the correct event descriptor field. Notes: svn path=/stable/7/; revision=202015
* MFC 201021:Fabien Thomas2010-01-101-3/+161
| | | | | | | Log process mappings for existing processes at PMC start time. Notes: svn path=/stable/7/; revision=202014
* MFC r200693:Pyun YongHyeon2010-01-091-1/+3
| | | | | | | | | Make sure to enable Next Page bit for IP1001. Otherwise the PHY fails to re-establishe 1000baseT link after downgrading to 10/100Mbps link. Notes: svn path=/stable/7/; revision=201878
* MFC r200696,200740,200756,200758-200759,200972Pyun YongHyeon2010-01-093-26/+244
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r200696: Add rudimentary WOL support. While I'm here remove enabling busmastering/memory address in resume path. Bus driver will handle that. r200740: Swap VGE_TXQTIMER and VGE_RXQTIMER register definition. Pending timer for Tx queue is at 0x3E. r200756: Correct fragment bit definition in comments. r200758: VT6130 datasheet was wrong. If VT6130 receive a jumbo frame the controller will split the jumbo frame into multiple RX buffers. However it seems the hardware always dma the frame to 8 bytes boundary for the split frames. Only the first part of the fragment can have 4 byte alignment and subsequent buffers should be 8 bytes aligned. Change RX buffer the alignment requirement to 8 bytes from 4 bytes. r200759: Disable jumbo frame support for PCIe VT6130/VT6132 controllers. Quite contrary to VT6130 datasheet which says it supports up to 8K jumbo frame, VT6130 does not seem to send jumbo frame that is larger than 4K in length. Trying to send a frame that is larger than 4K cause TX MAC hang. Even though it's possible to allow 4K jumbo frame for VT6130, I think it's meaningless to allow 4K jumbo frame. I'm not sure VT6132 also has the same limitation but I guess it uses the same MAC of VT6130. r200972: Remove wrong assertion. Notes: svn path=/stable/7/; revision=201874
* MFC r200638:Pyun YongHyeon2010-01-093-80/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement interrupt moderation scheme supported by VT61xx controllers. TX/RX interrupt mitigation is controlled by VGE_TXSUPPTHR and VGE_RXSUPPTHR register. These registers suppress generation of interrupts until the programmed frames counter equals to the registers. VT61xx also supports interrupt hold off timer register. If this interrupt hold off timer is active all interrupts would be disabled until the timer reaches to 0. The timer value is reloaded whenever VGE_ISR register written. The timer resolution is about 20us. Previously vge(4) used single shot timer to reduce Tx completion interrupts. This required VGE_CRS1 register access in Tx start/completion handler to rearm new timeout value and it did not show satisfactory result(more than 50k interrupts under load). Rx interrupts was not moderated at all such that vge(4) used to generate too many interrupts which in turn made polling(4) better approach under high network load. This change activates all interrupt moderation mechanism and initial values were tuned to generate interrupt less than 8k per second. That number of interrupts wouldn't add additional packet latencies compared to polling(4). These interrupt parameters could be changed with sysctl. dev.vge.%d.int_holdoff dev.vge.%d.rx_coal_pkt dev.vge.%d.tx_coal_pkt Interface has be brought down and up again before change take effect. With interrupt moderation there is no more need to loop in interrupt handler. This loop always added one more register access. While I'm here remove dead code which tried to implement subset of interrupt moderation. Notes: svn path=/stable/7/; revision=201869
* MFC r200616-200617,200635,200639,200644Pyun YongHyeon2010-01-092-20/+8
| | | | | | | | | | | | | | | | | | | | | | | | | r200616: Add new flag VGE_FLAG_SUSPENDED to mark suspended state and remove suspended member in softc. r200617: Add "Velocity" to probe message which will make it clearer which ethernet controller was recognized. VIA consistently calls "Velocity" family for gigabit ethernet controllers. For fast ethernet controllers they uses "Rhine" family(vr(4) controllers)) and vr(4) already shows "Rhine" in probe message. r200635: Remove unused VGE_ETHER_ALIGN definition. r200639: Actually clear interrupts. Writing 0 has no effect. r200644: Remove unused member variable of softc. Notes: svn path=/stable/7/; revision=201867
* MFC 200615:Pyun YongHyeon2010-01-093-3/+322
| | | | | | | | Add hardware MAC statistics support. This statistics could be extracted from dev.vge.%d.stats sysctl node. Notes: svn path=/stable/7/; revision=201865
* MFC r200551-200552,200555,200558,200609,200613Pyun YongHyeon2010-01-091-70/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r200551: Whenever link state change interrupt is raised, vge_tick() is called and vge(4) used to drive auto-negotiation timer(mii_tick) in vge_tick(). Therefore the mii_tick was not called for every hz such that auto-negotiation complete was never handled in vge(4). Use mii_pollstat to extract current negotiated speed/duplex instead of mii_tick. The latter is valid only for auto-negotiation case. While I'm here change the confusing function name vge_tick() to vge_link_statchg(). r200552: Report media change result to caller instead of returning success without regard to the result. r200555: Don't report current link status if interface is not UP. If interface is not UP, the current link status wouldn't reflect the negotiated status. r200558: Tell upper layer vge(4) supports long frames. This should be done after ether_ifattach(), as ether_ifattach() initializes it with ETHER_HDR_LEN. While I'm here remove setting if_mtu, it's already handled in ether_ifattach(). r200609: All vge(4) controllers support RX/TX checksum offloading for VLAN tagged frames so add checksum offloading capabilities. Also add missing VLAN hardware tagging control in ioctl handler and let upper stack know current VLAN capabilities. r200613: Rewrite RX filter setup and simplify code. Now promiscuous mode and multicast handling is performed in single function, vge_rxfilter(). Notes: svn path=/stable/7/; revision=201861
* MFC r200538,200540-200541,200543,200545,200548Pyun YongHyeon2010-01-082-82/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r200538: Introduce vge_flags member in softc. The vge_flags member will record device specific bits. Remove vge_link and use vge_flags. While here, move clearing link state before mii_mediachg() as mii_mediachg() may affect link state. r200540: Save PHY address by reading VGE_MIICFG register. For PCIe controllers(VT613x), we assume the PHY address is 1. Use the saved PHY address in MII register access routines and remove accessing VGE_MIICFG register. While I'm here save PCI express capability register which will be used in near future. r200541: Add MSI support for VT613x controllers. r200543: Increase output queue size from 64 to 255. r200545: We don't have to reload EEPROM in vge_reset(). Because vge_reset() is called in vge_init_lock(), vge(4) always used to reload EEPROM. Also add more comment why vge(4) clears VGE_CHIPCFG0_PACPI bit. While I'm here add missing new line in vge_reset(). r200548: Sort function prototyes. Notes: svn path=/stable/7/; revision=201841
* MFC r200526-200527,200529,200531-200533,200536Pyun YongHyeon2010-01-083-236/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r200526: Use PCIR_BAR instead of hard-coded value. r200527: Fix typo in register definition. r200529: Clear VGE_TXDESC_Q bit for transmitted frames. The VGE_TXDESC_Q bit seems to work like a tag that indicates 'not list end' of queued frames. Without having a VGE_TXDESC_Q bit indicates 'list end'. So the last frame of multiple queued frames has no VGE_TXDESC_Q bit. The hardware has peculiar behavior for VGE_TXDESC_Q bit handling. If the VGE_TXDESC_Q bit of descriptor was set the controller would fetch next descriptor. However if next descriptor's OWN bit was cleared but VGE_TXDESC_Q was set, it could confuse controller. Clearing VGE_TXDESC_Q bit for transmitted frames ensure correct behavior. r200531: Use ANSI function definations. r200532: Remove unnecessary return statement. r200533: s/u_intXX_t/uintXX_t/g r200536: style(9). Notes: svn path=/stable/7/; revision=201839
* MFC r200525:Pyun YongHyeon2010-01-083-688/+836
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Overhaul bus_dma(9) usage and fix various things. o Separate TX/RX buffer DMA tag from TX/RX descriptor ring DMA tag. o Separate RX buffer DMA tag from common buffer DMA tag. RX DMA tag has different restriction compared to TX DMA tag. o Add 40bit DMA address support. o Adjust TX/RX descriptor ring alignment to 64 bytes from 256 bytes as documented in datasheet. o Added check to ensure TX/RX ring reside within a 4GB boundary. Since TX/RX ring shares the same high address register they should have the same high address. o TX/RX side bus_dmamap_load_mbuf_sg(9) support. o Add lock assertion to vge_setmulti(). o Add RX spare DMA map to recover from DMA map load failure. o Add optimized RX buffer handler, vge_discard_rxbuf which is activated when vge(4) sees bad frames. o Don't blindly update VGE_RXDESC_RESIDUECNT register. Datasheet says the register should be updated only when number of available RX descriptors are multiple of 4. o Use __NO_STRICT_ALIGNMENT instead of defining VGE_FIXUP_RX which is only set for i386 architecture. Previously vge(4) also performed expensive copy operation to align IP header on amd64. This change should give RX performance boost on amd64 architecture. o Don't reinitialize controller if driver is already running. This should reduce number of link state flipping. o Since vge(4) drops a driver lock before passing received frame to upper layer, make sure vge(4) is still running after re-acquiring driver lock. o Add second argument count to vge_rxeof(). The argument will limit number of packets could be processed in RX handler. o Rearrange vge_rxeof() not to allocate RX buffer if received frame was bad packet. o Removed if_printf that prints DMA map failure. This type of message shouldn't be used in fast path of driver. o Reduce number of allowed TX buffer fragments to 6 from 7. A TX descriptor allows 7 fragments of a frame. However the CMZ field of descriptor has just 3bits and the controller wants to see fragment + 1 in the field. So if we have 7 fragments the field value would be 0 which seems to cause unexpected results under certain conditions. This change should fix occasional TX hang observed on vge(4). o Simplify vge_stat_locked() and add number of available TX descriptor check. o vge(4) controllers lack padding short frames. Make sure to fill zero for the padded bytes. This closes unintended information disclosure. o Don't set VGE_TDCTL_JUMBO flag. Datasheet is not clear whether this bit should be set by driver or write-back status bit after transmission. At least vendor's driver does not set this bit so remove it. Without this bit vge(4) still can send jumbo frames. o Don't start driver when vge(4) know there are not enough RX buffers. o Remove volatile keyword in RX descriptor structure. This should be handled by bus_dma(9). o Collapse two 16bits member of TX/RX descriptor into single 32bits member. o Reduce number of RX descriptors to 252 from 256. The VGE_RXDESCNUM is 16bits register but only lower 8bits are valid. So the maximum number of RX descriptors would be 255. However the number of should be multiple of 4 as controller wants to update 4 RX descriptors at a time. This limits the maximum number of RX descriptor to be 252. PR: kern/141276, kern/141414 Notes: svn path=/stable/7/; revision=201834
* MFC r200519-200522Pyun YongHyeon2010-01-081-15/+14
| | | | | | | | | | | | | | | | | r200519: Remove register keyword. r200520: Prefer device_printf(9) to printf(9). r200521: Fix spelling in comment. r200522: Prefer bus_alloc_resource_any(9) to bus_alloc_resource(9). Notes: svn path=/stable/7/; revision=201827
* MFC r198987,199414,199543,200422Pyun YongHyeon2010-01-082-103/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Partial merge r198987: Use device_printf() and if_printf() instead of printf() with an explicit unit number and remove 'unit' members from softc. Partial merge r199414: Use the bus_*() routines rather than bus_space_*() for register operations. r199543: Several fixes to this driver: - Overhaul the locking to avoid recursion and add missing locking in a few places. - Don't schedule a task to call vge_start() from contexts that are safe to call vge_start() directly. Just invoke the routine directly instead (this is what all of the other NIC drivers I am familiar with do). Note that vge(4) does not use an interrupt filter handler which is the primary reason some other drivers use tasks. - Add a new private timer to drive the watchdog timer instead of using if_watchdog and if_timer. - Fixup detach by calling ether_ifdetach() before stopping the interface. r200422: Remove driver lock assertion in MII register access. This change was made in r199543 to remove MTX_RECURSE. These routines can be called in device attach phase(e.g. mii_phy_probe()) so checking assertion here is not right as caller does not hold a driver lock. Notes: svn path=/stable/7/; revision=201824
* MFC r200994:Gavin Atkinson2010-01-081-1/+1
| | | | | | | | | | | | Set the locally-assigned bit in the randomly generated Ethernet address if we end up having to generate one. PR: kern/133239 Discussed with: yongari Approved by: ed (mentor, implicit) Notes: svn path=/stable/7/; revision=201779
* MFC rev. 198487:Alexander Motin2010-01-071-2/+2
| | | | | | | Round timeout up when converting CAM milliseconds to ATA seconds. Notes: svn path=/stable/7/; revision=201720
* MFC r200353:Alexander Motin2010-01-071-0/+4
| | | | | | | | Limit maximum I/O size, depending on command set supported by device. It is required to suppot non-LBA48 devices with MAXPHYS above 128K. Notes: svn path=/stable/7/; revision=201719