if_sis.c (121816) | if_sis.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 --- 42 unchanged lines hidden (view full) --- 51 * Both chips offer the standard bit-bang MII interface as well as 52 * an enchanced PHY interface which simplifies accessing MII registers. 53 * 54 * The only downside to this chipset is that RX descriptors must be 55 * longword aligned. 56 */ 57 58#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 --- 42 unchanged lines hidden (view full) --- 51 * Both chips offer the standard bit-bang MII interface as well as 52 * an enchanced PHY interface which simplifies accessing MII registers. 53 * 54 * The only downside to this chipset is that RX descriptors must be 55 * longword aligned. 56 */ 57 58#include <sys/cdefs.h> |
59__FBSDID("$FreeBSD: head/sys/pci/if_sis.c 121816 2003-10-31 18:32:15Z brooks $"); | 59__FBSDID("$FreeBSD: head/sys/pci/if_sis.c 122625 2003-11-13 20:55:53Z obrien $"); |
60 61#include <sys/param.h> 62#include <sys/systm.h> 63#include <sys/sockio.h> 64#include <sys/mbuf.h> 65#include <sys/malloc.h> 66#include <sys/kernel.h> 67#include <sys/socket.h> --- 83 unchanged lines hidden (view full) --- 151static int sis_mii_readreg (struct sis_softc *, struct sis_mii_frame *); 152static int sis_mii_writereg (struct sis_softc *, struct sis_mii_frame *); 153static int sis_miibus_readreg (device_t, int, int); 154static int sis_miibus_writereg (device_t, int, int, int); 155static void sis_miibus_statchg (device_t); 156 157static void sis_setmulti_sis (struct sis_softc *); 158static void sis_setmulti_ns (struct sis_softc *); | 60 61#include <sys/param.h> 62#include <sys/systm.h> 63#include <sys/sockio.h> 64#include <sys/mbuf.h> 65#include <sys/malloc.h> 66#include <sys/kernel.h> 67#include <sys/socket.h> --- 83 unchanged lines hidden (view full) --- 151static int sis_mii_readreg (struct sis_softc *, struct sis_mii_frame *); 152static int sis_mii_writereg (struct sis_softc *, struct sis_mii_frame *); 153static int sis_miibus_readreg (device_t, int, int); 154static int sis_miibus_writereg (device_t, int, int, int); 155static void sis_miibus_statchg (device_t); 156 157static void sis_setmulti_sis (struct sis_softc *); 158static void sis_setmulti_ns (struct sis_softc *); |
159static u_int32_t sis_crc (struct sis_softc *, caddr_t); | 159static u_int32_t sis_mchash (struct sis_softc *, caddr_t); |
160static void sis_reset (struct sis_softc *); 161static int sis_list_rx_init (struct sis_softc *); 162static int sis_list_tx_init (struct sis_softc *); 163 164static void sis_dma_map_desc_ptr (void *, bus_dma_segment_t *, int, int); 165static void sis_dma_map_desc_next (void *, bus_dma_segment_t *, int, int); 166static void sis_dma_map_ring (void *, bus_dma_segment_t *, int, int); 167#ifdef SIS_USEIOSPACE --- 665 unchanged lines hidden (view full) --- 833 834 sc = device_get_softc(dev); 835 sis_init(sc); 836 837 return; 838} 839 840static u_int32_t | 160static void sis_reset (struct sis_softc *); 161static int sis_list_rx_init (struct sis_softc *); 162static int sis_list_tx_init (struct sis_softc *); 163 164static void sis_dma_map_desc_ptr (void *, bus_dma_segment_t *, int, int); 165static void sis_dma_map_desc_next (void *, bus_dma_segment_t *, int, int); 166static void sis_dma_map_ring (void *, bus_dma_segment_t *, int, int); 167#ifdef SIS_USEIOSPACE --- 665 unchanged lines hidden (view full) --- 833 834 sc = device_get_softc(dev); 835 sis_init(sc); 836 837 return; 838} 839 840static u_int32_t |
841sis_crc(sc, addr) | 841sis_mchash(sc, addr) |
842 struct sis_softc *sc; 843 caddr_t addr; 844{ 845 u_int32_t crc, carry; | 842 struct sis_softc *sc; 843 caddr_t addr; 844{ 845 u_int32_t crc, carry; |
846 int i, j; 847 u_int8_t c; | 846 int idx, bit; 847 u_int8_t data; |
848 849 /* Compute CRC for the address value. */ 850 crc = 0xFFFFFFFF; /* initial value */ 851 | 848 849 /* Compute CRC for the address value. */ 850 crc = 0xFFFFFFFF; /* initial value */ 851 |
852 for (i = 0; i < 6; i++) { 853 c = *(addr + i); 854 for (j = 0; j < 8; j++) { 855 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 852 for (idx = 0; idx < 6; idx++) { 853 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 854 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
856 crc <<= 1; | 855 crc <<= 1; |
857 c >>= 1; | |
858 if (carry) 859 crc = (crc ^ 0x04c11db6) | carry; 860 } 861 } 862 863 /* 864 * return the filter bit position 865 * --- 39 unchanged lines hidden (view full) --- 905 for (i = 0; i < 32; i++) { 906 CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + (i*2)); 907 CSR_WRITE_4(sc, SIS_RXFILT_DATA, 0); 908 } 909 910 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 911 if (ifma->ifma_addr->sa_family != AF_LINK) 912 continue; | 856 if (carry) 857 crc = (crc ^ 0x04c11db6) | carry; 858 } 859 } 860 861 /* 862 * return the filter bit position 863 * --- 39 unchanged lines hidden (view full) --- 903 for (i = 0; i < 32; i++) { 904 CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + (i*2)); 905 CSR_WRITE_4(sc, SIS_RXFILT_DATA, 0); 906 } 907 908 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 909 if (ifma->ifma_addr->sa_family != AF_LINK) 910 continue; |
913 h = sis_crc(sc, LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 911 h = sis_mchash(sc, 912 LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
914 index = h >> 3; 915 bit = h & 0x1F; 916 CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + index); 917 if (bit > 0xF) 918 bit -= 0x10; 919 SIS_SETBIT(sc, SIS_RXFILT_DATA, (1 << bit)); 920 } 921 --- 33 unchanged lines hidden (view full) --- 955 hashes[i] = ~0; 956 } else { 957 for (i = 0; i < n; i++) 958 hashes[i] = 0; 959 i = 0; 960 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 961 if (ifma->ifma_addr->sa_family != AF_LINK) 962 continue; | 913 index = h >> 3; 914 bit = h & 0x1F; 915 CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + index); 916 if (bit > 0xF) 917 bit -= 0x10; 918 SIS_SETBIT(sc, SIS_RXFILT_DATA, (1 << bit)); 919 } 920 --- 33 unchanged lines hidden (view full) --- 954 hashes[i] = ~0; 955 } else { 956 for (i = 0; i < n; i++) 957 hashes[i] = 0; 958 i = 0; 959 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 960 if (ifma->ifma_addr->sa_family != AF_LINK) 961 continue; |
963 h = sis_crc(sc, | 962 h = sis_mchash(sc, |
964 LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); 965 hashes[h >> 4] |= 1 << (h & 0xf); 966 i++; 967 } 968 if (i > n) { 969 ctl |= SIS_RXFILTCTL_ALLMULTI; 970 for (i = 0; i < n; i++) 971 hashes[i] = ~0; --- 1474 unchanged lines hidden --- | 963 LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); 964 hashes[h >> 4] |= 1 << (h & 0xf); 965 i++; 966 } 967 if (i > n) { 968 ctl |= SIS_RXFILTCTL_ALLMULTI; 969 for (i = 0; i < n; i++) 970 hashes[i] = ~0; --- 1474 unchanged lines hidden --- |