Deleted Added
full compact
if_ie.c (581) if_ie.c (798)
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 *
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$
42 * $Id: if_ie.c,v 1.1 1993/10/12 06:52:31 rgrimes Exp $
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"
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"
109#include "protosw.h"
110#include "socket.h"
111#include "ioctl.h"
112#include "errno.h"
113#include "syslog.h"
114
115#include "net/if.h"
116#include "net/if_types.h"

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

129#endif
130
131#ifdef NS
132#include "netns/ns.h"
133#include "netns/ns_if.h"
134#endif
135
136#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
137#include "i386/isa/isa_device.h"
138#include "i386/isa/ic/i82586.h"
139#include "i386/isa/if_iereg.h"
140#include "i386/isa/icu.h"
141
142#include "vm/vm.h"
143
144#if NBPFILTER > 0

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

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

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

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

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

1069 ie->rbtail = (ie->rbtail + 1) % NBUFFS;
1070 } while(!i);
1071}
1072
1073
1074/*
1075 * Start transmission on an interface.
1076 */
1078int iestart(ifp)
1079 struct ifnet *ifp;
1077static void
1078iestart(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))
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;
1089 return;
1090 if(ifp->if_flags & IFF_OACTIVE)
1090 if(ifp->if_flags & IFF_OACTIVE)
1091 return 0;
1091 return;
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
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;
1150 return;
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
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;
1284static void
1285iereset(unit, dummy)
1286 int unit, dummy;
1286{
1287 int s = splimp();
1288
1289 if(unit >= NIE) {
1290 splx(s);
1287{
1288 int s = splimp();
1289
1290 if(unit >= NIE) {
1291 splx(s);
1291 return -1;
1292 return;
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);
1293 }
1294
1295 printf("ie%d: reset\n", unit);
1296 ie_softc[unit].arpcom.ac_if.if_flags &= ~IFF_UP;
1297 ieioctl(&ie_softc[unit].arpcom.ac_if, SIOCSIFFLAGS, 0);
1298
1299 /*
1300 * Stop i82586 dead in its tracks.

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

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

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

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

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

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

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

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

--- 131 unchanged lines hidden ---