if_tx.c (129879) | if_tx.c (130270) |
---|---|
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 --- 11 unchanged lines hidden (view full) --- 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 27#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 --- 11 unchanged lines hidden (view full) --- 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 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/tx/if_tx.c 129879 2004-05-30 20:08:47Z phk $"); | 28__FBSDID("$FreeBSD: head/sys/dev/tx/if_tx.c 130270 2004-06-09 14:34:04Z naddy $"); |
29 30/* 31 * EtherPower II 10/100 Fast Ethernet (SMC 9432 serie) 32 * 33 * These cards are based on SMC83c17x (EPIC) chip and one of the various 34 * PHYs (QS6612, AC101 and LXT970 were seen). The media support depends on 35 * card model. All cards support 10baseT/UTP and 100baseTX half- and full- 36 * duplex (SMB9432TX). SMC9432BTX also supports 10baseT/BNC. SMC9432FTX also --- 60 unchanged lines hidden (view full) --- 97static int epic_init_rings(epic_softc_t *); 98static void epic_free_rings(epic_softc_t *); 99static void epic_stop_activity(epic_softc_t *); 100static int epic_queue_last_packet(epic_softc_t *); 101static void epic_start_activity(epic_softc_t *); 102static void epic_set_rx_mode(epic_softc_t *); 103static void epic_set_tx_mode(epic_softc_t *); 104static void epic_set_mc_table(epic_softc_t *); | 29 30/* 31 * EtherPower II 10/100 Fast Ethernet (SMC 9432 serie) 32 * 33 * These cards are based on SMC83c17x (EPIC) chip and one of the various 34 * PHYs (QS6612, AC101 and LXT970 were seen). The media support depends on 35 * card model. All cards support 10baseT/UTP and 100baseTX half- and full- 36 * duplex (SMB9432TX). SMC9432BTX also supports 10baseT/BNC. SMC9432FTX also --- 60 unchanged lines hidden (view full) --- 97static int epic_init_rings(epic_softc_t *); 98static void epic_free_rings(epic_softc_t *); 99static void epic_stop_activity(epic_softc_t *); 100static int epic_queue_last_packet(epic_softc_t *); 101static void epic_start_activity(epic_softc_t *); 102static void epic_set_rx_mode(epic_softc_t *); 103static void epic_set_tx_mode(epic_softc_t *); 104static void epic_set_mc_table(epic_softc_t *); |
105static uint32_t tx_mchash(const uint8_t *); | |
106static int epic_read_eeprom(epic_softc_t *,u_int16_t); 107static void epic_output_eepromw(epic_softc_t *, u_int16_t); 108static u_int16_t epic_input_eepromw(epic_softc_t *); 109static u_int8_t epic_eeprom_clock(epic_softc_t *,u_int8_t); 110static void epic_write_eepromreg(epic_softc_t *,u_int8_t); 111static u_int8_t epic_read_eepromreg(epic_softc_t *); 112 113static int epic_read_phy_reg(epic_softc_t *, int, int); --- 1291 unchanged lines hidden (view full) --- 1405 1406#if __FreeBSD_version < 500000 1407 LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1408#else 1409 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1410#endif 1411 if (ifma->ifma_addr->sa_family != AF_LINK) 1412 continue; | 105static int epic_read_eeprom(epic_softc_t *,u_int16_t); 106static void epic_output_eepromw(epic_softc_t *, u_int16_t); 107static u_int16_t epic_input_eepromw(epic_softc_t *); 108static u_int8_t epic_eeprom_clock(epic_softc_t *,u_int8_t); 109static void epic_write_eepromreg(epic_softc_t *,u_int8_t); 110static u_int8_t epic_read_eepromreg(epic_softc_t *); 111 112static int epic_read_phy_reg(epic_softc_t *, int, int); --- 1291 unchanged lines hidden (view full) --- 1404 1405#if __FreeBSD_version < 500000 1406 LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1407#else 1408 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1409#endif 1410 if (ifma->ifma_addr->sa_family != AF_LINK) 1411 continue; |
1413 h = tx_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 1412 h = ether_crc32_be(LLADDR((struct sockaddr_dl *) 1413 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; |
1414 filter[h >> 4] |= 1 << (h & 0xF); 1415 } 1416 1417 CSR_WRITE_4(sc, MC0, filter[0]); 1418 CSR_WRITE_4(sc, MC1, filter[1]); 1419 CSR_WRITE_4(sc, MC2, filter[2]); 1420 CSR_WRITE_4(sc, MC3, filter[3]); 1421} 1422 | 1414 filter[h >> 4] |= 1 << (h & 0xF); 1415 } 1416 1417 CSR_WRITE_4(sc, MC0, filter[0]); 1418 CSR_WRITE_4(sc, MC1, filter[1]); 1419 CSR_WRITE_4(sc, MC2, filter[2]); 1420 CSR_WRITE_4(sc, MC3, filter[3]); 1421} 1422 |
1423/* 1424 * Synopsis: calculate EPIC's hash of multicast address. 1425 */ 1426static uint32_t 1427tx_mchash(addr) 1428 const uint8_t *addr; 1429{ 1430 uint32_t crc, carry; 1431 int idx, bit; 1432 uint8_t data; | |
1433 | 1423 |
1434 /* Compute CRC for the address value. */ 1435 crc = 0xFFFFFFFF; /* initial value */ 1436 1437 for (idx = 0; idx < 6; idx++) { 1438 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 1439 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); 1440 crc <<= 1; 1441 if (carry) 1442 crc = (crc ^ 0x04c11db6) | carry; 1443 } 1444 } 1445 1446 return ((crc >> 26) & 0x3F); 1447} 1448 1449 | |
1450/* 1451 * Synopsis: Start receive process and transmit one, if they need. 1452 */ 1453static void 1454epic_start_activity(sc) 1455 epic_softc_t *sc; 1456{ 1457 --- 459 unchanged lines hidden --- | 1424/* 1425 * Synopsis: Start receive process and transmit one, if they need. 1426 */ 1427static void 1428epic_start_activity(sc) 1429 epic_softc_t *sc; 1430{ 1431 --- 459 unchanged lines hidden --- |