Deleted Added
sdiff udiff text old ( 154895 ) new ( 154924 )
full compact
1/*-
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed.c 154895 2006-01-27 08:25:47Z imp $");
30
31/*
32 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
33 * adapters. By David Greenman, 29-April-1993
34 *
35 * Currently supports the Western Digital/SMC 8003 and 8013 series,
36 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
37 * and a variety of similar clones.

--- 44 unchanged lines hidden (view full) ---

82
83static void ed_get_packet(struct ed_softc *, bus_size_t, u_short);
84static void ed_stop_hw(struct ed_softc *sc);
85
86static __inline void ed_rint(struct ed_softc *);
87static __inline void ed_xmit(struct ed_softc *);
88static __inline void ed_ring_copy(struct ed_softc *, bus_size_t, char *,
89 u_short);
90static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *,
91 bus_size_t);
92
93static void ed_setrcr(struct ed_softc *);
94
95/*
96 * Generic probe routine for testing for the existance of a DS8390.
97 * Must be called after the NIC has just been reset. This routine
98 * works by looking at certain register values that are guaranteed
99 * to be initialized a certain way after power-up or reset. Seems

--- 171 unchanged lines hidden (view full) ---

271 if (sc->isa16bit)
272 sc->readmem = ed_shmem_readmem16;
273 else
274 sc->readmem = ed_shmem_readmem8;
275 } else {
276 sc->readmem = ed_pio_readmem;
277 }
278 }
279
280 callout_init_mtx(&sc->tick_ch, ED_MUTEX(sc), 0);
281 /*
282 * Set interface to stopped condition (reset)
283 */
284 ed_stop_hw(sc);
285
286 /*
287 * Initialize ifnet structure

--- 418 unchanged lines hidden (view full) ---

706 /*
707 * Copy the mbuf chain into the transmit buffer
708 */
709 m0 = m;
710
711 /* txb_new points to next open buffer slot */
712 buffer = sc->mem_start + (sc->txb_new * ED_TXBUF_SIZE * ED_PAGE_SIZE);
713
714 if (sc->mem_shared) {
715 /*
716 * Special case setup for 16 bit boards...
717 */
718 if (sc->isa16bit) {
719 switch (sc->vendor) {
720#ifdef ED_3C503
721 /*
722 * For 16bit 3Com boards (which have 16k of
723 * memory), we have the xmit buffers in a
724 * different page of memory ('page 0') - so
725 * change pages.
726 */
727 case ED_VENDOR_3COM:
728 ed_asic_outb(sc, ED_3COM_GACFR,
729 ED_3COM_GACFR_RSEL);
730 break;
731#endif
732 /*
733 * Enable 16bit access to shared memory on
734 * WD/SMC boards.
735 *
736 * XXX - same as ed_enable_16bit_access()
737 */
738 case ED_VENDOR_WD_SMC:
739 ed_asic_outb(sc, ED_WD_LAAR,
740 sc->wd_laar_proto | ED_WD_LAAR_M16EN);
741 if (sc->chip_type == ED_CHIP_TYPE_WD790)
742 ed_asic_outb(sc, ED_WD_MSR, ED_WD_MSR_MENB);
743 break;
744 }
745 }
746 for (len = 0; m != 0; m = m->m_next) {
747 if (sc->isa16bit)
748 bus_space_write_region_2(sc->mem_bst,
749 sc->mem_bsh, buffer,
750 mtod(m, uint16_t *), (m->m_len + 1)/ 2);
751 else
752 bus_space_write_region_1(sc->mem_bst,
753 sc->mem_bsh, buffer,
754 mtod(m, uint8_t *), m->m_len);
755 buffer += m->m_len;
756 len += m->m_len;
757 }
758
759 /*
760 * Restore previous shared memory access
761 */
762 if (sc->isa16bit) {
763 switch (sc->vendor) {
764#ifdef ED_3C503
765 case ED_VENDOR_3COM:
766 ed_asic_outb(sc, ED_3COM_GACFR,
767 ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
768 break;
769#endif
770 case ED_VENDOR_WD_SMC:
771 /* XXX - same as ed_disable_16bit_access() */
772 if (sc->chip_type == ED_CHIP_TYPE_WD790)
773 ed_asic_outb(sc, ED_WD_MSR, 0x00);
774 ed_asic_outb(sc, ED_WD_LAAR,
775 sc->wd_laar_proto & ~ED_WD_LAAR_M16EN);
776 break;
777 }
778 }
779 } else {
780 len = ed_pio_write_mbufs(sc, m, buffer);
781 if (len == 0) {
782 m_freem(m0);
783 goto outloop;
784 }
785 }
786
787 sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN));
788
789 sc->txb_inuse++;
790
791 /*
792 * Point to next buffer slot and wrap if necessary.

--- 659 unchanged lines hidden (view full) ---

1452 --maxwait)
1453 continue;
1454}
1455
1456/*
1457 * Write an mbuf chain to the destination NIC memory address using
1458 * programmed I/O.
1459 */
1460static u_short
1461ed_pio_write_mbufs(struct ed_softc *sc, struct mbuf *m, bus_size_t dst)
1462{
1463 struct ifnet *ifp = sc->ifp;
1464 unsigned short total_len, dma_len;
1465 struct mbuf *mp;
1466 int maxwait = 200; /* about 240us */
1467
1468 ED_ASSERT_LOCKED(sc);
1469
1470#ifdef ED_HPP
1471 /* HP PC Lan+ cards need special handling */
1472 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS)
1473 return ed_hpp_write_mbufs(sc, m, dst);
1474#endif
1475
1476 /* Regular Novell cards */
1477 /* First, count up the total number of bytes to copy */
1478 for (total_len = 0, mp = m; mp; mp = mp->m_next)
1479 total_len += mp->m_len;
1480
1481 dma_len = total_len;
1482 if (sc->isa16bit && (dma_len & 1))
1483 dma_len++;

--- 219 unchanged lines hidden (view full) ---

1703 device_printf(dev, "failed to clear shared memory at "
1704 "0x%jx - check configuration\n",
1705 (uintmax_t)rman_get_start(sc->mem_res) + i);
1706 return (ENXIO);
1707 }
1708 }
1709 return (0);
1710}