Deleted Added
full compact
if_sf.c (121816) if_sf.c (122625)
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

73 * PCI memory mapped mode, the entire register space can be accessed
74 * directly. However in I/O space mode, only 256 bytes are directly
75 * mapped into PCI I/O space. The other registers can be accessed
76 * indirectly using the SF_INDIRECTIO_ADDR and SF_INDIRECTIO_DATA
77 * registers inside the 256-byte I/O window.
78 */
79
80#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. 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

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

73 * PCI memory mapped mode, the entire register space can be accessed
74 * directly. However in I/O space mode, only 256 bytes are directly
75 * mapped into PCI I/O space. The other registers can be accessed
76 * indirectly using the SF_INDIRECTIO_ADDR and SF_INDIRECTIO_DATA
77 * registers inside the 256-byte I/O window.
78 */
79
80#include <sys/cdefs.h>
81__FBSDID("$FreeBSD: head/sys/dev/sf/if_sf.c 121816 2003-10-31 18:32:15Z brooks $");
81__FBSDID("$FreeBSD: head/sys/dev/sf/if_sf.c 122625 2003-11-13 20:55:53Z obrien $");
82
83#include <sys/param.h>
84#include <sys/systm.h>
85#include <sys/sockio.h>
86#include <sys/mbuf.h>
87#include <sys/malloc.h>
88#include <sys/kernel.h>
89#include <sys/socket.h>

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

155static void sf_setmulti (struct sf_softc *);
156static int sf_setperf (struct sf_softc *, int, caddr_t);
157static int sf_sethash (struct sf_softc *, caddr_t, int);
158#ifdef notdef
159static int sf_setvlan (struct sf_softc *, int, u_int32_t);
160#endif
161
162static u_int8_t sf_read_eeprom (struct sf_softc *, int);
82
83#include <sys/param.h>
84#include <sys/systm.h>
85#include <sys/sockio.h>
86#include <sys/mbuf.h>
87#include <sys/malloc.h>
88#include <sys/kernel.h>
89#include <sys/socket.h>

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

155static void sf_setmulti (struct sf_softc *);
156static int sf_setperf (struct sf_softc *, int, caddr_t);
157static int sf_sethash (struct sf_softc *, caddr_t, int);
158#ifdef notdef
159static int sf_setvlan (struct sf_softc *, int, u_int32_t);
160#endif
161
162static u_int8_t sf_read_eeprom (struct sf_softc *, int);
163static u_int32_t sf_calchash (caddr_t);
163static u_int32_t sf_mchash (caddr_t);
164
165static int sf_miibus_readreg (device_t, int, int);
166static int sf_miibus_writereg (device_t, int, int, int);
167static void sf_miibus_statchg (device_t);
168
169static u_int32_t csr_read_4 (struct sf_softc *, int);
170static void csr_write_4 (struct sf_softc *, int, u_int32_t);
171static void sf_txthresh_adjust (struct sf_softc *);

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

255 CSR_WRITE_4(sc, SF_INDIRECTIO_DATA, val);
256#else
257 CSR_WRITE_4(sc, (reg + SF_RMAP_INTREG_BASE), val);
258#endif
259 return;
260}
261
262static u_int32_t
164
165static int sf_miibus_readreg (device_t, int, int);
166static int sf_miibus_writereg (device_t, int, int, int);
167static void sf_miibus_statchg (device_t);
168
169static u_int32_t csr_read_4 (struct sf_softc *, int);
170static void csr_write_4 (struct sf_softc *, int, u_int32_t);
171static void sf_txthresh_adjust (struct sf_softc *);

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

255 CSR_WRITE_4(sc, SF_INDIRECTIO_DATA, val);
256#else
257 CSR_WRITE_4(sc, (reg + SF_RMAP_INTREG_BASE), val);
258#endif
259 return;
260}
261
262static u_int32_t
263sf_calchash(addr)
264 caddr_t addr;
263sf_mchash(addr)
264 caddr_t addr;
265{
265{
266 u_int32_t crc, carry;
267 int i, j;
268 u_int8_t c;
266 u_int32_t crc, carry;
267 int idx, bit;
268 u_int8_t data;
269
270 /* Compute CRC for the address value. */
271 crc = 0xFFFFFFFF; /* initial value */
272
269
270 /* Compute CRC for the address value. */
271 crc = 0xFFFFFFFF; /* initial value */
272
273 for (i = 0; i < 6; i++) {
274 c = *(addr + i);
275 for (j = 0; j < 8; j++) {
276 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
273 for (idx = 0; idx < 6; idx++) {
274 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
275 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
277 crc <<= 1;
276 crc <<= 1;
278 c >>= 1;
279 if (carry)
280 crc = (crc ^ 0x04c11db6) | carry;
281 }
282 }
283
284 /* return the filter bit position */
285 return(crc >> 23 & 0x1FF);
286}

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

327 caddr_t mac;
328 int prio;
329{
330 u_int32_t h = 0;
331
332 if (mac == NULL)
333 return(EINVAL);
334
277 if (carry)
278 crc = (crc ^ 0x04c11db6) | carry;
279 }
280 }
281
282 /* return the filter bit position */
283 return(crc >> 23 & 0x1FF);
284}

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

325 caddr_t mac;
326 int prio;
327{
328 u_int32_t h = 0;
329
330 if (mac == NULL)
331 return(EINVAL);
332
335 h = sf_calchash(mac);
333 h = sf_mchash(mac);
336
337 if (prio) {
338 SF_SETBIT(sc, SF_RXFILT_HASH_BASE + SF_RXFILT_HASH_PRIOOFF +
339 (SF_RXFILT_HASH_SKIP * (h >> 4)), (1 << (h & 0xF)));
340 } else {
341 SF_SETBIT(sc, SF_RXFILT_HASH_BASE + SF_RXFILT_HASH_ADDROFF +
342 (SF_RXFILT_HASH_SKIP * (h >> 4)), (1 << (h & 0xF)));
343 }

--- 1194 unchanged lines hidden ---
334
335 if (prio) {
336 SF_SETBIT(sc, SF_RXFILT_HASH_BASE + SF_RXFILT_HASH_PRIOOFF +
337 (SF_RXFILT_HASH_SKIP * (h >> 4)), (1 << (h & 0xF)));
338 } else {
339 SF_SETBIT(sc, SF_RXFILT_HASH_BASE + SF_RXFILT_HASH_ADDROFF +
340 (SF_RXFILT_HASH_SKIP * (h >> 4)), (1 << (h & 0xF)));
341 }

--- 1194 unchanged lines hidden ---