if_cs.c (104252) | if_cs.c (106937) |
---|---|
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/* | 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/* |
30 * $FreeBSD: head/sys/dev/cs/if_cs.c 104252 2002-10-01 00:46:41Z brooks $ | 30 * $FreeBSD: head/sys/dev/cs/if_cs.c 106937 2002-11-14 23:54:55Z sam $ |
31 * 32 * Device driver for Crystal Semiconductor CS8920 based ethernet 33 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997 34 */ 35 36/* 37#define CS_DEBUG 38 */ --- 613 unchanged lines hidden (view full) --- 652 case A_CNF_MEDIA_10B_T: media = IFM_ETHER|IFM_10_T; break; 653 case A_CNF_MEDIA_10B_2: media = IFM_ETHER|IFM_10_2; break; 654 case A_CNF_MEDIA_AUI: media = IFM_ETHER|IFM_10_5; break; 655 default: if_printf(ifp, "adapter has no media\n"); 656 } 657 ifmedia_set(&sc->media, media); 658 cs_mediaset(sc, media); 659 | 31 * 32 * Device driver for Crystal Semiconductor CS8920 based ethernet 33 * adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997 34 */ 35 36/* 37#define CS_DEBUG 38 */ --- 613 unchanged lines hidden (view full) --- 652 case A_CNF_MEDIA_10B_T: media = IFM_ETHER|IFM_10_T; break; 653 case A_CNF_MEDIA_10B_2: media = IFM_ETHER|IFM_10_2; break; 654 case A_CNF_MEDIA_AUI: media = IFM_ETHER|IFM_10_5; break; 655 default: if_printf(ifp, "adapter has no media\n"); 656 } 657 ifmedia_set(&sc->media, media); 658 cs_mediaset(sc, media); 659 |
660 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); | 660 ether_ifattach(ifp, sc->arpcom.ac_enaddr); |
661 } 662 663 if (bootverbose) 664 if_printf(ifp, "ethernet address %6D\n", 665 sc->arpcom.ac_enaddr, ":"); 666 667 return (0); 668} --- 76 unchanged lines hidden (view full) --- 745 * Start sending process 746 */ 747 cs_start(ifp); 748 749 (void) splx(s); 750} 751 752/* | 661 } 662 663 if (bootverbose) 664 if_printf(ifp, "ethernet address %6D\n", 665 sc->arpcom.ac_enaddr, ":"); 666 667 return (0); 668} --- 76 unchanged lines hidden (view full) --- 745 * Start sending process 746 */ 747 cs_start(ifp); 748 749 (void) splx(s); 750} 751 752/* |
753 * Get the packet from the board and send it to the upper layer 754 * via ether_input(). | 753 * Get the packet from the board and send it to the upper layer. |
755 */ 756static int 757cs_get_packet(struct cs_softc *sc) 758{ 759 struct ifnet *ifp = &(sc->arpcom.ac_if); 760 int iobase = sc->nic_addr, status, length; 761 struct ether_header *eh; 762 struct mbuf *m; --- 43 unchanged lines hidden (view full) --- 806#ifdef CS_DEBUG 807 for (i=0;i<length;i++) 808 printf(" %02x",(unsigned char)*((char *)(m->m_data+i))); 809 printf( "\n" ); 810#endif 811 812 if (status & (RX_IA | RX_BROADCAST) || 813 (ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) { | 754 */ 755static int 756cs_get_packet(struct cs_softc *sc) 757{ 758 struct ifnet *ifp = &(sc->arpcom.ac_if); 759 int iobase = sc->nic_addr, status, length; 760 struct ether_header *eh; 761 struct mbuf *m; --- 43 unchanged lines hidden (view full) --- 805#ifdef CS_DEBUG 806 for (i=0;i<length;i++) 807 printf(" %02x",(unsigned char)*((char *)(m->m_data+i))); 808 printf( "\n" ); 809#endif 810 811 if (status & (RX_IA | RX_BROADCAST) || 812 (ifp->if_flags & IFF_MULTICAST && status & RX_HASHED)) { |
814 m->m_pkthdr.len -= sizeof(struct ether_header); 815 m->m_len -= sizeof(struct ether_header); 816 m->m_data += sizeof(struct ether_header); 817 | |
818 /* Feed the packet to the upper layer */ | 813 /* Feed the packet to the upper layer */ |
819 ether_input(ifp, eh, m); | 814 (*ifp->if_input)(ifp, m); |
820 821 ifp->if_ipackets++; 822 823 if (length==ETHER_MAX_LEN-ETHER_CRC_LEN) 824 DELAY( cs_recv_delay ); 825 } else { 826 m_freem(m); 827 } --- 128 unchanged lines hidden (view full) --- 956 /* Skip zero-length packets */ 957 if (length == 0) { 958 m_freem(m); 959 continue; 960 } 961 962 cs_write_mbufs(sc, m); 963 | 815 816 ifp->if_ipackets++; 817 818 if (length==ETHER_MAX_LEN-ETHER_CRC_LEN) 819 DELAY( cs_recv_delay ); 820 } else { 821 m_freem(m); 822 } --- 128 unchanged lines hidden (view full) --- 951 /* Skip zero-length packets */ 952 if (length == 0) { 953 m_freem(m); 954 continue; 955 } 956 957 cs_write_mbufs(sc, m); 958 |
964 if (ifp->if_bpf) { 965 bpf_mtap(ifp, m); 966 } | 959 BPF_MTAP(ifp, m); |
967 968 m_freem(m); 969 } 970 971 /* 972 * Issue a SEND command 973 */ 974 cs_outw(sc, TX_CMD_PORT, sc->send_cmd); --- 105 unchanged lines hidden (view full) --- 1080 1081#ifdef CS_DEBUG 1082 if_printf(ifp, "ioctl(%lx)\n", command); 1083#endif 1084 1085 s=splimp(); 1086 1087 switch (command) { | 960 961 m_freem(m); 962 } 963 964 /* 965 * Issue a SEND command 966 */ 967 cs_outw(sc, TX_CMD_PORT, sc->send_cmd); --- 105 unchanged lines hidden (view full) --- 1073 1074#ifdef CS_DEBUG 1075 if_printf(ifp, "ioctl(%lx)\n", command); 1076#endif 1077 1078 s=splimp(); 1079 1080 switch (command) { |
1088 case SIOCSIFADDR: 1089 case SIOCGIFADDR: 1090 case SIOCSIFMTU: 1091 ether_ioctl(ifp, command, data); 1092 break; 1093 | |
1094 case SIOCSIFFLAGS: 1095 /* 1096 * Switch interface state between "running" and 1097 * "stopped", reflecting the UP flag. 1098 */ 1099 if (sc->arpcom.ac_if.if_flags & IFF_UP) { 1100 if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)==0) { 1101 cs_init(sc); --- 25 unchanged lines hidden (view full) --- 1127 break; 1128 1129 case SIOCSIFMEDIA: 1130 case SIOCGIFMEDIA: 1131 error = ifmedia_ioctl(ifp, ifr, &sc->media, command); 1132 break; 1133 1134 default: | 1081 case SIOCSIFFLAGS: 1082 /* 1083 * Switch interface state between "running" and 1084 * "stopped", reflecting the UP flag. 1085 */ 1086 if (sc->arpcom.ac_if.if_flags & IFF_UP) { 1087 if ((sc->arpcom.ac_if.if_flags & IFF_RUNNING)==0) { 1088 cs_init(sc); --- 25 unchanged lines hidden (view full) --- 1114 break; 1115 1116 case SIOCSIFMEDIA: 1117 case SIOCGIFMEDIA: 1118 error = ifmedia_ioctl(ifp, ifr, &sc->media, command); 1119 break; 1120 1121 default: |
1135 error = EINVAL; | 1122 ether_ioctl(ifp, command, data); 1123 break; |
1136 } 1137 1138 (void) splx(s); 1139 return error; 1140} 1141 1142/* 1143 * Device timeout/watchdog routine. Entered if the device neglects to --- 108 unchanged lines hidden --- | 1124 } 1125 1126 (void) splx(s); 1127 return error; 1128} 1129 1130/* 1131 * Device timeout/watchdog routine. Entered if the device neglects to --- 108 unchanged lines hidden --- |