Deleted Added
full compact
if_sis.c (99163) if_sis.c (101340)
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

--- 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, 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

--- 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_sis.c 99163 2002-06-30 21:59:08Z luigi $
32 * $FreeBSD: head/sys/pci/if_sis.c 101340 2002-08-04 21:52:05Z luigi $
33 */
34
35/*
36 * SiS 900/SiS 7016 fast ethernet PCI NIC driver. Datasheets are
37 * available from http://www.sis.com.tw.
38 *
39 * This driver also supports the NatSemi DP83815. Datasheets are
40 * available from http://www.national.com.

--- 54 unchanged lines hidden (view full) ---

95
96MODULE_DEPEND(sis, miibus, 1, 1, 1);
97
98/* "controller miibus0" required. See GENERIC if you get errors here. */
99#include "miibus_if.h"
100
101#ifndef lint
102static const char rcsid[] =
33 */
34
35/*
36 * SiS 900/SiS 7016 fast ethernet PCI NIC driver. Datasheets are
37 * available from http://www.sis.com.tw.
38 *
39 * This driver also supports the NatSemi DP83815. Datasheets are
40 * available from http://www.national.com.

--- 54 unchanged lines hidden (view full) ---

95
96MODULE_DEPEND(sis, miibus, 1, 1, 1);
97
98/* "controller miibus0" required. See GENERIC if you get errors here. */
99#include "miibus_if.h"
100
101#ifndef lint
102static const char rcsid[] =
103 "$FreeBSD: head/sys/pci/if_sis.c 99163 2002-06-30 21:59:08Z luigi $";
103 "$FreeBSD: head/sys/pci/if_sis.c 101340 2002-08-04 21:52:05Z luigi $";
104#endif
105
106/*
107 * Various supported device vendors/types and their names.
108 */
109static struct sis_type sis_devs[] = {
110 { SIS_VENDORID, SIS_DEVICEID_900, "SiS 900 10/100BaseTX" },
111 { SIS_VENDORID, SIS_DEVICEID_7016, "SiS 7016 10/100BaseTX" },

--- 80 unchanged lines hidden (view full) ---

192static driver_t sis_driver = {
193 "sis",
194 sis_methods,
195 sizeof(struct sis_softc)
196};
197
198static devclass_t sis_devclass;
199
104#endif
105
106/*
107 * Various supported device vendors/types and their names.
108 */
109static struct sis_type sis_devs[] = {
110 { SIS_VENDORID, SIS_DEVICEID_900, "SiS 900 10/100BaseTX" },
111 { SIS_VENDORID, SIS_DEVICEID_7016, "SiS 7016 10/100BaseTX" },

--- 80 unchanged lines hidden (view full) ---

192static driver_t sis_driver = {
193 "sis",
194 sis_methods,
195 sizeof(struct sis_softc)
196};
197
198static devclass_t sis_devclass;
199
200#ifdef __i386__
201static int sis_quick=1;
202SYSCTL_INT(_hw, OID_AUTO, sis_quick, CTLFLAG_RW,
203 &sis_quick,0,"do not mdevget in sis driver");
204#endif
205
206DRIVER_MODULE(if_sis, pci, sis_driver, sis_devclass, 0, 0);
207DRIVER_MODULE(miibus, sis, miibus_driver, miibus_devclass, 0, 0);
208
209#define SIS_SETBIT(sc, reg, x) \
210 CSR_WRITE_4(sc, reg, \
211 CSR_READ_4(sc, reg) | (x))
212
213#define SIS_CLRBIT(sc, reg, x) \

--- 1030 unchanged lines hidden (view full) ---

1244/*
1245 * Initialize an RX descriptor and attach an MBUF cluster.
1246 */
1247static int sis_newbuf(sc, c, m)
1248 struct sis_softc *sc;
1249 struct sis_desc *c;
1250 struct mbuf *m;
1251{
200DRIVER_MODULE(if_sis, pci, sis_driver, sis_devclass, 0, 0);
201DRIVER_MODULE(miibus, sis, miibus_driver, miibus_devclass, 0, 0);
202
203#define SIS_SETBIT(sc, reg, x) \
204 CSR_WRITE_4(sc, reg, \
205 CSR_READ_4(sc, reg) | (x))
206
207#define SIS_CLRBIT(sc, reg, x) \

--- 1030 unchanged lines hidden (view full) ---

1238/*
1239 * Initialize an RX descriptor and attach an MBUF cluster.
1240 */
1241static int sis_newbuf(sc, c, m)
1242 struct sis_softc *sc;
1243 struct sis_desc *c;
1244 struct mbuf *m;
1245{
1252 struct mbuf *m_new = NULL;
1253
1254 if (c == NULL)
1255 return(EINVAL);
1256
1257 if (m == NULL) {
1246
1247 if (c == NULL)
1248 return(EINVAL);
1249
1250 if (m == NULL) {
1258 MGETHDR(m_new, M_DONTWAIT, MT_DATA);
1259 if (m_new == NULL)
1251 m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
1252 if (m == NULL)
1260 return(ENOBUFS);
1253 return(ENOBUFS);
1254 } else
1255 m->m_data = m->m_ext.ext_buf;
1256 m->m_len = m->m_pkthdr.len = MCLBYTES;
1261
1257
1262 MCLGET(m_new, M_DONTWAIT);
1263 if (!(m_new->m_flags & M_EXT)) {
1264 m_freem(m_new);
1265 return(ENOBUFS);
1266 }
1267 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
1268 } else {
1269 m_new = m;
1270 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES;
1271 m_new->m_data = m_new->m_ext.ext_buf;
1272 }
1258 m_adj(m, sizeof(u_int64_t));
1273
1259
1274 m_adj(m_new, sizeof(u_int64_t));
1275
1276 c->sis_mbuf = m_new;
1260 c->sis_mbuf = m;
1277 c->sis_ctl = SIS_RXLEN;
1278
1279 bus_dmamap_create(sc->sis_tag, 0, &c->sis_map);
1280 bus_dmamap_load(sc->sis_tag, c->sis_map,
1261 c->sis_ctl = SIS_RXLEN;
1262
1263 bus_dmamap_create(sc->sis_tag, 0, &c->sis_map);
1264 bus_dmamap_load(sc->sis_tag, c->sis_map,
1281 mtod(m_new, void *), m_new->m_len,
1265 mtod(m, void *), m->m_len,
1282 sis_dma_map_desc_ptr, c, 0);
1283 bus_dmamap_sync(sc->sis_tag, c->sis_map, BUS_DMASYNC_PREWRITE);
1284
1285 return(0);
1286}
1287
1288/*
1289 * A frame has been uploaded: pass the resulting mbuf chain up to

--- 52 unchanged lines hidden (view full) ---

1342 * On the x86 we do not have alignment problems, so try to
1343 * allocate a new buffer for the receive ring, and pass up
1344 * the one where the packet is already, saving the expensive
1345 * copy done in m_devget().
1346 * If we are on an architecture with alignment problems, or
1347 * if the allocation fails, then use m_devget and leave the
1348 * existing buffer in the receive ring.
1349 */
1266 sis_dma_map_desc_ptr, c, 0);
1267 bus_dmamap_sync(sc->sis_tag, c->sis_map, BUS_DMASYNC_PREWRITE);
1268
1269 return(0);
1270}
1271
1272/*
1273 * A frame has been uploaded: pass the resulting mbuf chain up to

--- 52 unchanged lines hidden (view full) ---

1326 * On the x86 we do not have alignment problems, so try to
1327 * allocate a new buffer for the receive ring, and pass up
1328 * the one where the packet is already, saving the expensive
1329 * copy done in m_devget().
1330 * If we are on an architecture with alignment problems, or
1331 * if the allocation fails, then use m_devget and leave the
1332 * existing buffer in the receive ring.
1333 */
1350 if (sis_quick && sis_newbuf(sc, cur_rx, NULL) == 0) {
1334 if (sis_newbuf(sc, cur_rx, NULL) == 0) {
1351 m->m_pkthdr.rcvif = ifp;
1352 m->m_pkthdr.len = m->m_len = total_len;
1353 } else
1354#endif
1355 {
1356 struct mbuf *m0;
1357 m0 = m_devget(mtod(m, char *), total_len,
1358 ETHER_ALIGN, ifp, NULL);

--- 719 unchanged lines hidden ---
1335 m->m_pkthdr.rcvif = ifp;
1336 m->m_pkthdr.len = m->m_len = total_len;
1337 } else
1338#endif
1339 {
1340 struct mbuf *m0;
1341 m0 = m_devget(mtod(m, char *), total_len,
1342 ETHER_ALIGN, ifp, NULL);

--- 719 unchanged lines hidden ---