Wed Nov 3 14:03:40 2010 UTC ()
Make nfe(4) detachable.


(jakllsch)
diff -r1.52 -r1.53 src/sys/dev/pci/if_nfe.c
diff -r1.9 -r1.10 src/sys/dev/pci/if_nfevar.h

cvs diff -r1.52 -r1.53 src/sys/dev/pci/if_nfe.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_nfe.c 2010/11/02 16:56:47 1.52
+++ src/sys/dev/pci/if_nfe.c 2010/11/03 14:03:40 1.53
@@ -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
74static int nfe_ifflags_cb(struct ethercom *); 74static int nfe_ifflags_cb(struct ethercom *);
75 75
76int nfe_match(device_t, cfdata_t, void *); 76int nfe_match(device_t, cfdata_t, void *);
77void nfe_attach(device_t, device_t, void *); 77void nfe_attach(device_t, device_t, void *);
 78int nfe_detach(device_t, int);
78void nfe_power(int, void *); 79void nfe_power(int, void *);
79void nfe_miibus_statchg(device_t); 80void nfe_miibus_statchg(device_t);
80int nfe_miibus_readreg(device_t, int, int); 81int nfe_miibus_readreg(device_t, int, int);
81void nfe_miibus_writereg(device_t, int, int, int); 82void nfe_miibus_writereg(device_t, int, int, int);
82int nfe_intr(void *); 83int nfe_intr(void *);
83int nfe_ioctl(struct ifnet *, u_long, void *); 84int nfe_ioctl(struct ifnet *, u_long, void *);
84void nfe_txdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int); 85void nfe_txdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int);
85void nfe_txdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int); 86void nfe_txdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int);
86void nfe_txdesc32_rsync(struct nfe_softc *, int, int, int); 87void nfe_txdesc32_rsync(struct nfe_softc *, int, int, int);
87void nfe_txdesc64_rsync(struct nfe_softc *, int, int, int); 88void nfe_txdesc64_rsync(struct nfe_softc *, int, int, int);
88void nfe_rxdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int); 89void nfe_rxdesc32_sync(struct nfe_softc *, struct nfe_desc32 *, int);
89void nfe_rxdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int); 90void nfe_rxdesc64_sync(struct nfe_softc *, struct nfe_desc64 *, int);
90void nfe_rxeof(struct nfe_softc *); 91void 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 *);
101int nfe_alloc_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); 102int nfe_alloc_rx_ring(struct nfe_softc *, struct nfe_rx_ring *);
102void nfe_reset_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); 103void nfe_reset_rx_ring(struct nfe_softc *, struct nfe_rx_ring *);
103void nfe_free_rx_ring(struct nfe_softc *, struct nfe_rx_ring *); 104void nfe_free_rx_ring(struct nfe_softc *, struct nfe_rx_ring *);
104int nfe_alloc_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); 105int nfe_alloc_tx_ring(struct nfe_softc *, struct nfe_tx_ring *);
105void nfe_reset_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); 106void nfe_reset_tx_ring(struct nfe_softc *, struct nfe_tx_ring *);
106void nfe_free_tx_ring(struct nfe_softc *, struct nfe_tx_ring *); 107void nfe_free_tx_ring(struct nfe_softc *, struct nfe_tx_ring *);
107void nfe_setmulti(struct nfe_softc *); 108void nfe_setmulti(struct nfe_softc *);
108void nfe_get_macaddr(struct nfe_softc *, uint8_t *); 109void nfe_get_macaddr(struct nfe_softc *, uint8_t *);
109void nfe_set_macaddr(struct nfe_softc *, const uint8_t *); 110void nfe_set_macaddr(struct nfe_softc *, const uint8_t *);
110void nfe_tick(void *); 111void nfe_tick(void *);
111void nfe_poweron(device_t); 112void nfe_poweron(device_t);
112bool nfe_resume(device_t, const pmf_qual_t *); 113bool nfe_resume(device_t, const pmf_qual_t *);
113 114
114CFATTACH_DECL_NEW(nfe, sizeof(struct nfe_softc), nfe_match, nfe_attach, 115CFATTACH_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
120int nfedebug = 0; 121int 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
212void 213void
213nfe_attach(device_t parent, device_t self, void *aux) 214nfe_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
423fail: 424fail:
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
 435int
 436nfe_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
432void 481void
433nfe_miibus_statchg(device_t dev) 482nfe_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
1545struct nfe_jbuf * 1596struct nfe_jbuf *
1546nfe_jalloc(struct nfe_softc *sc, int i) 1597nfe_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
1660void 1711void
1661nfe_jpool_free(struct nfe_softc *sc) 1712nfe_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
1677int 1730int
1678nfe_alloc_tx_ring(struct nfe_softc *sc, struct nfe_tx_ring *ring) 1731nfe_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);

cvs diff -r1.9 -r1.10 src/sys/dev/pci/if_nfevar.h (expand / switch to unified diff)

--- src/sys/dev/pci/if_nfevar.h 2008/04/20 08:57:37 1.9
+++ src/sys/dev/pci/if_nfevar.h 2010/11/03 14:03:40 1.10
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_nfevar.h,v 1.9 2008/04/20 08:57:37 cube Exp $ */ 1/* $NetBSD: if_nfevar.h,v 1.10 2010/11/03 14:03:40 jakllsch Exp $ */
2/* $OpenBSD: if_nfevar.h,v 1.13 2007/12/05 08:30:33 jsg Exp $ */ 2/* $OpenBSD: if_nfevar.h,v 1.13 2007/12/05 08:30:33 jsg Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org> 5 * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org>
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above 8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies. 9 * copyright notice and this permission notice appear in all copies.
10 * 10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
@@ -61,28 +61,30 @@ struct nfe_rx_ring { @@ -61,28 +61,30 @@ struct nfe_rx_ring {
61 struct nfe_jbuf jbuf[NFE_JPOOL_COUNT]; 61 struct nfe_jbuf jbuf[NFE_JPOOL_COUNT];
62 int jbufmap[NFE_RX_RING_COUNT]; 62 int jbufmap[NFE_RX_RING_COUNT];
63 SLIST_HEAD(, nfe_jbuf) jfreelist; 63 SLIST_HEAD(, nfe_jbuf) jfreelist;
64 int bufsz; 64 int bufsz;
65 int cur; 65 int cur;
66 int next; 66 int next;
67 kmutex_t mtx; 67 kmutex_t mtx;
68}; 68};
69 69
70struct nfe_softc { 70struct nfe_softc {
71 device_t sc_dev; 71 device_t sc_dev;
72 struct ethercom sc_ethercom; 72 struct ethercom sc_ethercom;
73 uint8_t sc_enaddr[ETHER_ADDR_LEN]; 73 uint8_t sc_enaddr[ETHER_ADDR_LEN];
 74 pci_chipset_tag_t sc_pc;
74 bus_space_handle_t sc_memh; 75 bus_space_handle_t sc_memh;
75 bus_space_tag_t sc_memt; 76 bus_space_tag_t sc_memt;
 77 bus_size_t sc_mems;
76 void *sc_ih; 78 void *sc_ih;
77 bus_dma_tag_t sc_dmat; 79 bus_dma_tag_t sc_dmat;
78 struct mii_data sc_mii; 80 struct mii_data sc_mii;
79 struct callout sc_tick_ch; 81 struct callout sc_tick_ch;
80 82
81 int sc_if_flags; 83 int sc_if_flags;
82 u_int sc_flags; 84 u_int sc_flags;
83#define NFE_JUMBO_SUP 0x01 85#define NFE_JUMBO_SUP 0x01
84#define NFE_40BIT_ADDR 0x02 86#define NFE_40BIT_ADDR 0x02
85#define NFE_HW_CSUM 0x04 87#define NFE_HW_CSUM 0x04
86#define NFE_HW_VLAN 0x08 88#define NFE_HW_VLAN 0x08
87#define NFE_USE_JUMBO 0x10 89#define NFE_USE_JUMBO 0x10
88#define NFE_CORRECT_MACADDR 0x20 90#define NFE_CORRECT_MACADDR 0x20