Deleted Added
full compact
if_ed.c (154895) if_ed.c (154924)
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>
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 $");
29__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed.c 154924 2006-01-27 19:10:13Z 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);
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 }
90
91static void ed_setrcr(struct ed_softc *);
92
93/*
94 * Generic probe routine for testing for the existance of a DS8390.
95 * Must be called after the NIC has just been reset. This routine
96 * works by looking at certain register values that are guaranteed
97 * to be initialized a certain way after power-up or reset. Seems

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

269 if (sc->isa16bit)
270 sc->readmem = ed_shmem_readmem16;
271 else
272 sc->readmem = ed_shmem_readmem8;
273 } else {
274 sc->readmem = ed_pio_readmem;
275 }
276 }
279
277 if (sc->sc_write_mbufs == NULL) {
278 device_printf(dev, "No write mbufs routine set\n");
279 return (ENXIO);
280 }
281
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
282 callout_init_mtx(&sc->tick_ch, ED_MUTEX(sc), 0);
283 /*
284 * Set interface to stopped condition (reset)
285 */
286 ed_stop_hw(sc);
287
288 /*
289 * Initialize ifnet structure

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

708 /*
709 * Copy the mbuf chain into the transmit buffer
710 */
711 m0 = m;
712
713 /* txb_new points to next open buffer slot */
714 buffer = sc->mem_start + (sc->txb_new * ED_TXBUF_SIZE * ED_PAGE_SIZE);
715
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 }
716 len = sc->sc_write_mbufs(sc, m, buffer);
717 if (len == 0) {
718 m_freem(m0);
719 goto outloop;
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 */
720 }
721
722 sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN));
723
724 sc->txb_inuse++;
725
726 /*
727 * Point to next buffer slot and wrap if necessary.

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

1387 --maxwait)
1388 continue;
1389}
1390
1391/*
1392 * Write an mbuf chain to the destination NIC memory address using
1393 * programmed I/O.
1394 */
1460static u_short
1395u_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
1396ed_pio_write_mbufs(struct ed_softc *sc, struct mbuf *m, bus_size_t dst)
1397{
1398 struct ifnet *ifp = sc->ifp;
1399 unsigned short total_len, dma_len;
1400 struct mbuf *mp;
1401 int maxwait = 200; /* about 240us */
1402
1403 ED_ASSERT_LOCKED(sc);
1404
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}
1405 /* Regular Novell cards */
1406 /* First, count up the total number of bytes to copy */
1407 for (total_len = 0, mp = m; mp; mp = mp->m_next)
1408 total_len += mp->m_len;
1409
1410 dma_len = total_len;
1411 if (sc->isa16bit && (dma_len & 1))
1412 dma_len++;

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

1632 device_printf(dev, "failed to clear shared memory at "
1633 "0x%jx - check configuration\n",
1634 (uintmax_t)rman_get_start(sc->mem_res) + i);
1635 return (ENXIO);
1636 }
1637 }
1638 return (0);
1639}
1640
1641u_short
1642ed_shmem_write_mbufs(struct ed_softc *sc, struct mbuf *m, bus_size_t dst)
1643{
1644 u_short len;
1645
1646 /*
1647 * Special case setup for 16 bit boards...
1648 */
1649 if (sc->isa16bit) {
1650 switch (sc->vendor) {
1651#ifdef ED_3C503
1652 /*
1653 * For 16bit 3Com boards (which have 16k of
1654 * memory), we have the xmit buffers in a
1655 * different page of memory ('page 0') - so
1656 * change pages.
1657 */
1658 case ED_VENDOR_3COM:
1659 ed_asic_outb(sc, ED_3COM_GACFR, ED_3COM_GACFR_RSEL);
1660 break;
1661#endif
1662 /*
1663 * Enable 16bit access to shared memory on
1664 * WD/SMC boards.
1665 *
1666 * XXX - same as ed_enable_16bit_access()
1667 */
1668 case ED_VENDOR_WD_SMC:
1669 ed_asic_outb(sc, ED_WD_LAAR,
1670 sc->wd_laar_proto | ED_WD_LAAR_M16EN);
1671 if (sc->chip_type == ED_CHIP_TYPE_WD790)
1672 ed_asic_outb(sc, ED_WD_MSR, ED_WD_MSR_MENB);
1673 break;
1674 }
1675 }
1676 for (len = 0; m != 0; m = m->m_next) {
1677 if (sc->isa16bit)
1678 bus_space_write_region_2(sc->mem_bst,
1679 sc->mem_bsh, dst,
1680 mtod(m, uint16_t *), (m->m_len + 1)/ 2);
1681 else
1682 bus_space_write_region_1(sc->mem_bst,
1683 sc->mem_bsh, dst,
1684 mtod(m, uint8_t *), m->m_len);
1685 dst += m->m_len;
1686 len += m->m_len;
1687 }
1688
1689 /*
1690 * Restore previous shared memory access
1691 */
1692 if (sc->isa16bit) {
1693 switch (sc->vendor) {
1694#ifdef ED_3C503
1695 case ED_VENDOR_3COM:
1696 ed_asic_outb(sc, ED_3COM_GACFR,
1697 ED_3COM_GACFR_RSEL | ED_3COM_GACFR_MBS0);
1698 break;
1699#endif
1700 case ED_VENDOR_WD_SMC:
1701 /* XXX - same as ed_disable_16bit_access() */
1702 if (sc->chip_type == ED_CHIP_TYPE_WD790)
1703 ed_asic_outb(sc, ED_WD_MSR, 0x00);
1704 ed_asic_outb(sc, ED_WD_LAAR,
1705 sc->wd_laar_proto & ~ED_WD_LAAR_M16EN);
1706 break;
1707 }
1708 }
1709 return (len);
1710}