Deleted Added
sdiff udiff text old ( 141548 ) new ( 141586 )
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 141586 2005-02-09 20:03:40Z 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.

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

63
64#ifndef ED_NO_MIIBUS
65#include <dev/mii/mii.h>
66#include <dev/mii/miivar.h>
67#endif
68
69#include <net/bpf.h>
70
71#include <dev/ed/if_edreg.h>
72#include <dev/ed/if_edvar.h>
73
74devclass_t ed_devclass;
75
76static void ed_init(void *);
77static int ed_ioctl(struct ifnet *, u_long, caddr_t);
78static void ed_start(struct ifnet *);

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

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

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

125 return (0);
126 if ((ed_nic_inb(sc, ED_P0_ISR) & ED_ISR_RST) != ED_ISR_RST)
127 return (0);
128
129 return (1);
130}
131
132/*
133 * Allocate a port resource with the given resource id.
134 */
135int
136ed_alloc_port(device_t dev, int rid, int size)
137{
138 struct ed_softc *sc = device_get_softc(dev);
139 struct resource *res;
140
141 res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
142 0ul, ~0ul, size, RF_ACTIVE);
143 if (res) {
144 sc->port_rid = rid;
145 sc->port_res = res;
146 sc->port_used = size;
147 return (0);
148 } else {
149 return (ENOENT);
150 }

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

155 */
156int
157ed_alloc_memory(device_t dev, int rid, int size)
158{
159 struct ed_softc *sc = device_get_softc(dev);
160 struct resource *res;
161
162 res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
163 0ul, ~0ul, size, RF_ACTIVE);
164 if (res) {
165 sc->mem_rid = rid;
166 sc->mem_res = res;
167 sc->mem_used = size;
168 return (0);
169 } else {
170 return (ENOENT);
171 }
172}
173
174/*
175 * Allocate an irq resource with the given resource id.
176 */
177int
178ed_alloc_irq(device_t dev, int rid, int flags)
179{
180 struct ed_softc *sc = device_get_softc(dev);
181 struct resource *res;
182
183 res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid, RF_ACTIVE | flags);
184 if (res) {
185 sc->irq_rid = rid;
186 sc->irq_res = res;
187 return (0);
188 } else {
189 return (ENOENT);
190 }
191}

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

282 /* device attach does transition from UNCONFIGURED to IDLE state */
283
284 if (bootverbose || 1) {
285 if (sc->type_str && (*sc->type_str != 0))
286 device_printf(dev, "type %s ", sc->type_str);
287 else
288 device_printf(dev, "type unknown (0x%x) ", sc->type);
289
290#ifdef ED_HPP
291 if (sc->vendor == ED_VENDOR_HP)
292 printf("(%s %s IO)",
293 (sc->hpp_id & ED_HPP_ID_16_BIT_ACCESS) ?
294 "16-bit" : "32-bit",
295 sc->hpp_mem_start ? "memory mapped" : "regular");
296 else
297#endif
298 printf("%s ", sc->isa16bit ? "(16 bit)" : "(8 bit)");
299
300 printf("%s\n", (((sc->vendor == ED_VENDOR_3COM) ||
301 (sc->vendor == ED_VENDOR_HP)) &&
302 (ifp->if_flags & IFF_ALTPHYS)) ?
303 " tranceiver disabled" : "");
304 }
305 return (0);

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

1228 * disables the tranceiver if set.
1229 */
1230 if (sc->vendor == ED_VENDOR_3COM) {
1231 if (ifp->if_flags & IFF_ALTPHYS) {
1232 ed_asic_outb(sc, ED_3COM_CR, 0);
1233 } else {
1234 ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
1235 }
1236 }
1237#ifdef ED_HPP
1238 else if (sc->vendor == ED_VENDOR_HP)
1239 ed_hpp_set_physical_link(sc);
1240#endif
1241 break;
1242
1243 case SIOCADDMULTI:
1244 case SIOCDELMULTI:
1245 /*
1246 * Multicast list has changed; set the hardware filter
1247 * accordingly.
1248 */

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

1362 * address, copy 'amount' from NIC to host using Programmed I/O.
1363 * The 'amount' is rounded up to a word - okay as long as mbufs
1364 * are word sized.
1365 * This routine is currently Novell-specific.
1366 */
1367void
1368ed_pio_readmem(struct ed_softc *sc, long src, uint8_t *dst, uint16_t amount)
1369{
1370#ifdef ED_HPP
1371 /* HP PC Lan+ cards need special handling */
1372 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS) {
1373 ed_hpp_readmem(sc, src, dst, amount);
1374 return;
1375 }
1376#endif
1377
1378 /* Regular Novell cards */
1379 /* select page 0 registers */
1380 ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STA);
1381
1382 /* round up to a word */
1383 if (amount & 1)
1384 ++amount;

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

1450static u_short
1451ed_pio_write_mbufs(struct ed_softc *sc, struct mbuf *m, long dst)
1452{
1453 struct ifnet *ifp = (struct ifnet *)sc;
1454 unsigned short total_len, dma_len;
1455 struct mbuf *mp;
1456 int maxwait = 200; /* about 240us */
1457
1458#ifdef ED_HPP
1459 /* HP PC Lan+ cards need special handling */
1460 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS)
1461 return ed_hpp_write_mbufs(sc, m, dst);
1462#endif
1463
1464 /* Regular Novell cards */
1465 /* First, count up the total number of bytes to copy */
1466 for (total_len = 0, mp = m; mp; mp = mp->m_next)
1467 total_len += mp->m_len;
1468
1469 dma_len = total_len;
1470 if (sc->isa16bit && (dma_len & 1))

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

1557 log(LOG_WARNING, "%s: remote transmit DMA failed to complete\n",
1558 ifp->if_xname);
1559 ed_reset(ifp);
1560 return(0);
1561 }
1562 return (total_len);
1563}
1564
1565#ifndef ED_NO_MIIBUS
1566/*
1567 * MII bus support routines.
1568 */
1569int
1570ed_miibus_readreg(device_t dev, int phy, int reg)
1571{
1572 struct ed_softc *sc;

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

1754 continue;
1755 index = ether_crc32_be(LLADDR((struct sockaddr_dl *)
1756 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
1757 af[index >> 3] |= 1 << (index & 7);
1758 }
1759}
1760
1761int
1762ed_isa_mem_ok(device_t dev, u_long pmem, u_int memsize)
1763{
1764 if (pmem < 0xa0000 || pmem + memsize > 0x1000000) {
1765 device_printf(dev, "Invalid ISA memory address range "
1766 "configured: 0x%lx - 0x%lx\n", pmem, pmem + memsize);
1767 return (ENXIO);
1768 }
1769 return (0);
1770}
1771
1772int
1773ed_clear_memory(device_t dev)
1774{
1775 struct ed_softc *sc = device_get_softc(dev);
1776 int i;
1777
1778 /*
1779 * Now zero memory and verify that it is clear
1780 */

--- 12 unchanged lines hidden ---