1/* $NetBSD: lance.c,v 1.34 2005/12/24 20:27:30 perry Exp $ */ 2 3/*- 4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Charles M. Hannum and by Jason R. Thorpe of the Numerical Aerospace --- 58 unchanged lines hidden (view full) --- 67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 69 * SUCH DAMAGE. 70 * 71 * @(#)if_le.c 8.2 (Berkeley) 11/16/93 72 */ 73 74#include <sys/cdefs.h> |
75__FBSDID("$FreeBSD: head/sys/dev/le/lance.c 158663 2006-05-16 21:04:01Z marius $"); |
76 77#include <sys/param.h> 78#include <sys/bus.h> 79#include <sys/endian.h> 80#include <sys/lock.h> 81#include <sys/mbuf.h> 82#include <sys/mutex.h> 83#include <sys/socket.h> 84#include <sys/sockio.h> 85 86#include <net/ethernet.h> 87#include <net/if.h> 88#include <net/if_arp.h> 89#include <net/if_dl.h> 90#include <net/if_media.h> 91#include <net/if_types.h> 92#include <net/if_vlan_var.h> 93 |
94#include <machine/bus.h> 95 |
96#include <dev/le/lancereg.h> 97#include <dev/le/lancevar.h> 98 99devclass_t le_devclass; 100 |
101static void lance_start(struct ifnet *); 102static void lance_stop(struct lance_softc *); 103static void lance_init(void *); |
104static void lance_watchdog(struct ifnet *); 105static int lance_mediachange(struct ifnet *); 106static void lance_mediastatus(struct ifnet *, struct ifmediareq *); 107static int lance_ioctl(struct ifnet *, u_long, caddr_t); 108 |
109int 110lance_config(struct lance_softc *sc, const char* name, int unit) 111{ 112 struct ifnet *ifp; 113 int i, nbuf; 114 115 if (LE_LOCK_INITIALIZED(sc) == 0) 116 return (ENXIO); --- 252 unchanged lines hidden (view full) --- 369} 370 371/* 372 * Pull data off an interface. 373 * Len is length of data, with local net header stripped. 374 * We copy the data into mbufs. When full cluster sized units are present 375 * we copy into clusters. 376 */ |
377struct mbuf * |
378lance_get(struct lance_softc *sc, int boff, int totlen) 379{ 380 struct ifnet *ifp = sc->sc_ifp; 381 struct mbuf *m, *m0, *newm; 382 caddr_t newdata; 383 int len; 384 |
385 if (totlen <= ETHER_HDR_LEN || totlen > LEBLEN - ETHER_CRC_LEN) { 386#ifdef LEDEBUG 387 if_printf(ifp, "invalid packet size %d; dropping\n", totlen); 388#endif 389 return (NULL); 390 } 391 |
392 MGETHDR(m0, M_DONTWAIT, MT_DATA); |
393 if (m0 == NULL) 394 return (NULL); |
395 m0->m_pkthdr.rcvif = ifp; 396 m0->m_pkthdr.len = totlen; 397 len = MHLEN; 398 m = m0; 399 400 while (totlen > 0) { 401 if (totlen >= MINCLSIZE) { 402 MCLGET(m, M_DONTWAIT); --- 22 unchanged lines hidden (view full) --- 425 m = m->m_next = newm; 426 } 427 } 428 429 return (m0); 430 431 bad: 432 m_freem(m0); |
433 return (NULL); |
434} 435 |
436static void 437lance_watchdog(struct ifnet *ifp) 438{ 439 struct lance_softc *sc = ifp->if_softc; 440 441 LE_LOCK(sc); 442 if_printf(ifp, "device timeout\n"); 443 ++ifp->if_oerrors; --- 149 unchanged lines hidden (view full) --- 593 594 crc = ether_crc32_le(LLADDR((struct sockaddr_dl *) 595 ifma->ifma_addr), ETHER_ADDR_LEN); 596 597 /* Just want the 6 most significant bits. */ 598 crc >>= 26; 599 600 /* Set the corresponding bit in the filter. */ |
601 af[crc >> 4] |= LE_HTOLE16(1 << (crc & 0xf)); |
602 } 603 IF_ADDR_UNLOCK(ifp); 604} 605 606/* 607 * Routines for accessing the transmit and receive buffers. 608 * The various CPU and adapter configurations supported by this 609 * driver require three different access methods for buffers --- 195 unchanged lines hidden --- |