Deleted Added
full compact
if_re.c (171263) if_re.c (171560)
1/*-
2 * Copyright (c) 1997, 1998-2003
3 * Bill Paul <wpaul@windriver.com>. 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

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

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
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, 1998-2003
3 * Bill Paul <wpaul@windriver.com>. 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

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

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
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 171263 2007-07-06 00:05:12Z yongari $");
34__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 171560 2007-07-24 01:24:03Z yongari $");
35
36/*
37 * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver
38 *
39 * Written by Bill Paul <wpaul@windriver.com>
40 * Senior Networking Software Engineer
41 * Wind River Systems
42 */

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

155
156/*
157 * Default to using PIO access for this driver.
158 */
159#define RE_USEIOSPACE
160
161#include <pci/if_rlreg.h>
162
35
36/*
37 * RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver
38 *
39 * Written by Bill Paul <wpaul@windriver.com>
40 * Senior Networking Software Engineer
41 * Wind River Systems
42 */

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

155
156/*
157 * Default to using PIO access for this driver.
158 */
159#define RE_USEIOSPACE
160
161#include <pci/if_rlreg.h>
162
163/* Tunables. */
164static int msi_disable = 0;
165TUNABLE_INT("hw.re.msi_disable", &msi_disable);
166
163#define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
164
165/*
166 * Various supported device vendors/types and their names.
167 */
168static struct rl_type re_devs[] = {
169 { DLINK_VENDORID, DLINK_DEVICEID_528T, RL_HWREV_8169S,
170 "D-Link DGE-528(T) Gigabit Ethernet Adapter" },

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

1154 u_char eaddr[ETHER_ADDR_LEN];
1155 u_int16_t as[ETHER_ADDR_LEN / 2];
1156 struct rl_softc *sc;
1157 struct ifnet *ifp;
1158 struct rl_hwrev *hw_rev;
1159 int hwrev;
1160 u_int16_t re_did = 0;
1161 int error = 0, rid, i;
167#define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
168
169/*
170 * Various supported device vendors/types and their names.
171 */
172static struct rl_type re_devs[] = {
173 { DLINK_VENDORID, DLINK_DEVICEID_528T, RL_HWREV_8169S,
174 "D-Link DGE-528(T) Gigabit Ethernet Adapter" },

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

1158 u_char eaddr[ETHER_ADDR_LEN];
1159 u_int16_t as[ETHER_ADDR_LEN / 2];
1160 struct rl_softc *sc;
1161 struct ifnet *ifp;
1162 struct rl_hwrev *hw_rev;
1163 int hwrev;
1164 u_int16_t re_did = 0;
1165 int error = 0, rid, i;
1166 int msic, reg;
1162
1163 sc = device_get_softc(dev);
1164 sc->rl_dev = dev;
1165
1166 mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1167 MTX_DEF);
1168 callout_init_mtx(&sc->rl_stat_callout, &sc->rl_mtx, 0);
1169

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

1180 device_printf(dev, "couldn't map ports/memory\n");
1181 error = ENXIO;
1182 goto fail;
1183 }
1184
1185 sc->rl_btag = rman_get_bustag(sc->rl_res);
1186 sc->rl_bhandle = rman_get_bushandle(sc->rl_res);
1187
1167
1168 sc = device_get_softc(dev);
1169 sc->rl_dev = dev;
1170
1171 mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1172 MTX_DEF);
1173 callout_init_mtx(&sc->rl_stat_callout, &sc->rl_mtx, 0);
1174

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

1185 device_printf(dev, "couldn't map ports/memory\n");
1186 error = ENXIO;
1187 goto fail;
1188 }
1189
1190 sc->rl_btag = rman_get_bustag(sc->rl_res);
1191 sc->rl_bhandle = rman_get_bushandle(sc->rl_res);
1192
1188 /* Allocate interrupt */
1189 rid = 0;
1190 sc->rl_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
1191 RF_SHAREABLE | RF_ACTIVE);
1193 msic = 0;
1194 if (pci_find_extcap(dev, PCIY_EXPRESS, &reg) == 0) {
1195 msic = pci_msi_count(dev);
1196 if (bootverbose)
1197 device_printf(dev, "MSI count : %d\n", msic);
1198 }
1199 if (msic == RL_MSI_MESSAGES && msi_disable == 0) {
1200 if (pci_alloc_msi(dev, &msic) == 0) {
1201 if (msic == RL_MSI_MESSAGES) {
1202 device_printf(dev, "Using %d MSI messages\n",
1203 msic);
1204 sc->rl_msi = 1;
1205 } else
1206 pci_release_msi(dev);
1207 }
1208 }
1192
1209
1193 if (sc->rl_irq == NULL) {
1194 device_printf(dev, "couldn't map interrupt\n");
1195 error = ENXIO;
1196 goto fail;
1210 /* Allocate interrupt */
1211 if (sc->rl_msi == 0) {
1212 rid = 0;
1213 sc->rl_irq[0] = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
1214 RF_SHAREABLE | RF_ACTIVE);
1215 if (sc->rl_irq[0] == NULL) {
1216 device_printf(dev, "couldn't allocate IRQ resources\n");
1217 error = ENXIO;
1218 goto fail;
1219 }
1220 } else {
1221 for (i = 0, rid = 1; i < RL_MSI_MESSAGES; i++, rid++) {
1222 sc->rl_irq[i] = bus_alloc_resource_any(dev,
1223 SYS_RES_IRQ, &rid, RF_ACTIVE);
1224 if (sc->rl_irq[i] == NULL) {
1225 device_printf(dev,
1226 "couldn't llocate IRQ resources for "
1227 "message %d\n", rid);
1228 error = ENXIO;
1229 goto fail;
1230 }
1231 }
1197 }
1198
1199 /* Reset the adapter. */
1200 RL_LOCK(sc);
1201 re_reset(sc);
1202 RL_UNLOCK(sc);
1203
1204 hw_rev = re_hwrevs;

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

1315 "attach aborted due to hardware diag failure\n");
1316 ether_ifdetach(ifp);
1317 goto fail;
1318 }
1319 }
1320#endif
1321
1322 /* Hook interrupt last to avoid having to lock softc */
1232 }
1233
1234 /* Reset the adapter. */
1235 RL_LOCK(sc);
1236 re_reset(sc);
1237 RL_UNLOCK(sc);
1238
1239 hw_rev = re_hwrevs;

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

1350 "attach aborted due to hardware diag failure\n");
1351 ether_ifdetach(ifp);
1352 goto fail;
1353 }
1354 }
1355#endif
1356
1357 /* Hook interrupt last to avoid having to lock softc */
1323 error = bus_setup_intr(dev, sc->rl_irq, INTR_TYPE_NET | INTR_MPSAFE,
1324 re_intr, NULL, sc, &sc->rl_intrhand);
1358 if (sc->rl_msi == 0)
1359 error = bus_setup_intr(dev, sc->rl_irq[0],
1360 INTR_TYPE_NET | INTR_MPSAFE, re_intr, NULL, sc,
1361 &sc->rl_intrhand[0]);
1362 else {
1363 for (i = 0; i < RL_MSI_MESSAGES; i++) {
1364 error = bus_setup_intr(dev, sc->rl_irq[i],
1365 INTR_TYPE_NET | INTR_MPSAFE, re_intr, NULL, sc,
1366 &sc->rl_intrhand[i]);
1367 if (error != 0)
1368 break;
1369 }
1370 }
1325 if (error) {
1326 device_printf(dev, "couldn't set up irq\n");
1327 ether_ifdetach(ifp);
1328 }
1329
1330fail:
1331
1332 if (error)

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

1343 * allocated.
1344 */
1345static int
1346re_detach(dev)
1347 device_t dev;
1348{
1349 struct rl_softc *sc;
1350 struct ifnet *ifp;
1371 if (error) {
1372 device_printf(dev, "couldn't set up irq\n");
1373 ether_ifdetach(ifp);
1374 }
1375
1376fail:
1377
1378 if (error)

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

1389 * allocated.
1390 */
1391static int
1392re_detach(dev)
1393 device_t dev;
1394{
1395 struct rl_softc *sc;
1396 struct ifnet *ifp;
1351 int i;
1397 int i, rid;
1352
1353 sc = device_get_softc(dev);
1354 ifp = sc->rl_ifp;
1355 KASSERT(mtx_initialized(&sc->rl_mtx), ("re mutex not initialized"));
1356
1357#ifdef DEVICE_POLLING
1358 if (ifp->if_capenable & IFCAP_POLLING)
1359 ether_poll_deregister(ifp);

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

1388 device_delete_child(dev, sc->rl_miibus);
1389 bus_generic_detach(dev);
1390
1391 /*
1392 * The rest is resource deallocation, so we should already be
1393 * stopped here.
1394 */
1395
1398
1399 sc = device_get_softc(dev);
1400 ifp = sc->rl_ifp;
1401 KASSERT(mtx_initialized(&sc->rl_mtx), ("re mutex not initialized"));
1402
1403#ifdef DEVICE_POLLING
1404 if (ifp->if_capenable & IFCAP_POLLING)
1405 ether_poll_deregister(ifp);

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

1434 device_delete_child(dev, sc->rl_miibus);
1435 bus_generic_detach(dev);
1436
1437 /*
1438 * The rest is resource deallocation, so we should already be
1439 * stopped here.
1440 */
1441
1396 if (sc->rl_intrhand)
1397 bus_teardown_intr(dev, sc->rl_irq, sc->rl_intrhand);
1442 for (i = 0; i < RL_MSI_MESSAGES; i++) {
1443 if (sc->rl_intrhand[i] != NULL) {
1444 bus_teardown_intr(dev, sc->rl_irq[i],
1445 sc->rl_intrhand[i]);
1446 sc->rl_intrhand[i] = NULL;
1447 }
1448 }
1398 if (ifp != NULL)
1399 if_free(ifp);
1449 if (ifp != NULL)
1450 if_free(ifp);
1400 if (sc->rl_irq)
1401 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->rl_irq);
1451 if (sc->rl_msi == 0) {
1452 if (sc->rl_irq[0] != NULL) {
1453 bus_release_resource(dev, SYS_RES_IRQ, 0,
1454 sc->rl_irq[0]);
1455 sc->rl_irq[0] = NULL;
1456 }
1457 } else {
1458 for (i = 0, rid = 1; i < RL_MSI_MESSAGES; i++, rid++) {
1459 if (sc->rl_irq[i] != NULL) {
1460 bus_release_resource(dev, SYS_RES_IRQ, rid,
1461 sc->rl_irq[i]);
1462 sc->rl_irq[i] = NULL;
1463 }
1464 }
1465 pci_release_msi(dev);
1466 }
1402 if (sc->rl_res)
1403 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
1404
1405 /* Unload and free the RX DMA ring memory and map */
1406
1407 if (sc->rl_ldata.rl_rx_list_tag) {
1408 bus_dmamap_unload(sc->rl_ldata.rl_rx_list_tag,
1409 sc->rl_ldata.rl_rx_list_map);

--- 1327 unchanged lines hidden ---
1467 if (sc->rl_res)
1468 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
1469
1470 /* Unload and free the RX DMA ring memory and map */
1471
1472 if (sc->rl_ldata.rl_rx_list_tag) {
1473 bus_dmamap_unload(sc->rl_ldata.rl_rx_list_tag,
1474 sc->rl_ldata.rl_rx_list_map);

--- 1327 unchanged lines hidden ---