Deleted Added
full compact
if_my.c (121816) if_my.c (122625)
1/*-
2 * Written by: yen_cw@myson.com.tw
3 * Copyright (c) 2002 Myson Technology Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * Myson fast ethernet PCI NIC driver, available at: http://www.myson.com.tw/
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Written by: yen_cw@myson.com.tw
3 * Copyright (c) 2002 Myson Technology Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

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

23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * Myson fast ethernet PCI NIC driver, available at: http://www.myson.com.tw/
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/dev/my/if_my.c 121816 2003-10-31 18:32:15Z brooks $");
31__FBSDID("$FreeBSD: head/sys/dev/my/if_my.c 122625 2003-11-13 20:55:53Z obrien $");
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sockio.h>
36#include <sys/mbuf.h>
37#include <sys/malloc.h>
38#include <sys/kernel.h>
39#include <sys/socket.h>

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

137static void my_ifmedia_sts(struct ifnet *, struct ifmediareq *);
138static u_int16_t my_phy_readreg(struct my_softc *, int);
139static void my_phy_writereg(struct my_softc *, int, int);
140static void my_autoneg_xmit(struct my_softc *);
141static void my_autoneg_mii(struct my_softc *, int, int);
142static void my_setmode_mii(struct my_softc *, int);
143static void my_getmode_mii(struct my_softc *);
144static void my_setcfg(struct my_softc *, int);
32
33#include <sys/param.h>
34#include <sys/systm.h>
35#include <sys/sockio.h>
36#include <sys/mbuf.h>
37#include <sys/malloc.h>
38#include <sys/kernel.h>
39#include <sys/socket.h>

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

137static void my_ifmedia_sts(struct ifnet *, struct ifmediareq *);
138static u_int16_t my_phy_readreg(struct my_softc *, int);
139static void my_phy_writereg(struct my_softc *, int, int);
140static void my_autoneg_xmit(struct my_softc *);
141static void my_autoneg_mii(struct my_softc *, int, int);
142static void my_setmode_mii(struct my_softc *, int);
143static void my_getmode_mii(struct my_softc *);
144static void my_setcfg(struct my_softc *, int);
145static u_int8_t my_calchash(caddr_t);
145static u_int32_t my_mchash(caddr_t);
146static void my_setmulti(struct my_softc *);
147static void my_reset(struct my_softc *);
148static int my_list_rx_init(struct my_softc *);
149static int my_list_tx_init(struct my_softc *);
150static long my_send_cmd_to_phy(struct my_softc *, int, int);
151
152#define MY_SETBIT(sc, reg, x) CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | (x))
153#define MY_CLRBIT(sc, reg, x) CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~(x))

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

308 /* low MDC */
309 miir &= ~MY_MASK_MIIR_MII_MDC;
310 CSR_WRITE_4(sc, MY_MANAGEMENT, miir);
311 }
312 MY_UNLOCK(sc);
313 return;
314}
315
146static void my_setmulti(struct my_softc *);
147static void my_reset(struct my_softc *);
148static int my_list_rx_init(struct my_softc *);
149static int my_list_tx_init(struct my_softc *);
150static long my_send_cmd_to_phy(struct my_softc *, int, int);
151
152#define MY_SETBIT(sc, reg, x) CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) | (x))
153#define MY_CLRBIT(sc, reg, x) CSR_WRITE_4(sc, reg, CSR_READ_4(sc, reg) & ~(x))

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

308 /* low MDC */
309 miir &= ~MY_MASK_MIIR_MII_MDC;
310 CSR_WRITE_4(sc, MY_MANAGEMENT, miir);
311 }
312 MY_UNLOCK(sc);
313 return;
314}
315
316static u_int8_t
317my_calchash(caddr_t addr)
316static u_int32_t
317my_mchash(caddr_t addr)
318{
319 u_int32_t crc, carry;
318{
319 u_int32_t crc, carry;
320 int i, j;
321 u_int8_t c;
320 int idx, bit;
321 u_int8_t data;
322
323 /* Compute CRC for the address value. */
324 crc = 0xFFFFFFFF; /* initial value */
325
322
323 /* Compute CRC for the address value. */
324 crc = 0xFFFFFFFF; /* initial value */
325
326 for (i = 0; i < 6; i++) {
327 c = *(addr + i);
328 for (j = 0; j < 8; j++) {
329 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
326 for (idx = 0; idx < 6; idx++) {
327 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
328 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
330 crc <<= 1;
329 crc <<= 1;
331 c >>= 1;
332 if (carry)
333 crc = (crc ^ 0x04c11db6) | carry;
334 }
335 }
336
337 /*
338 * return the filter bit position Note: I arrived at the following
339 * nonsense through experimentation. It's not the usual way to

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

376 /* first, zot all the existing hash bits */
377 CSR_WRITE_4(sc, MY_MAR0, 0);
378 CSR_WRITE_4(sc, MY_MAR1, 0);
379
380 /* now program new ones */
381 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
382 if (ifma->ifma_addr->sa_family != AF_LINK)
383 continue;
330 if (carry)
331 crc = (crc ^ 0x04c11db6) | carry;
332 }
333 }
334
335 /*
336 * return the filter bit position Note: I arrived at the following
337 * nonsense through experimentation. It's not the usual way to

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

374 /* first, zot all the existing hash bits */
375 CSR_WRITE_4(sc, MY_MAR0, 0);
376 CSR_WRITE_4(sc, MY_MAR1, 0);
377
378 /* now program new ones */
379 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
380 if (ifma->ifma_addr->sa_family != AF_LINK)
381 continue;
384 h = my_calchash(LLADDR((struct sockaddr_dl *) ifma->ifma_addr));
382 h = my_mchash(LLADDR((struct sockaddr_dl *) ifma->ifma_addr));
385 if (h < 32)
386 hashes[0] |= (1 << h);
387 else
388 hashes[1] |= (1 << (h - 32));
389 mcnt++;
390 }
391
392 if (mcnt)

--- 1483 unchanged lines hidden ---
383 if (h < 32)
384 hashes[0] |= (1 << h);
385 else
386 hashes[1] |= (1 << (h - 32));
387 mcnt++;
388 }
389
390 if (mcnt)

--- 1483 unchanged lines hidden ---