Deleted Added
full compact
if_xe.c (122170) if_xe.c (122625)
1/*-
2 * Copyright (c) 1998, 1999, 2003 Scott Mitchell
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

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

17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
1/*-
2 * Copyright (c) 1998, 1999, 2003 Scott Mitchell
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

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

17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: if_xe.c,v 1.20 1999/06/13 19:17:40 scott Exp $
27 */
25 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/xe/if_xe.c 122170 2003-11-06 08:54:43Z rsm $");
31
32/*
33 * Portions of this software were derived from Werner Koch's xirc2ps driver
34 * for Linux under the terms of the following license (from v1.30 of the
35 * xirc2ps driver):
36 *
37 * Copyright (c) 1997 by Werner Koch (dd9jn)
38 *
39 * Redistribution and use in source and binary forms, with or without

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

57 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
58 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
60 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
62 * OF THE POSSIBILITY OF SUCH DAMAGE.
63 */
64
26/*
27 * Portions of this software were derived from Werner Koch's xirc2ps driver
28 * for Linux under the terms of the following license (from v1.30 of the
29 * xirc2ps driver):
30 *
31 * Copyright (c) 1997 by Werner Koch (dd9jn)
32 *
33 * Redistribution and use in source and binary forms, with or without

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

51 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
52 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
54 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
56 * OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58
59#include <sys/cdefs.h>
60__FBSDID("$FreeBSD: head/sys/dev/xe/if_xe.c 122625 2003-11-13 20:55:53Z obrien $");
61
65/*
66 * FreeBSD device driver for Xircom CreditCard PCMCIA Ethernet adapters. The
67 * following cards are currently known to work with the driver:
68 * Xircom CreditCard 10/100 (CE3)
69 * Xircom CreditCard Ethernet + Modem 28 (CEM28)
70 * Xircom CreditCard Ethernet 10/100 + Modem 56 (CEM56)
71 * Xircom RealPort Ethernet 10
72 * Xircom RealPort Ethernet 10/100

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

161static void xe_media_status (struct ifnet *ifp, struct ifmediareq *mrp);
162static timeout_t xe_setmedia;
163static void xe_reset (struct xe_softc *scp);
164static void xe_stop (struct xe_softc *scp);
165static void xe_enable_intr (struct xe_softc *scp);
166static void xe_disable_intr (struct xe_softc *scp);
167static void xe_set_multicast (struct xe_softc *scp);
168static void xe_set_addr (struct xe_softc *scp, u_int8_t* addr, unsigned idx);
62/*
63 * FreeBSD device driver for Xircom CreditCard PCMCIA Ethernet adapters. The
64 * following cards are currently known to work with the driver:
65 * Xircom CreditCard 10/100 (CE3)
66 * Xircom CreditCard Ethernet + Modem 28 (CEM28)
67 * Xircom CreditCard Ethernet 10/100 + Modem 56 (CEM56)
68 * Xircom RealPort Ethernet 10
69 * Xircom RealPort Ethernet 10/100

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

158static void xe_media_status (struct ifnet *ifp, struct ifmediareq *mrp);
159static timeout_t xe_setmedia;
160static void xe_reset (struct xe_softc *scp);
161static void xe_stop (struct xe_softc *scp);
162static void xe_enable_intr (struct xe_softc *scp);
163static void xe_disable_intr (struct xe_softc *scp);
164static void xe_set_multicast (struct xe_softc *scp);
165static void xe_set_addr (struct xe_softc *scp, u_int8_t* addr, unsigned idx);
169static void xe_set_hash (struct xe_softc *scp, u_int8_t* addr);
166static void xe_mchash (struct xe_softc *scp, caddr_t addr);
170static int xe_pio_write_packet (struct xe_softc *scp, struct mbuf *mbp);
171
172/*
173 * MII functions
174 */
175static void xe_mii_sync (struct xe_softc *scp);
176static int xe_mii_init (struct xe_softc *scp);
177static void xe_mii_send (struct xe_softc *scp, u_int32_t bits, int cnt);

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

1297 count++;
1298
1299 if (count < 10)
1300 /* First 9 use Individual Addresses for exact matching */
1301 xe_set_addr(scp, LLADDR((struct sockaddr_dl *)maddr->ifma_addr), count);
1302 else
1303 if (scp->mohawk)
1304 /* Use hash filter on Mohawk and Dingo */
167static int xe_pio_write_packet (struct xe_softc *scp, struct mbuf *mbp);
168
169/*
170 * MII functions
171 */
172static void xe_mii_sync (struct xe_softc *scp);
173static int xe_mii_init (struct xe_softc *scp);
174static void xe_mii_send (struct xe_softc *scp, u_int32_t bits, int cnt);

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

1294 count++;
1295
1296 if (count < 10)
1297 /* First 9 use Individual Addresses for exact matching */
1298 xe_set_addr(scp, LLADDR((struct sockaddr_dl *)maddr->ifma_addr), count);
1299 else
1300 if (scp->mohawk)
1301 /* Use hash filter on Mohawk and Dingo */
1305 xe_set_hash(scp, LLADDR((struct sockaddr_dl *)maddr->ifma_addr));
1302 xe_mchash(scp, LLADDR((struct sockaddr_dl *)maddr->ifma_addr));
1306 else
1307 /* Nowhere else to put them on CE2 */
1308 break;
1309 }
1310
1311 DEVPRINTF(2, (scp->dev, "set_multicast: count = %u\n", count));
1312
1313 /* Now do some cleanup and enable multicast handling as needed */

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

1410
1411
1412/*
1413 * Set the appropriate bit in the multicast hash table for the supplied
1414 * Ethernet multicast address addr. Assumes that addr is really a multicast
1415 * address.
1416 */
1417static void
1303 else
1304 /* Nowhere else to put them on CE2 */
1305 break;
1306 }
1307
1308 DEVPRINTF(2, (scp->dev, "set_multicast: count = %u\n", count));
1309
1310 /* Now do some cleanup and enable multicast handling as needed */

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

1407
1408
1409/*
1410 * Set the appropriate bit in the multicast hash table for the supplied
1411 * Ethernet multicast address addr. Assumes that addr is really a multicast
1412 * address.
1413 */
1414static void
1418xe_set_hash(struct xe_softc* scp, u_int8_t* addr) {
1415xe_mchash(struct xe_softc* scp, caddr_t addr) {
1419 u_int32_t crc = 0xffffffff;
1416 u_int32_t crc = 0xffffffff;
1420 u_int8_t bit, byte, crc31, idx;
1421 unsigned i, j;
1417 int idx, bit;
1418 u_int8_t carry, byte, data, crc31, hash;
1422
1423 /* Compute CRC of the address -- standard Ethernet CRC function */
1419
1420 /* Compute CRC of the address -- standard Ethernet CRC function */
1424 for (i = 0; i < 6; i++) {
1425 byte = addr[i];
1426 for (j = 1; j <= 8; j++) {
1421 for (data = *addr++, idx = 0; idx < 6; idx++, data >>= 1) {
1422 for (bit = 1; bit <= 8; bit++) {
1427 if (crc & 0x80000000)
1428 crc31 = 0x01;
1429 else
1430 crc31 = 0;
1423 if (crc & 0x80000000)
1424 crc31 = 0x01;
1425 else
1426 crc31 = 0;
1431 bit = crc31 ^ (byte & 0x01);
1427 carry = crc31 ^ (data & 0x01);
1432 crc <<= 1;
1428 crc <<= 1;
1433 byte >>= 1;
1434 if (bit)
1435 crc = (crc ^ XE_CRC_POLY)|1;
1429 data >>= 1;
1430 crc = (crc ^ XE_CRC_POLY) | (carry|0x1);
1436 }
1437 }
1438
1439 DEVPRINTF(3, (scp->dev, "set_hash: CRC = 0x%08x\n", crc));
1440
1431 }
1432 }
1433
1434 DEVPRINTF(3, (scp->dev, "set_hash: CRC = 0x%08x\n", crc));
1435
1441 /* Hash table index = 6 msbs of CRC, reversed */
1442 for (i = 0, idx = 0; i < 6; i++) {
1443 idx >>= 1;
1436 /*
1437 * Convert a CRC into an index into the multicast hash table. What we do is
1438 * take the most-significant 6 bits of the CRC, reverse them, and use that as
1439 * the bit number in the hash table. Bits 5:3 of the result give the byte
1440 * within the table (0-7); bits 2:0 give the bit number within that byte (also
1441 * 0-7), ie. the number of shifts needed to get it into the lsb position.
1442 */
1443 for (idx = 0, hash = 0; idx < 6; idx++) {
1444 hash >>= 1;
1444 if (crc & 0x80000000) {
1445 if (crc & 0x80000000) {
1445 idx |= 0x20;
1446 hash |= 0x20;
1446 }
1447 crc <<= 1;
1448 }
1449
1447 }
1448 crc <<= 1;
1449 }
1450
1450 /* Top 3 bits of idx give register - 8, bottom 3 give bit within register */
1451 byte = idx >> 3 | 0x08;
1452 bit = 0x01 << (idx & 0x07);
1451 /* Top 3 bits of hash give register - 8, bottom 3 give bit within register */
1452 byte = hash >> 3 | 0x08;
1453 carry = 0x01 << (hash & 0x07);
1453
1454
1454 DEVPRINTF(3, (scp->dev, "set_hash: idx = 0x%02x, byte = 0x%02x, bit = 0x%02x\n", idx, byte, bit));
1455 DEVPRINTF(3, (scp->dev, "set_hash: hash = 0x%02x, byte = 0x%02x, carry = 0x%02x\n", hash, byte, carry));
1455
1456 XE_SELECT_PAGE(0x58);
1456
1457 XE_SELECT_PAGE(0x58);
1457 XE_OUTB(byte, XE_INB(byte) | bit);
1458 XE_OUTB(byte, XE_INB(byte) | carry);
1458}
1459
1460
1461/*
1462 * Write an outgoing packet to the card using programmed I/O.
1463 */
1464static int
1465xe_pio_write_packet(struct xe_softc *scp, struct mbuf *mbp) {

--- 537 unchanged lines hidden ---
1459}
1460
1461
1462/*
1463 * Write an outgoing packet to the card using programmed I/O.
1464 */
1465static int
1466xe_pio_write_packet(struct xe_softc *scp, struct mbuf *mbp) {

--- 537 unchanged lines hidden ---