| @@ -1,37 +1,37 @@ | | | @@ -1,37 +1,37 @@ |
1 | /* $NetBSD: if_nfe.c,v 1.52 2010/11/02 16:56:47 jakllsch Exp $ */ | | 1 | /* $NetBSD: if_nfe.c,v 1.53 2010/11/03 14:03:40 jakllsch Exp $ */ |
2 | /* $OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $ */ | | 2 | /* $OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $ */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> | | 5 | * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> |
6 | * Copyright (c) 2005, 2006 Jonathan Gray <jsg@openbsd.org> | | 6 | * Copyright (c) 2005, 2006 Jonathan Gray <jsg@openbsd.org> |
7 | * | | 7 | * |
8 | * Permission to use, copy, modify, and distribute this software for any | | 8 | * Permission to use, copy, modify, and distribute this software for any |
9 | * purpose with or without fee is hereby granted, provided that the above | | 9 | * purpose with or without fee is hereby granted, provided that the above |
10 | * copyright notice and this permission notice appear in all copies. | | 10 | * copyright notice and this permission notice appear in all copies. |
11 | * | | 11 | * |
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
19 | */ | | 19 | */ |
20 | | | 20 | |
21 | /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */ | | 21 | /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */ |
22 | | | 22 | |
23 | #include <sys/cdefs.h> | | 23 | #include <sys/cdefs.h> |
24 | __KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.52 2010/11/02 16:56:47 jakllsch Exp $"); | | 24 | __KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.53 2010/11/03 14:03:40 jakllsch Exp $"); |
25 | | | 25 | |
26 | #include "opt_inet.h" | | 26 | #include "opt_inet.h" |
27 | #include "vlan.h" | | 27 | #include "vlan.h" |
28 | | | 28 | |
29 | #include <sys/param.h> | | 29 | #include <sys/param.h> |
30 | #include <sys/endian.h> | | 30 | #include <sys/endian.h> |
31 | #include <sys/systm.h> | | 31 | #include <sys/systm.h> |
32 | #include <sys/types.h> | | 32 | #include <sys/types.h> |
33 | #include <sys/sockio.h> | | 33 | #include <sys/sockio.h> |
34 | #include <sys/mbuf.h> | | 34 | #include <sys/mbuf.h> |
35 | #include <sys/mutex.h> | | 35 | #include <sys/mutex.h> |
36 | #include <sys/queue.h> | | 36 | #include <sys/queue.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
| @@ -65,26 +65,27 @@ __KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1 | | | @@ -65,26 +65,27 @@ __KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1 |
65 | #include <dev/mii/miivar.h> | | 65 | #include <dev/mii/miivar.h> |
66 | | | 66 | |
67 | #include <dev/pci/pcireg.h> | | 67 | #include <dev/pci/pcireg.h> |
68 | #include <dev/pci/pcivar.h> | | 68 | #include <dev/pci/pcivar.h> |
69 | #include <dev/pci/pcidevs.h> | | 69 | #include <dev/pci/pcidevs.h> |
70 | | | 70 | |
71 | #include <dev/pci/if_nfereg.h> | | 71 | #include <dev/pci/if_nfereg.h> |
72 | #include <dev/pci/if_nfevar.h> | | 72 | #include <dev/pci/if_nfevar.h> |
73 | | | 73 | |
74 | static int nfe_ifflags_cb(struct ethercom *); | | 74 | static int nfe_ifflags_cb(struct ethercom *); |
75 | | | 75 | |
76 | int nfe_match(device_t, cfdata_t, void *); | | 76 | int nfe_match(device_t, cfdata_t, void *); |
77 | void nfe_attach(device_t, device_t, void *); | | 77 | void nfe_attach(device_t, device_t, void *); |
| | | 78 | int nfe_detach(device_t, int); |
78 | void nfe_power(int, void *); | | 79 | void nfe_power(int, void *); |
79 | void nfe_miibus_statchg(device_t); | | 80 | void nfe_miibus_statchg(device_t); |
80 | int nfe_miibus_readreg(device_t, int, int); | | 81 | int nfe_miibus_readreg(device_t, int, int); |
81 | void nfe_miibus_writereg(device_t, int, int, int); | | 82 | void nfe_miibus_writereg(device_t, int, int, int); |
82 | int nfe_intr(void *); | | 83 | int nfe_intr(void *); |
83 | int nfe_ioctl(struct ifnet *, u_long, void *); | | 84 | int nfe_ioctl(struct ifnet *, u_long, void *); |
84 | void nfe_txdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int); | | 85 | void nfe_txdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int); |
85 | void nfe_txdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int); | | 86 | void nfe_txdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int); |
86 | void nfe_txdesc32_rsync(struct nfe_softc *, int, int, int); | | 87 | void nfe_txdesc32_rsync(struct nfe_softc *, int, int, int); |
87 | void nfe_txdesc64_rsync(struct nfe_softc *, int, int, int); | | 88 | void nfe_txdesc64_rsync(struct nfe_softc *, int, int, int); |
88 | void nfe_rxdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int); | | 89 | void nfe_rxdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int); |
89 | void nfe_rxdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int); | | 90 | void nfe_rxdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int); |
90 | void nfe_rxeof(struct nfe_softc *); | | 91 | void nfe_rxeof(struct nfe_softc *); |
| @@ -101,28 +102,28 @@ void nfe_jpool_free(struct nfe_softc *); | | | @@ -101,28 +102,28 @@ void nfe_jpool_free(struct nfe_softc *); |
101 | int nfe_alloc_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); | | 102 | int nfe_alloc_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); |
102 | void nfe_reset_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); | | 103 | void nfe_reset_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); |
103 | void nfe_free_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); | | 104 | void nfe_free_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); |
104 | int nfe_alloc_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); | | 105 | int nfe_alloc_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); |
105 | void nfe_reset_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); | | 106 | void nfe_reset_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); |
106 | void nfe_free_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); | | 107 | void nfe_free_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); |
107 | void nfe_setmulti(struct nfe_softc *); | | 108 | void nfe_setmulti(struct nfe_softc *); |
108 | void nfe_get_macaddr(struct nfe_softc *, uint8_t *); | | 109 | void nfe_get_macaddr(struct nfe_softc *, uint8_t *); |
109 | void nfe_set_macaddr(struct nfe_softc *, const uint8_t *); | | 110 | void nfe_set_macaddr(struct nfe_softc *, const uint8_t *); |
110 | void nfe_tick(void *); | | 111 | void nfe_tick(void *); |
111 | void nfe_poweron(device_t); | | 112 | void nfe_poweron(device_t); |
112 | bool nfe_resume(device_t, const pmf_qual_t *); | | 113 | bool nfe_resume(device_t, const pmf_qual_t *); |
113 | | | 114 | |
114 | CFATTACH_DECL_NEW(nfe, sizeof(struct nfe_softc), nfe_match, nfe_attach, | | 115 | CFATTACH_DECL_NEW(nfe, sizeof(struct nfe_softc), |
115 | NULL, NULL); | | 116 | nfe_match, nfe_attach, nfe_detach, NULL); |
116 | | | 117 | |
117 | /* #define NFE_NO_JUMBO */ | | 118 | /* #define NFE_NO_JUMBO */ |
118 | | | 119 | |
119 | #ifdef NFE_DEBUG | | 120 | #ifdef NFE_DEBUG |
120 | int nfedebug = 0; | | 121 | int nfedebug = 0; |
121 | #define DPRINTF(x) do { if (nfedebug) printf x; } while (0) | | 122 | #define DPRINTF(x) do { if (nfedebug) printf x; } while (0) |
122 | #define DPRINTFN(n,x) do { if (nfedebug >= (n)) printf x; } while (0) | | 123 | #define DPRINTFN(n,x) do { if (nfedebug >= (n)) printf x; } while (0) |
123 | #else | | 124 | #else |
124 | #define DPRINTF(x) | | 125 | #define DPRINTF(x) |
125 | #define DPRINTFN(n,x) | | 126 | #define DPRINTFN(n,x) |
126 | #endif | | 127 | #endif |
127 | | | 128 | |
128 | /* deal with naming differences */ | | 129 | /* deal with naming differences */ |
| @@ -208,41 +209,41 @@ nfe_match(device_t dev, cfdata_t match, | | | @@ -208,41 +209,41 @@ nfe_match(device_t dev, cfdata_t match, |
208 | } | | 209 | } |
209 | return 0; | | 210 | return 0; |
210 | } | | 211 | } |
211 | | | 212 | |
212 | void | | 213 | void |
213 | nfe_attach(device_t parent, device_t self, void *aux) | | 214 | nfe_attach(device_t parent, device_t self, void *aux) |
214 | { | | 215 | { |
215 | struct nfe_softc *sc = device_private(self); | | 216 | struct nfe_softc *sc = device_private(self); |
216 | struct pci_attach_args *pa = aux; | | 217 | struct pci_attach_args *pa = aux; |
217 | pci_chipset_tag_t pc = pa->pa_pc; | | 218 | pci_chipset_tag_t pc = pa->pa_pc; |
218 | pci_intr_handle_t ih; | | 219 | pci_intr_handle_t ih; |
219 | const char *intrstr; | | 220 | const char *intrstr; |
220 | struct ifnet *ifp; | | 221 | struct ifnet *ifp; |
221 | bus_size_t memsize; | | | |
222 | pcireg_t memtype, csr; | | 222 | pcireg_t memtype, csr; |
223 | char devinfo[256]; | | 223 | char devinfo[256]; |
224 | int mii_flags = 0; | | 224 | int mii_flags = 0; |
225 | | | 225 | |
226 | sc->sc_dev = self; | | 226 | sc->sc_dev = self; |
| | | 227 | sc->sc_pc = pa->pa_pc; |
227 | pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); | | 228 | pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); |
228 | aprint_normal(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class)); | | 229 | aprint_normal(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class)); |
229 | | | 230 | |
230 | memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, NFE_PCI_BA); | | 231 | memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, NFE_PCI_BA); |
231 | switch (memtype) { | | 232 | switch (memtype) { |
232 | case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: | | 233 | case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT: |
233 | case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: | | 234 | case PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT: |
234 | if (pci_mapreg_map(pa, NFE_PCI_BA, memtype, 0, &sc->sc_memt, | | 235 | if (pci_mapreg_map(pa, NFE_PCI_BA, memtype, 0, &sc->sc_memt, |
235 | &sc->sc_memh, NULL, &memsize) == 0) | | 236 | &sc->sc_memh, NULL, &sc->sc_mems) == 0) |
236 | break; | | 237 | break; |
237 | /* FALLTHROUGH */ | | 238 | /* FALLTHROUGH */ |
238 | default: | | 239 | default: |
239 | aprint_error_dev(self, "could not map mem space\n"); | | 240 | aprint_error_dev(self, "could not map mem space\n"); |
240 | return; | | 241 | return; |
241 | } | | 242 | } |
242 | | | 243 | |
243 | if (pci_intr_map(pa, &ih) != 0) { | | 244 | if (pci_intr_map(pa, &ih) != 0) { |
244 | aprint_error_dev(self, "could not map interrupt\n"); | | 245 | aprint_error_dev(self, "could not map interrupt\n"); |
245 | goto fail; | | 246 | goto fail; |
246 | } | | 247 | } |
247 | | | 248 | |
248 | intrstr = pci_intr_string(pc, ih); | | 249 | intrstr = pci_intr_string(pc, ih); |
| @@ -415,28 +416,76 @@ nfe_attach(device_t parent, device_t sel | | | @@ -415,28 +416,76 @@ nfe_attach(device_t parent, device_t sel |
415 | | | 416 | |
416 | if (pmf_device_register(self, NULL, nfe_resume)) | | 417 | if (pmf_device_register(self, NULL, nfe_resume)) |
417 | pmf_class_network_register(self, ifp); | | 418 | pmf_class_network_register(self, ifp); |
418 | else | | 419 | else |
419 | aprint_error_dev(self, "couldn't establish power handler\n"); | | 420 | aprint_error_dev(self, "couldn't establish power handler\n"); |
420 | | | 421 | |
421 | return; | | 422 | return; |
422 | | | 423 | |
423 | fail: | | 424 | fail: |
424 | if (sc->sc_ih != NULL) { | | 425 | if (sc->sc_ih != NULL) { |
425 | pci_intr_disestablish(pc, sc->sc_ih); | | 426 | pci_intr_disestablish(pc, sc->sc_ih); |
426 | sc->sc_ih = NULL; | | 427 | sc->sc_ih = NULL; |
427 | } | | 428 | } |
428 | if (memsize) | | 429 | if (sc->sc_mems != 0) { |
429 | bus_space_unmap(sc->sc_memt, sc->sc_memh, memsize); | | 430 | bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_mems); |
| | | 431 | sc->sc_mems = 0; |
| | | 432 | } |
| | | 433 | } |
| | | 434 | |
| | | 435 | int |
| | | 436 | nfe_detach(device_t self, int flags) |
| | | 437 | { |
| | | 438 | struct nfe_softc *sc = device_private(self); |
| | | 439 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; |
| | | 440 | int s; |
| | | 441 | |
| | | 442 | s = splnet(); |
| | | 443 | |
| | | 444 | nfe_stop(ifp, 1); |
| | | 445 | |
| | | 446 | pmf_device_deregister(self); |
| | | 447 | callout_destroy(&sc->sc_tick_ch); |
| | | 448 | ether_ifdetach(ifp); |
| | | 449 | if_detach(ifp); |
| | | 450 | mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); |
| | | 451 | |
| | | 452 | nfe_free_rx_ring(sc, &sc->rxq); |
| | | 453 | mutex_destroy(&sc->rxq.mtx); |
| | | 454 | nfe_free_tx_ring(sc, &sc->txq); |
| | | 455 | |
| | | 456 | if (sc->sc_ih != NULL) { |
| | | 457 | pci_intr_disestablish(sc->sc_pc, sc->sc_ih); |
| | | 458 | sc->sc_ih = NULL; |
| | | 459 | } |
| | | 460 | |
| | | 461 | if ((sc->sc_flags & NFE_CORRECT_MACADDR) != 0) { |
| | | 462 | nfe_set_macaddr(sc, sc->sc_enaddr); |
| | | 463 | } else { |
| | | 464 | NFE_WRITE(sc, NFE_MACADDR_LO, |
| | | 465 | sc->sc_enaddr[0] << 8 | sc->sc_enaddr[1]); |
| | | 466 | NFE_WRITE(sc, NFE_MACADDR_HI, |
| | | 467 | sc->sc_enaddr[2] << 24 | sc->sc_enaddr[3] << 16 | |
| | | 468 | sc->sc_enaddr[4] << 8 | sc->sc_enaddr[5]); |
| | | 469 | } |
| | | 470 | |
| | | 471 | if (sc->sc_mems != 0) { |
| | | 472 | bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_mems); |
| | | 473 | sc->sc_mems = 0; |
| | | 474 | } |
| | | 475 | |
| | | 476 | splx(s); |
| | | 477 | |
| | | 478 | return 0; |
430 | } | | 479 | } |
431 | | | 480 | |
432 | void | | 481 | void |
433 | nfe_miibus_statchg(device_t dev) | | 482 | nfe_miibus_statchg(device_t dev) |
434 | { | | 483 | { |
435 | struct nfe_softc *sc = device_private(dev); | | 484 | struct nfe_softc *sc = device_private(dev); |
436 | struct mii_data *mii = &sc->sc_mii; | | 485 | struct mii_data *mii = &sc->sc_mii; |
437 | uint32_t phy, seed, misc = NFE_MISC1_MAGIC, link = NFE_MEDIA_SET; | | 486 | uint32_t phy, seed, misc = NFE_MISC1_MAGIC, link = NFE_MEDIA_SET; |
438 | | | 487 | |
439 | phy = NFE_READ(sc, NFE_PHY_IFACE); | | 488 | phy = NFE_READ(sc, NFE_PHY_IFACE); |
440 | phy &= ~(NFE_PHY_HDX | NFE_PHY_100TX | NFE_PHY_1000T); | | 489 | phy &= ~(NFE_PHY_HDX | NFE_PHY_100TX | NFE_PHY_1000T); |
441 | | | 490 | |
442 | seed = NFE_READ(sc, NFE_RNDSEED); | | 491 | seed = NFE_READ(sc, NFE_RNDSEED); |
| @@ -1530,26 +1579,28 @@ nfe_free_rx_ring(struct nfe_softc *sc, s | | | @@ -1530,26 +1579,28 @@ nfe_free_rx_ring(struct nfe_softc *sc, s |
1530 | | | 1579 | |
1531 | for (i = 0; i < NFE_RX_RING_COUNT; i++) { | | 1580 | for (i = 0; i < NFE_RX_RING_COUNT; i++) { |
1532 | data = &ring->data[i]; | | 1581 | data = &ring->data[i]; |
1533 | | | 1582 | |
1534 | if (data->map != NULL) { | | 1583 | if (data->map != NULL) { |
1535 | bus_dmamap_sync(sc->sc_dmat, data->map, 0, | | 1584 | bus_dmamap_sync(sc->sc_dmat, data->map, 0, |
1536 | data->map->dm_mapsize, BUS_DMASYNC_POSTREAD); | | 1585 | data->map->dm_mapsize, BUS_DMASYNC_POSTREAD); |
1537 | bus_dmamap_unload(sc->sc_dmat, data->map); | | 1586 | bus_dmamap_unload(sc->sc_dmat, data->map); |
1538 | bus_dmamap_destroy(sc->sc_dmat, data->map); | | 1587 | bus_dmamap_destroy(sc->sc_dmat, data->map); |
1539 | } | | 1588 | } |
1540 | if (data->m != NULL) | | 1589 | if (data->m != NULL) |
1541 | m_freem(data->m); | | 1590 | m_freem(data->m); |
1542 | } | | 1591 | } |
| | | 1592 | |
| | | 1593 | nfe_jpool_free(sc); |
1543 | } | | 1594 | } |
1544 | | | 1595 | |
1545 | struct nfe_jbuf * | | 1596 | struct nfe_jbuf * |
1546 | nfe_jalloc(struct nfe_softc *sc, int i) | | 1597 | nfe_jalloc(struct nfe_softc *sc, int i) |
1547 | { | | 1598 | { |
1548 | struct nfe_jbuf *jbuf; | | 1599 | struct nfe_jbuf *jbuf; |
1549 | | | 1600 | |
1550 | mutex_enter(&sc->rxq.mtx); | | 1601 | mutex_enter(&sc->rxq.mtx); |
1551 | jbuf = SLIST_FIRST(&sc->rxq.jfreelist); | | 1602 | jbuf = SLIST_FIRST(&sc->rxq.jfreelist); |
1552 | if (jbuf != NULL) | | 1603 | if (jbuf != NULL) |
1553 | SLIST_REMOVE_HEAD(&sc->rxq.jfreelist, jnext); | | 1604 | SLIST_REMOVE_HEAD(&sc->rxq.jfreelist, jnext); |
1554 | mutex_exit(&sc->rxq.mtx); | | 1605 | mutex_exit(&sc->rxq.mtx); |
1555 | if (jbuf == NULL) | | 1606 | if (jbuf == NULL) |
| @@ -1657,30 +1708,32 @@ fail: nfe_jpool_free(sc); | | | @@ -1657,30 +1708,32 @@ fail: nfe_jpool_free(sc); |
1657 | return error; | | 1708 | return error; |
1658 | } | | 1709 | } |
1659 | | | 1710 | |
1660 | void | | 1711 | void |
1661 | nfe_jpool_free(struct nfe_softc *sc) | | 1712 | nfe_jpool_free(struct nfe_softc *sc) |
1662 | { | | 1713 | { |
1663 | struct nfe_rx_ring *ring = &sc->rxq; | | 1714 | struct nfe_rx_ring *ring = &sc->rxq; |
1664 | | | 1715 | |
1665 | if (ring->jmap != NULL) { | | 1716 | if (ring->jmap != NULL) { |
1666 | bus_dmamap_sync(sc->sc_dmat, ring->jmap, 0, | | 1717 | bus_dmamap_sync(sc->sc_dmat, ring->jmap, 0, |
1667 | ring->jmap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | | 1718 | ring->jmap->dm_mapsize, BUS_DMASYNC_POSTWRITE); |
1668 | bus_dmamap_unload(sc->sc_dmat, ring->jmap); | | 1719 | bus_dmamap_unload(sc->sc_dmat, ring->jmap); |
1669 | bus_dmamap_destroy(sc->sc_dmat, ring->jmap); | | 1720 | bus_dmamap_destroy(sc->sc_dmat, ring->jmap); |
| | | 1721 | ring->jmap = NULL; |
1670 | } | | 1722 | } |
1671 | if (ring->jpool != NULL) { | | 1723 | if (ring->jpool != NULL) { |
1672 | bus_dmamem_unmap(sc->sc_dmat, ring->jpool, NFE_JPOOL_SIZE); | | 1724 | bus_dmamem_unmap(sc->sc_dmat, ring->jpool, NFE_JPOOL_SIZE); |
1673 | bus_dmamem_free(sc->sc_dmat, &ring->jseg, 1); | | 1725 | bus_dmamem_free(sc->sc_dmat, &ring->jseg, 1); |
| | | 1726 | ring->jpool = NULL; |
1674 | } | | 1727 | } |
1675 | } | | 1728 | } |
1676 | | | 1729 | |
1677 | int | | 1730 | int |
1678 | nfe_alloc_tx_ring(struct nfe_softc *sc, struct nfe_tx_ring *ring) | | 1731 | nfe_alloc_tx_ring(struct nfe_softc *sc, struct nfe_tx_ring *ring) |
1679 | { | | 1732 | { |
1680 | int i, nsegs, error; | | 1733 | int i, nsegs, error; |
1681 | void **desc; | | 1734 | void **desc; |
1682 | int descsize; | | 1735 | int descsize; |
1683 | | | 1736 | |
1684 | if (sc->sc_flags & NFE_40BIT_ADDR) { | | 1737 | if (sc->sc_flags & NFE_40BIT_ADDR) { |
1685 | desc = (void **)&ring->desc64; | | 1738 | desc = (void **)&ring->desc64; |
1686 | descsize = sizeof (struct nfe_desc64); | | 1739 | descsize = sizeof (struct nfe_desc64); |