Lines Matching +full:test2 +full:. +full:zeros

2  * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com>
3 * All rights reserved.
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
15 * This product includes software developed by Gardner Buchanan.
16 * 4. The name of Gardner Buchanan may not be used to endorse or promote
18 * permission.
22 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * $FreeBSD: src/sys/dev/sn/if_sn.c,v 1.7.2.3 2001/02/04 04:38:38 toshi Exp $
35 * This is a driver for SMC's 9000 series of Ethernet adapters.
38 * Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman.
40 * which is Copyright (C) 1994 Herb Peyerl <hpeyerl@novatel.ca>
41 * All rights reserved.
44 * PC. It is adapted from Erik Stahlman's Linux driver which worked
45 * with his EFA Info*Express SVC VLB adaptor. According to SMC's databook,
46 * it will work for the entire SMC 9xxx series. (Ha Ha)
49 * 4608 byte packet memory. (for the 91C92. Others have more)
54 * Erik Stahlman erik@vt.edu
55 * Herb Peyerl hpeyerl@novatel.ca
56 * Andres Vega Garcia avega@sophia.inria.fr
57 * Serge Babkin babkin@hq.icb.chel.su
58 * Gardner Buchanan gbuchanan@shl.com
62 * o "smc9194.c:v0.10(FIXED) 02/15/96 by Erik Stahlman (erik@vt.edu)"
63 * o "if_ep.c,v 1.19 1995/01/24 20:53:45 davidg Exp"
66 * o The hardware multicast filter isn't used yet.
67 * o Setting of the hardware address isn't supported.
68 * o Hardware padding isn't used.
74 * Copyright (c) 1996 by Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>
75 * BSD-nomads, Tokyo, Japan.
78 * Multicast support by Kei TANAKA <kei@pal.xerox.com>
79 * Special thanks to itojun@itojun.org
84 #include <sys/param.h>
85 #include <sys/systm.h>
86 #include <sys/kernel.h>
87 #include <sys/interrupt.h>
88 #include <sys/errno.h>
89 #include <sys/sockio.h>
90 #include <sys/malloc.h>
91 #include <sys/mbuf.h>
92 #include <sys/socket.h>
93 #include <sys/syslog.h>
94 #include <sys/serialize.h>
95 #include <sys/module.h>
96 #include <sys/bus.h>
97 #include <sys/rman.h>
99 #include <net/ethernet.h>
100 #include <net/if.h>
101 #include <net/ifq_var.h>
102 #include <net/if_arp.h>
103 #include <net/if_dl.h>
104 #include <net/if_types.h>
105 #include <net/if_mib.h>
107 #include <net/bpf.h>
108 #include <net/bpfdesc.h>
110 #include <machine/clock.h>
112 #include "if_snreg.h"
113 #include "if_snvar.h"
136 * to work properly.
156 struct ifnet *ifp = &sc->arpcom.ac_if; in sn_attach()
186 w = (u_short)sc->arpcom.ac_enaddr[j * 2] | in sn_attach()
187 (((u_short)sc->arpcom.ac_enaddr[j * 2 + 1]) << 8); in sn_attach()
192 * Read the station address from the chip. The MAC address is bank 1, in sn_attach()
196 p = (u_char *) & sc->arpcom.ac_enaddr; in sn_attach()
214 ether_ifattach(ifp, sc->arpcom.ac_enaddr, NULL); in sn_attach()
238 struct ifnet *ifp = &sc->arpcom.ac_if; in sninit()
244 * EEPROM. After the reset cycle, we pause briefly for the chip to in sninit()
245 * be happy. in sninit()
259 * memory) and to enable the EPH interrupt on certain TX errors. in sninit()
271 * Reset the MMU and wait for it to be un-busy. in sninit()
286 * Set the transmitter control. We want it enabled. in sninit()
292 * I (GB) have been unlucky getting this to work. in sninit()
316 * Mark the interface running but not active. in sninit()
322 * Attempt to push out any waiting packets. in sninit()
365 * number of bytes. Below we assume that the packet length is even. in snstart()
373 * We drop packets that are too large. Perhaps we should truncate in snstart()
378 IFNET_STAT_INC(&sc->arpcom.ac_if, oerrors, 1); in snstart()
385 * If HW padding is not turned on, then pad to ETHER_MIN_LEN. in snstart()
396 * 'pages', minus 1 (A packet can't ever have 0 pages. We also in snstart()
398 * the allocation request. in snstart()
411 * completes. Otherwise, I enable the interrupt and wait for in snstart()
412 * completion asyncronously. in snstart()
424 * No memory now. Oh well, wait until the chip finds memory in snstart()
425 * later. Remember how many pages we were asking for and in snstart()
426 * enable the allocation completion interrupt. Also set a in snstart()
427 * watchdog in case we miss the interrupt. We mark the in snstart()
429 * snstart() until after the memory is available. in snstart()
443 * The memory allocation completed. Check the results. in snstart()
452 * We have a packet number, so tell the card to use it. in snstart()
463 * and the status word (set to zeros) in snstart()
470 * Push out the data to the card. in snstart()
475 * Push out words. in snstart()
480 * Push out remaining byte. in snstart()
487 * Push out padding. in snstart()
499 * desired. in snstart()
505 * watchdog in case we miss the interrupt. in snstart()
525 * RX FIFO. If nothing has arrived then attempt to queue another in snstart()
526 * transmit packet. in snstart()
535 * has completed.
538 * a completed memory allocation the same way snstart() does.
540 * packets.
574 * number of bytes. Below we assume that the packet length is even. in snresume()
582 * We drop packets that are too large. Perhaps we should truncate in snresume()
594 * If HW padding is not turned on, then pad to ETHER_MIN_LEN. in snresume()
606 * 'pages', minus 1 (A packet can't ever have 0 pages. We also in snresume()
608 * the allocation request. in snresume()
616 * The memory allocation completed. Check the results. If it failed, in snresume()
617 * we simply set a watchdog timer and hope for the best. in snresume()
621 kprintf("%s: Memory allocation failed. Weird.\n", ifp->if_xname); in snresume()
627 * We have a packet number, so tell the card to use it. in snresume()
633 * memory allocation was initiated. in snresume()
636 kprintf("%s: memory allocation wrong size. Weird.\n", ifp->if_xname); in snresume()
639 * memory once it is granted. Wait for the MMU to be un-busy. in snresume()
655 * and the status word (set to zeros) in snresume()
662 * Push out the data to the card. in snresume()
667 * Push out words. in snresume()
672 * Push out remaining byte. in snresume()
679 * Push out padding. in snresume()
691 * desired. in snresume()
697 * watchdog in case we miss the interrupt. in snresume()
718 * We've sent something, so we're active. Set a watchdog in case the in snresume()
719 * TX_EMPTY interrupt is lost. in snresume()
731 struct ifnet *ifp = &sc->arpcom.ac_if; in sn_intr()
742 * Clear the watchdog. in sn_intr()
750 * while servicing interrupts. in sn_intr()
757 * are masked. in sn_intr()
763 * Now, process each of the interrupt types. in sn_intr()
767 * Receive Overrun. in sn_intr()
777 IFNET_STAT_INC(&sc->arpcom.ac_if, ierrors, 1); in sn_intr()
780 * Got a packet. in sn_intr()
802 * An on-card memory allocation came through. in sn_intr()
807 * Disable this interrupt. in sn_intr()
810 ifq_clr_oactive(&sc->arpcom.ac_if.if_snd); in sn_intr()
811 snresume(&sc->arpcom.ac_if); in sn_intr()
814 * TX Completion. Handle a transmit error message. This will only be in sn_intr()
815 * called when there is an error, because of the AUTO_RELEASE mode. in sn_intr()
839 * Fetch the TX status word. The value found here will be a in sn_intr()
841 * failed. in sn_intr()
849 IFNET_STAT_INC(&sc->arpcom.ac_if, oerrors, 1); in sn_intr()
853 IFNET_STAT_INC(&sc->arpcom.ac_if, collisions, 1); in sn_intr()
856 * Some of these errors will have disabled transmit. in sn_intr()
857 * Re-enable transmit now. in sn_intr()
868 * kill the failed packet. Wait for the MMU to be un-busy. in sn_intr()
876 * Attempt to queue more transmits. in sn_intr()
878 ifq_clr_oactive(&sc->arpcom.ac_if.if_snd); in sn_intr()
879 if_devstart(&sc->arpcom.ac_if); in sn_intr()
882 * Transmit underrun. We use this opportunity to update transmit in sn_intr()
883 * statistics from the card. in sn_intr()
894 * Disable this interrupt. in sn_intr()
904 IFNET_STAT_INC(&sc->arpcom.ac_if, collisions, in sn_intr()
910 IFNET_STAT_INC(&sc->arpcom.ac_if, collisions, in sn_intr()
916 * Attempt to enqueue some more stuff. in sn_intr()
918 ifq_clr_oactive(&sc->arpcom.ac_if.if_snd); in sn_intr()
919 if_devstart(&sc->arpcom.ac_if); in sn_intr()
922 * Some other error. Try to fix it by resetting the adapter. in sn_intr()
931 * Handled all interrupt sources. in sn_intr()
938 * during this interrupt. Note that the hardware mask, which was set in sn_intr()
941 * those new interrupts stay enabled here. in sn_intr()
974 * Start reading from the start of the packet. Since PTR_RCV is set, in snread()
975 * packet number is found in FIFO_PORTS_REG_W, FIFO_RX_MASK. in snread()
987 * extra word with the control byte. in snread()
992 * Account for receive errors and discard. in snread()
999 * A packet is received. in snread()
1003 * Adjust for odd-length packet. in snread()
1009 * Allocate a header mbuf from the kernel. in snread()
1015 m->m_pkthdr.rcvif = ifp; in snread()
1016 m->m_pkthdr.len = m->m_len = packet_length; in snread()
1034 * Get packet, including link layer address, from interface. in snread()
1045 m->m_pkthdr.len = m->m_len = packet_length; in snread()
1053 * the MMU to be un-busy. in snread()
1072 * Handle IOCTLS. This function is completely stolen from if_ep.c
1074 * changes.
1104 /* update multicast filter list. */ in snioctl()
1109 /* update multicast filter list. */ in snioctl()
1135 /* 1. zero the interrupt mask
1136 * 2. clear the enable receive flag
1137 * 3. clear the enable xmit flags
1143 struct ifnet *ifp = &sc->arpcom.ac_if; in snstop()
1146 * Clear interrupt mask; disable all interrupts. in snstop()
1159 * Cancel watchdog. in snstop()
1215 * Tests to see if a given ioaddr points to an SMC9xxx chip.
1216 * Tries to cause as little damage as possible if it's not a SMC chip.
1253 * test this. Go to bank 0, then test that the register still in sn_probe()
1254 * reports the high byte is 0x33. in sn_probe()
1260 device_printf(dev, "test2 failed\n"); in sn_probe()
1266 * hurt. This time, I need to switch the bank register to bank 1, so in sn_probe()
1267 * I can access the base address register. The contents of the in sn_probe()
1269 * to match the I/O port address where the adapter is being probed. in sn_probe()
1276 * pccard == 1, skip this test. (hosokawa) in sn_probe()
1281 * Well, the base address register didn't match. Must not in sn_probe()
1282 * have been a SMC chip after all. in sn_probe()
1297 * Check if the revision register is something that I recognize. in sn_probe()
1299 * be added. in sn_probe()
1306 * I don't regonize this chip, so... in sn_probe()
1314 * at this point I'll assume that the chip is an SMC9xxx. It might be in sn_probe()
1316 * address, or do some other tests. in sn_probe()
1334 * Set the receiver filter. We want receive enabled and auto strip in sn_setmcast()
1335 * of CRC from received packet. If we are promiscuous then set that in sn_setmcast()
1336 * bit too. in sn_setmcast()
1375 TAILQ_FOREACH(ifma, &ac->ac_if.if_multiaddrs, ifma_link) { in sn_getmcf()