if_tx.c (121816) | if_tx.c (122625) |
---|---|
1/*- 2 * Copyright (c) 1997 Semen Ustimenko (semenu@FreeBSD.org) 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 --- 12 unchanged lines hidden (view full) --- 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 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997 Semen Ustimenko (semenu@FreeBSD.org) 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 --- 12 unchanged lines hidden (view full) --- 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 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/tx/if_tx.c 121816 2003-10-31 18:32:15Z brooks $"); | 29__FBSDID("$FreeBSD: head/sys/dev/tx/if_tx.c 122625 2003-11-13 20:55:53Z obrien $"); |
30 31/* 32 * EtherPower II 10/100 Fast Ethernet (SMC 9432 serie) 33 * 34 * These cards are based on SMC83c17x (EPIC) chip and one of the various 35 * PHYs (QS6612, AC101 and LXT970 were seen). The media support depends on 36 * card model. All cards support 10baseT/UTP and 100baseTX half- and full- 37 * duplex (SMB9432TX). SMC9432BTX also supports 10baseT/BNC. SMC9432FTX also 38 * supports fibre optics. 39 * 40 * Thanks are going to Steve Bauer and Jason Wright. 41 */ 42 43#include <sys/cdefs.h> | 30 31/* 32 * EtherPower II 10/100 Fast Ethernet (SMC 9432 serie) 33 * 34 * These cards are based on SMC83c17x (EPIC) chip and one of the various 35 * PHYs (QS6612, AC101 and LXT970 were seen). The media support depends on 36 * card model. All cards support 10baseT/UTP and 100baseTX half- and full- 37 * duplex (SMB9432TX). SMC9432BTX also supports 10baseT/BNC. SMC9432FTX also 38 * supports fibre optics. 39 * 40 * Thanks are going to Steve Bauer and Jason Wright. 41 */ 42 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: head/sys/dev/tx/if_tx.c 121816 2003-10-31 18:32:15Z brooks $"); | 44__FBSDID("$FreeBSD: head/sys/dev/tx/if_tx.c 122625 2003-11-13 20:55:53Z obrien $"); |
45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/sockio.h> 49#include <sys/mbuf.h> 50#include <sys/kernel.h> 51#include <sys/socket.h> 52#include <sys/queue.h> --- 47 unchanged lines hidden (view full) --- 100static int epic_init_rings(epic_softc_t *); 101static void epic_free_rings(epic_softc_t *); 102static void epic_stop_activity(epic_softc_t *); 103static int epic_queue_last_packet(epic_softc_t *); 104static void epic_start_activity(epic_softc_t *); 105static void epic_set_rx_mode(epic_softc_t *); 106static void epic_set_tx_mode(epic_softc_t *); 107static void epic_set_mc_table(epic_softc_t *); | 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/sockio.h> 49#include <sys/mbuf.h> 50#include <sys/kernel.h> 51#include <sys/socket.h> 52#include <sys/queue.h> --- 47 unchanged lines hidden (view full) --- 100static int epic_init_rings(epic_softc_t *); 101static void epic_free_rings(epic_softc_t *); 102static void epic_stop_activity(epic_softc_t *); 103static int epic_queue_last_packet(epic_softc_t *); 104static void epic_start_activity(epic_softc_t *); 105static void epic_set_rx_mode(epic_softc_t *); 106static void epic_set_tx_mode(epic_softc_t *); 107static void epic_set_mc_table(epic_softc_t *); |
108static u_int8_t epic_calchash(caddr_t); | 108static u_int32_t tx_mchash(caddr_t); |
109static int epic_read_eeprom(epic_softc_t *,u_int16_t); 110static void epic_output_eepromw(epic_softc_t *, u_int16_t); 111static u_int16_t epic_input_eepromw(epic_softc_t *); 112static u_int8_t epic_eeprom_clock(epic_softc_t *,u_int8_t); 113static void epic_write_eepromreg(epic_softc_t *,u_int8_t); 114static u_int8_t epic_read_eepromreg(epic_softc_t *); 115 116static int epic_read_phy_reg(epic_softc_t *, int, int); --- 1294 unchanged lines hidden (view full) --- 1411 1412#if __FreeBSD_version < 500000 1413 LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1414#else 1415 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1416#endif 1417 if (ifma->ifma_addr->sa_family != AF_LINK) 1418 continue; | 109static int epic_read_eeprom(epic_softc_t *,u_int16_t); 110static void epic_output_eepromw(epic_softc_t *, u_int16_t); 111static u_int16_t epic_input_eepromw(epic_softc_t *); 112static u_int8_t epic_eeprom_clock(epic_softc_t *,u_int8_t); 113static void epic_write_eepromreg(epic_softc_t *,u_int8_t); 114static u_int8_t epic_read_eepromreg(epic_softc_t *); 115 116static int epic_read_phy_reg(epic_softc_t *, int, int); --- 1294 unchanged lines hidden (view full) --- 1411 1412#if __FreeBSD_version < 500000 1413 LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1414#else 1415 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1416#endif 1417 if (ifma->ifma_addr->sa_family != AF_LINK) 1418 continue; |
1419 h = epic_calchash( 1420 LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 1419 h = tx_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
1421 filter[h >> 4] |= 1 << (h & 0xF); 1422 } 1423 1424 CSR_WRITE_4(sc, MC0, filter[0]); 1425 CSR_WRITE_4(sc, MC1, filter[1]); 1426 CSR_WRITE_4(sc, MC2, filter[2]); 1427 CSR_WRITE_4(sc, MC3, filter[3]); 1428} 1429 1430/* 1431 * Synopsis: calculate EPIC's hash of multicast address. 1432 */ | 1420 filter[h >> 4] |= 1 << (h & 0xF); 1421 } 1422 1423 CSR_WRITE_4(sc, MC0, filter[0]); 1424 CSR_WRITE_4(sc, MC1, filter[1]); 1425 CSR_WRITE_4(sc, MC2, filter[2]); 1426 CSR_WRITE_4(sc, MC3, filter[3]); 1427} 1428 1429/* 1430 * Synopsis: calculate EPIC's hash of multicast address. 1431 */ |
1433static u_int8_t 1434epic_calchash(addr) | 1432static u_int32_t 1433tx_mchash(addr) |
1435 caddr_t addr; 1436{ 1437 u_int32_t crc, carry; | 1434 caddr_t addr; 1435{ 1436 u_int32_t crc, carry; |
1438 int i, j; 1439 u_int8_t c; | 1437 int idx, bit; 1438 u_int8_t data; |
1440 1441 /* Compute CRC for the address value. */ 1442 crc = 0xFFFFFFFF; /* initial value */ 1443 | 1439 1440 /* Compute CRC for the address value. */ 1441 crc = 0xFFFFFFFF; /* initial value */ 1442 |
1444 for (i = 0; i < 6; i++) { 1445 c = *(addr + i); 1446 for (j = 0; j < 8; j++) { 1447 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 1443 for (idx = 0; idx < 6; idx++) { 1444 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 1445 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
1448 crc <<= 1; | 1446 crc <<= 1; |
1449 c >>= 1; | |
1450 if (carry) 1451 crc = (crc ^ 0x04c11db6) | carry; 1452 } 1453 } 1454 1455 return ((crc >> 26) & 0x3F); 1456} 1457 --- 468 unchanged lines hidden --- | 1447 if (carry) 1448 crc = (crc ^ 0x04c11db6) | carry; 1449 } 1450 } 1451 1452 return ((crc >> 26) & 0x3F); 1453} 1454 --- 468 unchanged lines hidden --- |