Deleted Added
full compact
1/*-
2 * Copyright (c) 1992, 1993, University of Vermont and State
3 * Agricultural College.
4 * Copyright (c) 1992, 1993, Garrett A. Wollman.
5 *
6 * Portions:
7 * Copyright (c) 1990, 1991, William F. Jolitz
8 * Copyright (c) 1990, The Regents of the University of California

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

34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 * $Id$
43 */
44
45/*
46 * Intel 82586 Ethernet chip
47 * Register, bit, and structure definitions.
48 *
49 * Written by GAW with reference to the Clarkson Packet Driver code for this
50 * chip written by Russ Nelson and others.

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

101*/
102
103#include "ie.h"
104#if NIE > 0
105
106#include "param.h"
107#include "systm.h"
108#include "mbuf.h"
109#include "buf.h"
110#include "protosw.h"
111#include "socket.h"
112#include "ioctl.h"
113#include "errno.h"
114#include "syslog.h"
115
116#include "net/if.h"
117#include "net/if_types.h"

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

130#endif
131
132#ifdef NS
133#include "netns/ns.h"
134#include "netns/ns_if.h"
135#endif
136
137#include "i386/isa/isa.h"
138/*#include "machine/cpufunc.h"*/
139#include "i386/isa/isa_device.h"
140#include "i386/isa/ic/i82586.h"
141#include "i386/isa/if_iereg.h"
142#include "i386/isa/icu.h"
143
144#include "vm/vm.h"
145
146#if NBPFILTER > 0

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

166#define ETHERMINLEN 60
167#endif
168
169#define IE_BUF_LEN 1512 /* length of transmit buffer */
170
171/* Forward declaration */
172struct ie_softc;
173
174int ieprobe(struct isa_device *dvp);
175int ieattach(struct isa_device *dvp);
176int ieinit(int unit);
177int ieioctl(struct ifnet *ifp, int command, void *data);
178int iestart(struct ifnet *ifp);
179static void sl_reset_586(int unit);
180static void sl_chan_attn(int unit);
181int iereset(int unit, int dummy);
182static void ie_readframe(int unit, struct ie_softc *ie, int bufno);
183static void ie_drop_packet_buffer(int unit, struct ie_softc *ie);
184static void sl_read_ether(int unit, unsigned char addr[6]);
185static void find_ie_mem_size(int unit);
186static int command_and_wait(int unit, int command, void volatile *pcmd, int);
187static int ierint(int unit, struct ie_softc *ie);
188static int ietint(int unit, struct ie_softc *ie);
189static int iernr(int unit, struct ie_softc *ie);

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

402
403 if_attach(ifp);
404 {
405 struct ifaddr *ifa = ifp->if_addrlist;
406 struct sockaddr_dl *sdl;
407 while(ifa && ifa->ifa_addr && ifa->ifa_addr->sa_family != AF_LINK)
408 ifa = ifa->ifa_next;
409
410 if(!ifa || !ifa->ifa_addr) return;
411
412 /* Provide our ether address to the higher layers */
413 sdl = (struct sockaddr_dl *)ifa->ifa_addr;
414 sdl->sdl_type = IFT_ETHER;
415 sdl->sdl_alen = 6;
416 sdl->sdl_slen = 0;
417 bcopy(ie->arpcom.ac_enaddr, LLADDR(sdl), 6);
418 }
419}
420
421/*
422 * What to do upon receipt of an interrupt.
423 */
424int ieintr(unit)
425 int unit;

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

1070 ie->rbtail = (ie->rbtail + 1) % NBUFFS;
1071 } while(!i);
1072}
1073
1074
1075/*
1076 * Start transmission on an interface.
1077 */
1078int iestart(ifp)
1079 struct ifnet *ifp;
1080{
1081 struct ie_softc *ie = &ie_softc[ifp->if_unit];
1082 struct mbuf *m0, *m;
1083 unsigned char *buffer;
1084 u_short len;
1085 /* This is not really volatile, in this routine, but it makes gcc happy. */
1086 volatile u_short *bptr = &ie->scb->ie_command_list;
1087
1088 if(!(ifp->if_flags & IFF_RUNNING))
1089 return 0;
1090 if(ifp->if_flags & IFF_OACTIVE)
1091 return 0;
1092
1093 do {
1094 IF_DEQUEUE(&ie->arpcom.ac_if.if_snd, m);
1095 if(!m)
1096 break;
1097
1098 buffer = ie->xmit_cbuffs[ie->xmit_count];
1099 len = 0;

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

1142 * By passing the command pointer as a null, we tell
1143 * command_and_wait() to pretend that this isn't an action
1144 * command. I wish I understood what was happening here.
1145 */
1146 command_and_wait(ifp->if_unit, IE_CU_START, 0, 0);
1147 ifp->if_flags |= IFF_OACTIVE;
1148 }
1149
1150 return 0;
1151}
1152
1153/*
1154 * Check to see if there's an 82586 out there.
1155 */
1156int check_ie_present(unit, where, size)
1157 int unit;
1158 caddr_t where;

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

1276{
1277 int i;
1278
1279 for(i = 0; i < 6; i++)
1280 addr[i] = inb(PORT + i);
1281}
1282
1283
1284int iereset(unit, dummy)
1285 int unit, dummy;
1286{
1287 int s = splimp();
1288
1289 if(unit >= NIE) {
1290 splx(s);
1291 return -1;
1292 }
1293
1294 printf("ie%d: reset\n", unit);
1295 ie_softc[unit].arpcom.ac_if.if_flags &= ~IFF_UP;
1296 ieioctl(&ie_softc[unit].arpcom.ac_if, SIOCSIFFLAGS, 0);
1297
1298 /*
1299 * Stop i82586 dead in its tracks.

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

1308 if(!check_ie_present(unit, ie_softc[unit].iomembot, ie_softc[unit].iosize))
1309 panic("ie disappeared!\n");
1310#endif
1311
1312 ie_softc[unit].arpcom.ac_if.if_flags |= IFF_UP;
1313 ieioctl(&ie_softc[unit].arpcom.ac_if, SIOCSIFFLAGS, 0);
1314
1315 splx(s);
1316 return 0;
1317}
1318
1319/*
1320 * This is called if we time out.
1321 */
1322static int chan_attn_timeout(rock)
1323 caddr_t rock;
1324{
1325 *(int *)rock = 1;
1326 return 0;
1327}
1328
1329/*
1330 * Send a command to the controller and wait for it to either
1331 * complete or be accepted, depending on the command. If the
1332 * command pointer is null, then pretend that the command is
1333 * not an action command. If the command pointer is not null,
1334 * and the command is an action command, wait for

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

1540/*
1541 * This routine takes the environment generated by check_ie_present()
1542 * and adds to it all the other structures we need to operate the adapter.
1543 * This includes executing the CONFIGURE, IA-SETUP, and MC-SETUP commands,
1544 * starting the receiver unit, and clearing interrupts.
1545 *
1546 * THIS ROUTINE MUST BE CALLED AT splimp() OR HIGHER.
1547 */
1548int ieinit(unit)
1549 int unit;
1550{
1551 struct ie_softc *ie = &ie_softc[unit];
1552 volatile struct ie_sys_ctl_block *scb = ie->scb;
1553 caddr_t ptr;
1554
1555 ptr = (caddr_t)Align((caddr_t)scb + sizeof *scb); /* ignore cast-qual */
1556

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

1565 cmd->com.ie_cmd_cmd = IE_CMD_CONFIG | IE_CMD_LAST;
1566 cmd->com.ie_cmd_link = 0xffff;
1567
1568 scb->ie_command_list = MK_16(MEM, cmd);
1569
1570 if(command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL)
1571 || !(cmd->com.ie_cmd_status & IE_STAT_OK)) {
1572 printf("ie%d: configure command failed\n", unit);
1573 return 0;
1574 }
1575 }
1576 /*
1577 * Now send the Individual Address Setup command.
1578 */
1579 {
1580 volatile struct ie_iasetup_cmd *cmd = (void *)ptr;
1581
1582 cmd->com.ie_cmd_status = 0;
1583 cmd->com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST;
1584 cmd->com.ie_cmd_link = 0xffff;
1585
1586 bcopy((char *)ie_softc[unit].arpcom.ac_enaddr, (char *)&cmd->ie_address,
1587 sizeof cmd->ie_address); /* ignore cast-qual */
1588
1589 scb->ie_command_list = MK_16(MEM, cmd);
1590 if(command_and_wait(unit, IE_CU_START, cmd, IE_STAT_COMPL)
1591 || !(cmd->com.ie_cmd_status & IE_STAT_OK)) {
1592 printf("ie%d: individual address setup command failed\n", unit);
1593 return 0;
1594 }
1595 }
1596
1597 /*
1598 * Now run the time-domain reflectometer.
1599 */
1600 run_tdr(unit, (void *)ptr);
1601

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

1640
1641 /*
1642 * This must be coordinated with iestart() and ietint().
1643 */
1644 ie->xmit_cmds[0]->ie_xmit_status = IE_STAT_COMPL;
1645
1646 ie->arpcom.ac_if.if_flags |= IFF_RUNNING; /* tell higher levels that we are here */
1647 start_receiver(unit);
1648 return 0;
1649}
1650
1651static void ie_stop(unit)
1652 int unit;
1653{
1654 command_and_wait(unit, IE_RU_DISABLE, 0, 0);
1655}
1656
1657int ieioctl(ifp, command, data)
1658 struct ifnet *ifp;
1659 int command;
1660 void *data;
1661{
1662 struct ifaddr *ifa = (struct ifaddr *)data;
1663 struct ie_softc *ie = &ie_softc[ifp->if_unit];
1664 int s, error = 0;
1665
1666 s = splimp();
1667
1668 switch(command) {

--- 131 unchanged lines hidden ---