if_rl.c (72813) | if_rl.c (78508) |
---|---|
1/* 2 * Copyright (c) 1997, 1998 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * | 1/* 2 * Copyright (c) 1997, 1998 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 --- 15 unchanged lines hidden (view full) --- 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * |
32 * $FreeBSD: head/sys/pci/if_rl.c 72813 2001-02-21 20:54:22Z wpaul $ | 32 * $FreeBSD: head/sys/pci/if_rl.c 78508 2001-06-20 19:48:35Z bmilekic $ |
33 */ 34 35/* 36 * RealTek 8129/8139 PCI NIC driver 37 * 38 * Supports several extremely cheap PCI 10/100 adapters based on 39 * the RealTek chipset. Datasheets can be obtained from 40 * www.realtek.com.tw. --- 87 unchanged lines hidden (view full) --- 128 * uniprocessor systems though. 129 */ 130#define RL_USEIOSPACE 131 132#include <pci/if_rlreg.h> 133 134#ifndef lint 135static const char rcsid[] = | 33 */ 34 35/* 36 * RealTek 8129/8139 PCI NIC driver 37 * 38 * Supports several extremely cheap PCI 10/100 adapters based on 39 * the RealTek chipset. Datasheets can be obtained from 40 * www.realtek.com.tw. --- 87 unchanged lines hidden (view full) --- 128 * uniprocessor systems though. 129 */ 130#define RL_USEIOSPACE 131 132#include <pci/if_rlreg.h> 133 134#ifndef lint 135static const char rcsid[] = |
136 "$FreeBSD: head/sys/pci/if_rl.c 72813 2001-02-21 20:54:22Z wpaul $"; | 136 "$FreeBSD: head/sys/pci/if_rl.c 78508 2001-06-20 19:48:35Z bmilekic $"; |
137#endif 138 139/* 140 * Various supported device vendors/types and their names. 141 */ 142static struct rl_type rl_devs[] = { 143 { RT_VENDORID, RT_DEVICEID_8129, 144 "RealTek 8129 10/100BaseTX" }, --- 913 unchanged lines hidden (view full) --- 1058 * The chip then begins copying frames into the RX buffer. Each frame 1059 * is preceded by a 32-bit RX status word which specifies the length 1060 * of the frame and certain other status bits. Each frame (starting with 1061 * the status word) is also 32-bit aligned. The frame length is in the 1062 * first 16 bits of the status word; the lower 15 bits correspond with 1063 * the 'rx status register' mentioned in the datasheet. 1064 * 1065 * Note: to make the Alpha happy, the frame payload needs to be aligned | 137#endif 138 139/* 140 * Various supported device vendors/types and their names. 141 */ 142static struct rl_type rl_devs[] = { 143 { RT_VENDORID, RT_DEVICEID_8129, 144 "RealTek 8129 10/100BaseTX" }, --- 913 unchanged lines hidden (view full) --- 1058 * The chip then begins copying frames into the RX buffer. Each frame 1059 * is preceded by a 32-bit RX status word which specifies the length 1060 * of the frame and certain other status bits. Each frame (starting with 1061 * the status word) is also 32-bit aligned. The frame length is in the 1062 * first 16 bits of the status word; the lower 15 bits correspond with 1063 * the 'rx status register' mentioned in the datasheet. 1064 * 1065 * Note: to make the Alpha happy, the frame payload needs to be aligned |
1066 * on a 32-bit boundary. To achieve this, we cheat a bit by copying from 1067 * the ring buffer starting at an address two bytes before the actual 1068 * data location. We can then shave off the first two bytes using m_adj(). 1069 * The reason we do this is because m_devget() doesn't let us specify an 1070 * offset into the mbuf storage space, so we have to artificially create 1071 * one. The ring is allocated in such a way that there are a few unused 1072 * bytes of space preceecing it so that it will be safe for us to do the 1073 * 2-byte backstep even if reading from the ring at offset 0. | 1066 * on a 32-bit boundary. To achieve this, we pass RL_ETHER_ALIGN (2 bytes) 1067 * as the offset argument to m_devget(). |
1074 */ 1075static void rl_rxeof(sc) 1076 struct rl_softc *sc; 1077{ 1078 struct ether_header *eh; 1079 struct mbuf *m; 1080 struct ifnet *ifp; 1081 int total_len = 0; --- 61 unchanged lines hidden (view full) --- 1143 ((cur_rx + sizeof(u_int32_t)) % RL_RXBUFLEN); 1144 1145 if (rxbufpos == (sc->rl_cdata.rl_rx_buf + RL_RXBUFLEN)) 1146 rxbufpos = sc->rl_cdata.rl_rx_buf; 1147 1148 wrap = (sc->rl_cdata.rl_rx_buf + RL_RXBUFLEN) - rxbufpos; 1149 1150 if (total_len > wrap) { | 1068 */ 1069static void rl_rxeof(sc) 1070 struct rl_softc *sc; 1071{ 1072 struct ether_header *eh; 1073 struct mbuf *m; 1074 struct ifnet *ifp; 1075 int total_len = 0; --- 61 unchanged lines hidden (view full) --- 1137 ((cur_rx + sizeof(u_int32_t)) % RL_RXBUFLEN); 1138 1139 if (rxbufpos == (sc->rl_cdata.rl_rx_buf + RL_RXBUFLEN)) 1140 rxbufpos = sc->rl_cdata.rl_rx_buf; 1141 1142 wrap = (sc->rl_cdata.rl_rx_buf + RL_RXBUFLEN) - rxbufpos; 1143 1144 if (total_len > wrap) { |
1151 /* 1152 * Fool m_devget() into thinking we want to copy 1153 * the whole buffer so we don't end up fragmenting 1154 * the data. 1155 */ 1156 m = m_devget(rxbufpos - RL_ETHER_ALIGN, 1157 total_len + RL_ETHER_ALIGN, 0, ifp, NULL); | 1145 m = m_devget(rxbufpos, total_len, RL_ETHER_ALIGN, ifp, 1146 NULL); |
1158 if (m == NULL) { 1159 ifp->if_ierrors++; 1160 printf("rl%d: out of mbufs, tried to " 1161 "copy %d bytes\n", sc->rl_unit, wrap); 1162 } else { | 1147 if (m == NULL) { 1148 ifp->if_ierrors++; 1149 printf("rl%d: out of mbufs, tried to " 1150 "copy %d bytes\n", sc->rl_unit, wrap); 1151 } else { |
1163 m_adj(m, RL_ETHER_ALIGN); | |
1164 m_copyback(m, wrap, total_len - wrap, 1165 sc->rl_cdata.rl_rx_buf); 1166 } 1167 cur_rx = (total_len - wrap + ETHER_CRC_LEN); 1168 } else { | 1152 m_copyback(m, wrap, total_len - wrap, 1153 sc->rl_cdata.rl_rx_buf); 1154 } 1155 cur_rx = (total_len - wrap + ETHER_CRC_LEN); 1156 } else { |
1169 m = m_devget(rxbufpos - RL_ETHER_ALIGN, 1170 total_len + RL_ETHER_ALIGN, 0, ifp, NULL); | 1157 m = m_devget(rxbufpos, total_len, RL_ETHER_ALIGN, ifp, 1158 NULL); |
1171 if (m == NULL) { 1172 ifp->if_ierrors++; 1173 printf("rl%d: out of mbufs, tried to " 1174 "copy %d bytes\n", sc->rl_unit, total_len); | 1159 if (m == NULL) { 1160 ifp->if_ierrors++; 1161 printf("rl%d: out of mbufs, tried to " 1162 "copy %d bytes\n", sc->rl_unit, total_len); |
1175 } else 1176 m_adj(m, RL_ETHER_ALIGN); | 1163 } |
1177 cur_rx += total_len + 4 + ETHER_CRC_LEN; 1178 } 1179 1180 /* 1181 * Round up to 32-bit boundary. 1182 */ 1183 cur_rx = (cur_rx + 3) & ~3; 1184 CSR_WRITE_2(sc, RL_CURRXADDR, cur_rx - 16); --- 502 unchanged lines hidden --- | 1164 cur_rx += total_len + 4 + ETHER_CRC_LEN; 1165 } 1166 1167 /* 1168 * Round up to 32-bit boundary. 1169 */ 1170 cur_rx = (cur_rx + 3) & ~3; 1171 CSR_WRITE_2(sc, RL_CURRXADDR, cur_rx - 16); --- 502 unchanged lines hidden --- |