Deleted Added
full compact
if_sk.c (113545) if_sk.c (113609)
1/*
2 * Copyright (c) 1997, 1998, 1999, 2000
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

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

62 * SysKonnect has the distinction of being the only vendor on the market
63 * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs,
64 * dual DMA queues, packet/MAC/transmit arbiters and direct access to the
65 * XMAC registers. This driver takes advantage of these features to allow
66 * both XMACs to operate as independent interfaces.
67 */
68
69#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1997, 1998, 1999, 2000
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

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

62 * SysKonnect has the distinction of being the only vendor on the market
63 * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs,
64 * dual DMA queues, packet/MAC/transmit arbiters and direct access to the
65 * XMAC registers. This driver takes advantage of these features to allow
66 * both XMACs to operate as independent interfaces.
67 */
68
69#include <sys/cdefs.h>
70__FBSDID("$FreeBSD: head/sys/dev/sk/if_sk.c 113545 2003-04-16 03:16:57Z mdodd $");
70__FBSDID("$FreeBSD: head/sys/dev/sk/if_sk.c 113609 2003-04-17 20:32:06Z njl $");
71
72#include <sys/param.h>
73#include <sys/systm.h>
74#include <sys/sockio.h>
75#include <sys/mbuf.h>
76#include <sys/malloc.h>
77#include <sys/kernel.h>
78#include <sys/socket.h>

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

111MODULE_DEPEND(sk, ether, 1, 1, 1);
112MODULE_DEPEND(sk, miibus, 1, 1, 1);
113
114/* "controller miibus0" required. See GENERIC if you get errors here. */
115#include "miibus_if.h"
116
117#ifndef lint
118static const char rcsid[] =
71
72#include <sys/param.h>
73#include <sys/systm.h>
74#include <sys/sockio.h>
75#include <sys/mbuf.h>
76#include <sys/malloc.h>
77#include <sys/kernel.h>
78#include <sys/socket.h>

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

111MODULE_DEPEND(sk, ether, 1, 1, 1);
112MODULE_DEPEND(sk, miibus, 1, 1, 1);
113
114/* "controller miibus0" required. See GENERIC if you get errors here. */
115#include "miibus_if.h"
116
117#ifndef lint
118static const char rcsid[] =
119 "$FreeBSD: head/sys/dev/sk/if_sk.c 113545 2003-04-16 03:16:57Z mdodd $";
119 "$FreeBSD: head/sys/dev/sk/if_sk.c 113609 2003-04-17 20:32:06Z njl $";
120#endif
121
122static struct sk_type sk_devs[] = {
123 { SK_VENDORID, SK_DEVICEID_GE, "SysKonnect Gigabit Ethernet" },
124 { 0, 0, NULL }
125};
126
127static int sk_probe (device_t);

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

1173
1174 /*
1175 * Do miibus setup.
1176 */
1177 sk_init_xmac(sc_if);
1178 if (mii_phy_probe(dev, &sc_if->sk_miibus,
1179 sk_ifmedia_upd, sk_ifmedia_sts)) {
1180 printf("skc%d: no PHY found!\n", sc_if->sk_unit);
120#endif
121
122static struct sk_type sk_devs[] = {
123 { SK_VENDORID, SK_DEVICEID_GE, "SysKonnect Gigabit Ethernet" },
124 { 0, 0, NULL }
125};
126
127static int sk_probe (device_t);

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

1173
1174 /*
1175 * Do miibus setup.
1176 */
1177 sk_init_xmac(sc_if);
1178 if (mii_phy_probe(dev, &sc_if->sk_miibus,
1179 sk_ifmedia_upd, sk_ifmedia_sts)) {
1180 printf("skc%d: no PHY found!\n", sc_if->sk_unit);
1181 ether_ifdetach(ifp);
1181 error = ENXIO;
1182 goto fail_xmac;
1183 }
1184
1185fail_xmac:
1186 SK_UNLOCK(sc);
1187 if (error) {
1188 /* Access should be ok even though lock has been dropped */

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

1330 device_set_ivars(sc->sk_devs[SK_PORT_B], port);
1331 }
1332
1333 /* Turn on the 'driver is loaded' LED. */
1334 CSR_WRITE_2(sc, SK_LED, SK_LED_GREEN_ON);
1335
1336 bus_generic_attach(dev);
1337
1182 error = ENXIO;
1183 goto fail_xmac;
1184 }
1185
1186fail_xmac:
1187 SK_UNLOCK(sc);
1188 if (error) {
1189 /* Access should be ok even though lock has been dropped */

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

1331 device_set_ivars(sc->sk_devs[SK_PORT_B], port);
1332 }
1333
1334 /* Turn on the 'driver is loaded' LED. */
1335 CSR_WRITE_2(sc, SK_LED, SK_LED_GREEN_ON);
1336
1337 bus_generic_attach(dev);
1338
1339 /* Hook interrupt last to avoid having to lock softc */
1338 error = bus_setup_intr(dev, sc->sk_irq, INTR_TYPE_NET,
1339 sk_intr, sc, &sc->sk_intrhand);
1340
1341 if (error) {
1342 printf("skc%d: couldn't set up irq\n", unit);
1343 goto fail;
1344 }
1345
1346fail:
1347 if (error)
1348 sk_detach(dev);
1349
1350 return(error);
1351}
1352
1340 error = bus_setup_intr(dev, sc->sk_irq, INTR_TYPE_NET,
1341 sk_intr, sc, &sc->sk_intrhand);
1342
1343 if (error) {
1344 printf("skc%d: couldn't set up irq\n", unit);
1345 goto fail;
1346 }
1347
1348fail:
1349 if (error)
1350 sk_detach(dev);
1351
1352 return(error);
1353}
1354
1355/*
1356 * Shutdown hardware and free up resources. This can be called any
1357 * time after the mutex has been initialized. It is called in both
1358 * the error case in attach and the normal detach case so it needs
1359 * to be careful about only freeing resources that have actually been
1360 * allocated.
1361 */
1353static int
1354sk_detach_xmac(dev)
1355 device_t dev;
1356{
1357 struct sk_softc *sc;
1358 struct sk_if_softc *sc_if;
1359 struct ifnet *ifp;
1360
1361 sc = device_get_softc(device_get_parent(dev));
1362 sc_if = device_get_softc(dev);
1363 KASSERT(mtx_initialized(&sc_if->sk_softc->sk_mtx),
1364 ("sk mutex not initialized in sk_detach_xmac"));
1365 SK_IF_LOCK(sc_if);
1366
1367 ifp = &sc_if->arpcom.ac_if;
1362static int
1363sk_detach_xmac(dev)
1364 device_t dev;
1365{
1366 struct sk_softc *sc;
1367 struct sk_if_softc *sc_if;
1368 struct ifnet *ifp;
1369
1370 sc = device_get_softc(device_get_parent(dev));
1371 sc_if = device_get_softc(dev);
1372 KASSERT(mtx_initialized(&sc_if->sk_softc->sk_mtx),
1373 ("sk mutex not initialized in sk_detach_xmac"));
1374 SK_IF_LOCK(sc_if);
1375
1376 ifp = &sc_if->arpcom.ac_if;
1377 /* These should only be active if attach_xmac succeeded */
1368 if (device_is_alive(dev)) {
1378 if (device_is_alive(dev)) {
1369 if (bus_child_present(dev))
1370 sk_stop(sc_if);
1379 sk_stop(sc_if);
1371 ether_ifdetach(ifp);
1380 ether_ifdetach(ifp);
1372 device_delete_child(dev, sc_if->sk_miibus);
1373 bus_generic_detach(dev);
1374 }
1381 }
1382 if (sc_if->sk_miibus)
1383 device_delete_child(dev, sc_if->sk_miibus);
1384 bus_generic_detach(dev);
1375 if (sc_if->sk_cdata.sk_jumbo_buf)
1376 contigfree(sc_if->sk_cdata.sk_jumbo_buf, SK_JMEM, M_DEVBUF);
1377 if (sc_if->sk_rdata) {
1378 contigfree(sc_if->sk_rdata, sizeof(struct sk_ring_data),
1379 M_DEVBUF);
1380 }
1381 SK_IF_UNLOCK(sc_if);
1382

--- 854 unchanged lines hidden ---
1385 if (sc_if->sk_cdata.sk_jumbo_buf)
1386 contigfree(sc_if->sk_cdata.sk_jumbo_buf, SK_JMEM, M_DEVBUF);
1387 if (sc_if->sk_rdata) {
1388 contigfree(sc_if->sk_rdata, sizeof(struct sk_ring_data),
1389 M_DEVBUF);
1390 }
1391 SK_IF_UNLOCK(sc_if);
1392

--- 854 unchanged lines hidden ---