if_xl.c (122160) | if_xl.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 --- 86 unchanged lines hidden (view full) --- 95 * support the PCI "boomerang" chips even though they work with the 96 * "vortex" driver in order to obtain better performance. 97 * 98 * This driver is in the /sys/pci directory because it only supports 99 * PCI-based NICs. 100 */ 101 102#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 --- 86 unchanged lines hidden (view full) --- 95 * support the PCI "boomerang" chips even though they work with the 96 * "vortex" driver in order to obtain better performance. 97 * 98 * This driver is in the /sys/pci directory because it only supports 99 * PCI-based NICs. 100 */ 101 102#include <sys/cdefs.h> |
103__FBSDID("$FreeBSD: head/sys/pci/if_xl.c 122160 2003-11-06 03:59:03Z imp $"); | 103__FBSDID("$FreeBSD: head/sys/pci/if_xl.c 122625 2003-11-13 20:55:53Z obrien $"); |
104 105#include <sys/param.h> 106#include <sys/systm.h> 107#include <sys/sockio.h> 108#include <sys/endian.h> 109#include <sys/mbuf.h> 110#include <sys/kernel.h> 111#include <sys/socket.h> --- 122 unchanged lines hidden (view full) --- 234static int xl_read_eeprom (struct xl_softc *, caddr_t, int, int, int); 235static void xl_mii_sync (struct xl_softc *); 236static void xl_mii_send (struct xl_softc *, u_int32_t, int); 237static int xl_mii_readreg (struct xl_softc *, struct xl_mii_frame *); 238static int xl_mii_writereg (struct xl_softc *, struct xl_mii_frame *); 239 240static void xl_setcfg (struct xl_softc *); 241static void xl_setmode (struct xl_softc *, int); | 104 105#include <sys/param.h> 106#include <sys/systm.h> 107#include <sys/sockio.h> 108#include <sys/endian.h> 109#include <sys/mbuf.h> 110#include <sys/kernel.h> 111#include <sys/socket.h> --- 122 unchanged lines hidden (view full) --- 234static int xl_read_eeprom (struct xl_softc *, caddr_t, int, int, int); 235static void xl_mii_sync (struct xl_softc *); 236static void xl_mii_send (struct xl_softc *, u_int32_t, int); 237static int xl_mii_readreg (struct xl_softc *, struct xl_mii_frame *); 238static int xl_mii_writereg (struct xl_softc *, struct xl_mii_frame *); 239 240static void xl_setcfg (struct xl_softc *); 241static void xl_setmode (struct xl_softc *, int); |
242static u_int8_t xl_calchash (caddr_t); | 242static u_int32_t xl_mchash (caddr_t); |
243static void xl_setmulti (struct xl_softc *); 244static void xl_setmulti_hash (struct xl_softc *); 245static void xl_reset (struct xl_softc *); 246static int xl_list_rx_init (struct xl_softc *); 247static int xl_list_tx_init (struct xl_softc *); 248static int xl_list_tx_init_90xB (struct xl_softc *); 249static void xl_wait (struct xl_softc *); 250static void xl_mediacheck (struct xl_softc *); --- 554 unchanged lines hidden (view full) --- 805 * which means we really only need 6 bits, but the manual indicates 806 * that future chip revisions will have a 256-bit hash table, 807 * hence the routine is set up to calculate 8 bits of position 808 * info in case we need it some day. 809 * Note II, The Sequel: _CURRENT_ versions of the 3c905B have a 810 * 256 bit hash table. This means we have to use all 8 bits regardless. 811 * On older cards, the upper 2 bits will be ignored. Grrrr.... 812 */ | 243static void xl_setmulti (struct xl_softc *); 244static void xl_setmulti_hash (struct xl_softc *); 245static void xl_reset (struct xl_softc *); 246static int xl_list_rx_init (struct xl_softc *); 247static int xl_list_tx_init (struct xl_softc *); 248static int xl_list_tx_init_90xB (struct xl_softc *); 249static void xl_wait (struct xl_softc *); 250static void xl_mediacheck (struct xl_softc *); --- 554 unchanged lines hidden (view full) --- 805 * which means we really only need 6 bits, but the manual indicates 806 * that future chip revisions will have a 256-bit hash table, 807 * hence the routine is set up to calculate 8 bits of position 808 * info in case we need it some day. 809 * Note II, The Sequel: _CURRENT_ versions of the 3c905B have a 810 * 256 bit hash table. This means we have to use all 8 bits regardless. 811 * On older cards, the upper 2 bits will be ignored. Grrrr.... 812 */ |
813static u_int8_t xl_calchash(addr) 814 caddr_t addr; | 813static u_int32_t 814xl_mchash(addr) 815 caddr_t addr; |
815{ | 816{ |
816 u_int32_t crc, carry; 817 int i, j; 818 u_int8_t c; | 817 u_int32_t crc, carry; 818 int idx, bit; 819 u_int8_t data; |
819 820 /* Compute CRC for the address value. */ 821 crc = 0xFFFFFFFF; /* initial value */ 822 | 820 821 /* Compute CRC for the address value. */ 822 crc = 0xFFFFFFFF; /* initial value */ 823 |
823 for (i = 0; i < 6; i++) { 824 c = *(addr + i); 825 for (j = 0; j < 8; j++) { 826 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 824 for (idx = 0; idx < 6; idx++) { 825 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 826 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
827 crc <<= 1; | 827 crc <<= 1; |
828 c >>= 1; | |
829 if (carry) 830 crc = (crc ^ 0x04c11db6) | carry; 831 } 832 } 833 834 /* return the filter bit position */ 835 return(crc & 0x000000FF); 836} --- 64 unchanged lines hidden (view full) --- 901 /* first, zot all the existing hash bits */ 902 for (i = 0; i < XL_HASHFILT_SIZE; i++) 903 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH|i); 904 905 /* now program new ones */ 906 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 907 if (ifma->ifma_addr->sa_family != AF_LINK) 908 continue; | 828 if (carry) 829 crc = (crc ^ 0x04c11db6) | carry; 830 } 831 } 832 833 /* return the filter bit position */ 834 return(crc & 0x000000FF); 835} --- 64 unchanged lines hidden (view full) --- 900 /* first, zot all the existing hash bits */ 901 for (i = 0; i < XL_HASHFILT_SIZE; i++) 902 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH|i); 903 904 /* now program new ones */ 905 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 906 if (ifma->ifma_addr->sa_family != AF_LINK) 907 continue; |
909 h = xl_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 908 h = xl_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
910 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH|XL_HASH_SET|h); 911 mcnt++; 912 } 913 914 if (mcnt) 915 rxfilt |= XL_RXFILTER_MULTIHASH; 916 else 917 rxfilt &= ~XL_RXFILTER_MULTIHASH; --- 2428 unchanged lines hidden --- | 909 CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH|XL_HASH_SET|h); 910 mcnt++; 911 } 912 913 if (mcnt) 914 rxfilt |= XL_RXFILTER_MULTIHASH; 915 else 916 rxfilt &= ~XL_RXFILTER_MULTIHASH; --- 2428 unchanged lines hidden --- |