Deleted Added
full compact
if_sn.c (122427) if_sn.c (122625)
1/*
2 * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com>
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

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

26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com>
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

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

26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/sn/if_sn.c 122427 2003-11-10 16:04:11Z imp $");
34__FBSDID("$FreeBSD: head/sys/dev/sn/if_sn.c 122625 2003-11-13 20:55:53Z obrien $");
35
36/*
37 * This is a driver for SMC's 9000 series of Ethernet adapters.
38 *
39 * This FreeBSD driver is derived from the smc9194 Linux driver by
40 * Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman.
41 * This driver also shamelessly borrows from the FreeBSD ep driver
42 * which is Copyright (C) 1994 Herb Peyerl <hpeyerl@novatel.ca>

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

129static void sninit(void *);
130static void snread(struct ifnet *);
131static void snstart(struct ifnet *);
132static void snstop(struct sn_softc *);
133static void snwatchdog(struct ifnet *);
134
135static void sn_setmcast(struct sn_softc *);
136static int sn_getmcf(struct arpcom *ac, u_char *mcf);
35
36/*
37 * This is a driver for SMC's 9000 series of Ethernet adapters.
38 *
39 * This FreeBSD driver is derived from the smc9194 Linux driver by
40 * Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman.
41 * This driver also shamelessly borrows from the FreeBSD ep driver
42 * which is Copyright (C) 1994 Herb Peyerl <hpeyerl@novatel.ca>

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

129static void sninit(void *);
130static void snread(struct ifnet *);
131static void snstart(struct ifnet *);
132static void snstop(struct sn_softc *);
133static void snwatchdog(struct ifnet *);
134
135static void sn_setmcast(struct sn_softc *);
136static int sn_getmcf(struct arpcom *ac, u_char *mcf);
137static u_int sn_crc(u_char *);
137static u_int32_t sn_mchash(caddr_t);
138
139/* I (GB) have been unlucky getting the hardware padding
140 * to work properly.
141 */
142#define SW_PAD
143
144static const char *chip_ids[15] = {
145 NULL, NULL, NULL,

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

1435 uint8_t *af = mcf;
1436 struct ifmultiaddr *ifma;
1437
1438 bzero(mcf, MCFSZ);
1439
1440 TAILQ_FOREACH(ifma, &ac->ac_if.if_multiaddrs, ifma_link) {
1441 if (ifma->ifma_addr->sa_family != AF_LINK)
1442 return 0;
138
139/* I (GB) have been unlucky getting the hardware padding
140 * to work properly.
141 */
142#define SW_PAD
143
144static const char *chip_ids[15] = {
145 NULL, NULL, NULL,

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

1435 uint8_t *af = mcf;
1436 struct ifmultiaddr *ifma;
1437
1438 bzero(mcf, MCFSZ);
1439
1440 TAILQ_FOREACH(ifma, &ac->ac_if.if_multiaddrs, ifma_link) {
1441 if (ifma->ifma_addr->sa_family != AF_LINK)
1442 return 0;
1443 index = sn_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) & 0x3f;
1443 index = sn_mchash(
1444 LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) & 0x3f;
1444 index2 = 0;
1445 for (i = 0; i < 6; i++) {
1446 index2 <<= 1;
1447 index2 |= (index & 0x01);
1448 index >>= 1;
1449 }
1450 af[index2 >> 3] |= 1 << (index2 & 7);
1451 }
1452 return 1; /* use multicast filter */
1453}
1454
1445 index2 = 0;
1446 for (i = 0; i < 6; i++) {
1447 index2 <<= 1;
1448 index2 |= (index & 0x01);
1449 index >>= 1;
1450 }
1451 af[index2 >> 3] |= 1 << (index2 & 7);
1452 }
1453 return 1; /* use multicast filter */
1454}
1455
1455static u_int
1456sn_crc(u_char *s)
1456static u_int32_t
1457sn_mchash(caddr_t addr)
1457{
1458{
1458 int perByte;
1459 int perBit;
1460 const uint32_t poly = 0xedb88320;
1459 const uint32_t poly = 0xedb88320;
1461 uint32_t v = 0xffffffff;
1462 uint8_t c;
1463
1464 for (perByte = 0; perByte < ETHER_ADDR_LEN; perByte++) {
1465 c = s[perByte];
1466 for (perBit = 0; perBit < 8; perBit++) {
1467 v = (v >> 1)^(((v ^ c) & 0x01) ? poly : 0);
1468 c >>= 1;
1460 u_int32_t crc;
1461 int idx, bit;
1462 u_int8_t data;
1463
1464 /* Compute CRC for the address value. */
1465 crc = 0xFFFFFFFF; /* initial value */
1466
1467 for (idx = 0; idx < ETHER_ADDR_LEN; idx++) {
1468 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
1469 crc = (crc >> 1)^(((crc ^ data) & 0x01) ? poly : 0);
1469 }
1470 }
1470 }
1471 }
1471 return v;
1472 return crc;
1472}
1473}