if_cs.c (150306) | if_cs.c (156559) |
---|---|
1/*- 2 * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko. 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 --- 13 unchanged lines hidden (view full) --- 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 */ 28 29#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997,1998 Maxim Bolotin and Oleg Sharoiko. 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 --- 13 unchanged lines hidden (view full) --- 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 */ 28 29#include <sys/cdefs.h> |
30__FBSDID("$FreeBSD: head/sys/dev/cs/if_cs.c 150306 2005-09-19 03:10:21Z imp $"); | 30__FBSDID("$FreeBSD: head/sys/dev/cs/if_cs.c 156559 2006-03-10 23:50:53Z philip $"); |
31 32/* 33 * 34 * Device driver for Crystal Semiconductor CS8920 based ethernet 35 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997 36 */ 37 38/* --- 13 unchanged lines hidden (view full) --- 52#include <sys/module.h> 53#include <sys/bus.h> 54#include <machine/bus.h> 55#include <sys/rman.h> 56#include <machine/resource.h> 57 58#include <net/if.h> 59#include <net/if_arp.h> | 31 32/* 33 * 34 * Device driver for Crystal Semiconductor CS8920 based ethernet 35 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997 36 */ 37 38/* --- 13 unchanged lines hidden (view full) --- 52#include <sys/module.h> 53#include <sys/bus.h> 54#include <machine/bus.h> 55#include <sys/rman.h> 56#include <machine/resource.h> 57 58#include <net/if.h> 59#include <net/if_arp.h> |
60#include <net/if_dl.h> |
|
60#include <net/if_media.h> 61#include <net/if_types.h> 62#include <net/ethernet.h> 63#include <net/bpf.h> 64 65#include <dev/cs/if_csvar.h> 66#include <dev/cs/if_csreg.h> 67 --- 978 unchanged lines hidden (view full) --- 1046 */ 1047static void 1048cs_reset(struct cs_softc *sc) 1049{ 1050 cs_stop(sc); 1051 cs_init(sc); 1052} 1053 | 61#include <net/if_media.h> 62#include <net/if_types.h> 63#include <net/ethernet.h> 64#include <net/bpf.h> 65 66#include <dev/cs/if_csvar.h> 67#include <dev/cs/if_csreg.h> 68 --- 978 unchanged lines hidden (view full) --- 1047 */ 1048static void 1049cs_reset(struct cs_softc *sc) 1050{ 1051 cs_stop(sc); 1052 cs_init(sc); 1053} 1054 |
1055static uint16_t 1056cs_hash_index(struct sockaddr_dl *addr) 1057{ 1058 uint32_t crc; 1059 uint16_t idx; 1060 caddr_t lla; 1061 1062 lla = LLADDR(addr); 1063 crc = ether_crc32_le(lla, ETHER_ADDR_LEN); 1064 idx = crc >> 26; 1065 1066 return (idx); 1067} 1068 |
|
1054static void 1055cs_setmode(struct cs_softc *sc) 1056{ | 1069static void 1070cs_setmode(struct cs_softc *sc) 1071{ |
1057 struct ifnet *ifp = sc->ifp; | |
1058 int rx_ctl; | 1072 int rx_ctl; |
1073 uint16_t af[4]; 1074 uint16_t port, mask, index; 1075 struct ifnet *ifp = sc->ifp; 1076 struct ifmultiaddr *ifma; |
|
1059 1060 /* Stop the receiver while changing filters */ 1061 cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) & ~SERIAL_RX_ON); 1062 1063 if (ifp->if_flags & IFF_PROMISC) { 1064 /* Turn on promiscuous mode. */ 1065 rx_ctl = RX_OK_ACCEPT | RX_PROM_ACCEPT; | 1077 1078 /* Stop the receiver while changing filters */ 1079 cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) & ~SERIAL_RX_ON); 1080 1081 if (ifp->if_flags & IFF_PROMISC) { 1082 /* Turn on promiscuous mode. */ 1083 rx_ctl = RX_OK_ACCEPT | RX_PROM_ACCEPT; |
1066 } else { 1067 if (ifp->if_flags & IFF_MULTICAST) { 1068 /* Allow receiving frames with multicast addresses */ 1069 rx_ctl = RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | 1070 RX_OK_ACCEPT | RX_MULTCAST_ACCEPT; 1071 /* 1072 * Here the reconfiguration of chip's multicast 1073 * filters should be done but I've no idea about 1074 * hash transformation in this chip. If you can 1075 * add this code or describe me the transformation 1076 * I'd be very glad. 1077 */ | 1084 } else if (ifp->if_flags & IFF_MULTICAST) { 1085 /* Allow receiving frames with multicast addresses */ 1086 rx_ctl = RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | 1087 RX_OK_ACCEPT | RX_MULTCAST_ACCEPT; 1088 1089 /* Start with an empty filter */ 1090 af[0] = af[1] = af[2] = af[3] = 0x0000; 1091 1092 if (ifp->if_flags & IFF_ALLMULTI) { 1093 /* Accept all multicast frames */ 1094 af[0] = af[1] = af[2] = af[3] = 0xffff; |
1078 } else { | 1095 } else { |
1079 /* 1080 * Receive only good frames addressed for us and 1081 * good broadcasts. | 1096 /* 1097 * Set up the filter to only accept multicast 1098 * frames we're interested in. |
1082 */ | 1099 */ |
1083 rx_ctl = RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | 1084 RX_OK_ACCEPT; | 1100 IF_ADDR_LOCK(ifp); 1101 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 1102 struct sockaddr_dl *dl = 1103 (struct sockaddr_dl *)ifma->ifma_addr; 1104 1105 index = cs_hash_index(dl); 1106 port = (u_int16_t) (index >> 4); 1107 mask = (u_int16_t) (1 << (index & 0xf)); 1108 af[port] |= mask; 1109 } 1110 IF_ADDR_UNLOCK(ifp); |
1085 } | 1111 } |
1112 1113 cs_writereg(sc, PP_LAF + 0, af[0]); 1114 cs_writereg(sc, PP_LAF + 2, af[1]); 1115 cs_writereg(sc, PP_LAF + 4, af[2]); 1116 cs_writereg(sc, PP_LAF + 6, af[3]); 1117 } else { 1118 /* 1119 * Receive only good frames addressed for us and 1120 * good broadcasts. 1121 */ 1122 rx_ctl = RX_IA_ACCEPT | RX_BROADCAST_ACCEPT | 1123 RX_OK_ACCEPT; |
|
1086 } 1087 1088 /* Set up the filter */ 1089 cs_writereg(sc, PP_RxCTL, RX_DEF_ACCEPT | rx_ctl); 1090 1091 /* Turn on receiver */ 1092 cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) | SERIAL_RX_ON); 1093} --- 174 unchanged lines hidden --- | 1124 } 1125 1126 /* Set up the filter */ 1127 cs_writereg(sc, PP_RxCTL, RX_DEF_ACCEPT | rx_ctl); 1128 1129 /* Turn on receiver */ 1130 cs_writereg(sc, PP_LineCTL, cs_readreg(sc, PP_LineCTL) | SERIAL_RX_ON); 1131} --- 174 unchanged lines hidden --- |