Deleted Added
full compact
if_re.c (180168) if_re.c (180169)
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 180168 2008-07-02 05:01:19Z yongari $");
34__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 180169 2008-07-02 05:21:09Z 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 */

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

150
151MODULE_DEPEND(re, pci, 1, 1, 1);
152MODULE_DEPEND(re, ether, 1, 1, 1);
153MODULE_DEPEND(re, miibus, 1, 1, 1);
154
155/* "device miibus" required. See GENERIC if you get errors here. */
156#include "miibus_if.h"
157
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 */

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

150
151MODULE_DEPEND(re, pci, 1, 1, 1);
152MODULE_DEPEND(re, ether, 1, 1, 1);
153MODULE_DEPEND(re, miibus, 1, 1, 1);
154
155/* "device miibus" required. See GENERIC if you get errors here. */
156#include "miibus_if.h"
157
158/*
159 * Default to using PIO access for this driver.
160 */
161#define RE_USEIOSPACE
162
163/* Tunables. */
164static int msi_disable = 1;
165TUNABLE_INT("hw.re.msi_disable", &msi_disable);
166
167#define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
168
169/*
170 * Various supported device vendors/types and their names.

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

267static void re_reset (struct rl_softc *);
268static void re_setwol (struct rl_softc *);
269static void re_clrwol (struct rl_softc *);
270
271#ifdef RE_DIAG
272static int re_diag (struct rl_softc *);
273#endif
274
158/* Tunables. */
159static int msi_disable = 1;
160TUNABLE_INT("hw.re.msi_disable", &msi_disable);
161
162#define RE_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
163
164/*
165 * Various supported device vendors/types and their names.

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

262static void re_reset (struct rl_softc *);
263static void re_setwol (struct rl_softc *);
264static void re_clrwol (struct rl_softc *);
265
266#ifdef RE_DIAG
267static int re_diag (struct rl_softc *);
268#endif
269
275#ifdef RE_USEIOSPACE
276#define RL_RES SYS_RES_IOPORT
277#define RL_RID RL_PCI_LOIO
278#else
279#define RL_RES SYS_RES_MEMORY
280#define RL_RID RL_PCI_LOMEM
281#endif
282
283static device_method_t re_methods[] = {
284 /* Device interface */
285 DEVMETHOD(device_probe, re_probe),
286 DEVMETHOD(device_attach, re_attach),
287 DEVMETHOD(device_detach, re_detach),
288 DEVMETHOD(device_suspend, re_suspend),
289 DEVMETHOD(device_resume, re_resume),
290 DEVMETHOD(device_shutdown, re_shutdown),

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

1124 device_t dev;
1125{
1126 u_char eaddr[ETHER_ADDR_LEN];
1127 u_int16_t as[ETHER_ADDR_LEN / 2];
1128 struct rl_softc *sc;
1129 struct ifnet *ifp;
1130 struct rl_hwrev *hw_rev;
1131 int hwrev;
270static device_method_t re_methods[] = {
271 /* Device interface */
272 DEVMETHOD(device_probe, re_probe),
273 DEVMETHOD(device_attach, re_attach),
274 DEVMETHOD(device_detach, re_detach),
275 DEVMETHOD(device_suspend, re_suspend),
276 DEVMETHOD(device_resume, re_resume),
277 DEVMETHOD(device_shutdown, re_shutdown),

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

1111 device_t dev;
1112{
1113 u_char eaddr[ETHER_ADDR_LEN];
1114 u_int16_t as[ETHER_ADDR_LEN / 2];
1115 struct rl_softc *sc;
1116 struct ifnet *ifp;
1117 struct rl_hwrev *hw_rev;
1118 int hwrev;
1132 u_int16_t re_did = 0;
1119 u_int16_t devid, re_did = 0;
1133 int error = 0, rid, i;
1134 int msic, reg;
1135 uint8_t cfg;
1136
1137 sc = device_get_softc(dev);
1138 sc->rl_dev = dev;
1139
1140 mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1141 MTX_DEF);
1142 callout_init_mtx(&sc->rl_stat_callout, &sc->rl_mtx, 0);
1143
1144 /*
1145 * Map control/status registers.
1146 */
1147 pci_enable_busmaster(dev);
1148
1120 int error = 0, rid, i;
1121 int msic, reg;
1122 uint8_t cfg;
1123
1124 sc = device_get_softc(dev);
1125 sc->rl_dev = dev;
1126
1127 mtx_init(&sc->rl_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1128 MTX_DEF);
1129 callout_init_mtx(&sc->rl_stat_callout, &sc->rl_mtx, 0);
1130
1131 /*
1132 * Map control/status registers.
1133 */
1134 pci_enable_busmaster(dev);
1135
1149 rid = RL_RID;
1150 sc->rl_res = bus_alloc_resource_any(dev, RL_RES, &rid,
1151 RF_ACTIVE);
1136 devid = pci_get_device(dev);
1137 /* Prefer memory space register mapping over IO space. */
1138 sc->rl_res_id = PCIR_BAR(1);
1139 sc->rl_res_type = SYS_RES_MEMORY;
1140 /* RTL8168/8101E seems to use different BARs. */
1141 if (devid == RT_DEVICEID_8168 || devid == RT_DEVICEID_8101E)
1142 sc->rl_res_id = PCIR_BAR(2);
1143 sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type,
1144 &sc->rl_res_id, RF_ACTIVE);
1152
1153 if (sc->rl_res == NULL) {
1145
1146 if (sc->rl_res == NULL) {
1154 device_printf(dev, "couldn't map ports/memory\n");
1155 error = ENXIO;
1156 goto fail;
1147 sc->rl_res_id = PCIR_BAR(0);
1148 sc->rl_res_type = SYS_RES_IOPORT;
1149 sc->rl_res = bus_alloc_resource_any(dev, sc->rl_res_type,
1150 &sc->rl_res_id, RF_ACTIVE);
1151 if (sc->rl_res == NULL) {
1152 device_printf(dev, "couldn't map ports/memory\n");
1153 error = ENXIO;
1154 goto fail;
1155 }
1157 }
1158
1159 sc->rl_btag = rman_get_bustag(sc->rl_res);
1160 sc->rl_bhandle = rman_get_bushandle(sc->rl_res);
1161
1162 msic = 0;
1163 if (pci_find_extcap(dev, PCIY_EXPRESS, &reg) == 0) {
1164 msic = pci_msi_count(dev);

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

1458 bus_release_resource(dev, SYS_RES_IRQ, rid,
1459 sc->rl_irq[i]);
1460 sc->rl_irq[i] = NULL;
1461 }
1462 }
1463 pci_release_msi(dev);
1464 }
1465 if (sc->rl_res)
1156 }
1157
1158 sc->rl_btag = rman_get_bustag(sc->rl_res);
1159 sc->rl_bhandle = rman_get_bushandle(sc->rl_res);
1160
1161 msic = 0;
1162 if (pci_find_extcap(dev, PCIY_EXPRESS, &reg) == 0) {
1163 msic = pci_msi_count(dev);

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

1457 bus_release_resource(dev, SYS_RES_IRQ, rid,
1458 sc->rl_irq[i]);
1459 sc->rl_irq[i] = NULL;
1460 }
1461 }
1462 pci_release_msi(dev);
1463 }
1464 if (sc->rl_res)
1466 bus_release_resource(dev, RL_RES, RL_RID, sc->rl_res);
1465 bus_release_resource(dev, sc->rl_res_type, sc->rl_res_id,
1466 sc->rl_res);
1467
1468 /* Unload and free the RX DMA ring memory and map */
1469
1470 if (sc->rl_ldata.rl_rx_list_tag) {
1471 bus_dmamap_unload(sc->rl_ldata.rl_rx_list_tag,
1472 sc->rl_ldata.rl_rx_list_map);
1473 bus_dmamem_free(sc->rl_ldata.rl_rx_list_tag,
1474 sc->rl_ldata.rl_rx_list,

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

--- 1515 unchanged lines hidden ---