2 * Copyright (c) 2003 by Quinton Dolan <q@onthenet.com.au>.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $Id: if_nv.c,v 1.9 2003/12/13 15:27:40 q Exp $
27 * $DragonFly: src/sys/dev/netif/nv/Attic/if_nv.c,v 1.2 2004/09/05 12:36:16 joerg Exp $
31 * NVIDIA nForce MCP Networking Adapter driver
33 * This is a port of the NVIDIA MCP Linux ethernet driver distributed by NVIDIA
34 * through their web site.
36 * All mainstream nForce and nForce2 motherboards are supported. This module
37 * is as stable, sometimes more stable, than the linux version. (This seems to
38 * be related to some issues with newer distributions using GCC 3.2, however
39 * this don't appear to effect FreeBSD 5.x).
41 * In accordance with the NVIDIA distribution license it is necessary to link
42 * this module against the nvlibnet.o binary object included in the Linux
43 * driver source distribution. The binary component is not modified in any
44 * way and is simply linked against a FreeBSD equivalent of the nvnet.c linux
45 * kernel module "wrapper".
47 * The Linux driver uses a common code API that is shared between Win32 and
48 * Linux. This abstracts the low level driver functions and uses callbacks
49 * and hooks to access the underlying hardware device. By using this same API
50 * in a FreeBSD kernel module it is possible to support the hardware without
51 * breaching the Linux source distributions licensing requirements, or
52 * obtaining the hardware programming specifications.
54 * Although not conventional, it works, and given the relatively small amount of
55 * hardware centric code, it's hopefully no more buggy than its linux
58 * Written by Quinton Dolan <q@onthenet.com.au>
59 * Portions based on existing FreeBSD network drivers.
60 * NVIDIA API usage derived from distributed NVIDIA NVNET driver source files.
62 * $Id: if_nv.c,v 1.9 2003/12/13 15:27:40 q Exp $
65 #include <sys/param.h>
66 #include <sys/systm.h>
67 #include <sys/sockio.h>
69 #include <sys/malloc.h>
70 #include <sys/kernel.h>
71 #include <sys/socket.h>
72 #include <sys/sysctl.h>
73 #include <sys/queue.h>
74 #include <sys/module.h>
77 #include <net/if_arp.h>
78 #include <net/ethernet.h>
79 #include <net/if_dl.h>
80 #include <net/if_media.h>
84 #include <net/vlan/if_vlan_var.h>
86 #include <machine/bus_memio.h>
87 #include <machine/bus.h>
88 #include <machine/resource.h>
90 #include <vm/vm.h> /* for vtophys */
91 #include <vm/pmap.h> /* for vtophys */
92 #include <machine/clock.h> /* for DELAY */
96 #include <bus/pci/pcireg.h>
97 #include <bus/pci/pcivar.h>
99 #include <dev/netif/mii_layer/mii.h>
100 #include <dev/netif/mii_layer/miivar.h>
102 MODULE_DEPEND(nv, pci, 1, 1, 1);
103 MODULE_DEPEND(nv, ether, 1, 1, 1);
104 MODULE_DEPEND(nv, miibus, 1, 1, 1);
106 #include "if_nvreg.h"
107 #include "miibus_if.h"
109 static int nv_probe(device_t);
110 static int nv_attach(device_t);
111 static int nv_detach(device_t);
112 static void nv_init(void *);
113 static void nv_stop(struct nv_softc *);
114 static void nv_shutdown(device_t);
115 static int nv_init_rings(struct nv_softc *);
116 static void nv_free_rings(struct nv_softc *);
118 static void nv_ifstart(struct ifnet *);
119 static int nv_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
120 static void nv_intr(void *);
121 static void nv_tick(void *);
122 static void nv_setmulti(struct nv_softc *);
123 static void nv_watchdog(struct ifnet *);
124 static void nv_update_stats(struct nv_softc *);
126 static int nv_ifmedia_upd(struct ifnet *);
127 static void nv_ifmedia_sts(struct ifnet *, struct ifmediareq *);
128 static int nv_miibus_readreg(device_t, int, int);
129 static void nv_miibus_writereg(device_t, int, int, int);
131 static void nv_dmamap_cb(void *, bus_dma_segment_t *, int, int);
132 static void nv_dmamap_tx_cb(void *, bus_dma_segment_t *, int, bus_size_t, int);
134 static int nv_osalloc(void *, MEMORY_BLOCK *);
135 static int nv_osfree(void *, MEMORY_BLOCK *);
136 static int nv_osallocex(void *, MEMORY_BLOCKEX *);
137 static int nv_osfreeex(void *, MEMORY_BLOCKEX *);
138 static int nv_osclear(void *, void *, int);
139 static int nv_osdelay(void *, unsigned long);
140 static int nv_osallocrxbuf(void *, MEMORY_BLOCK *, void **);
141 static int nv_osfreerxbuf(void *, MEMORY_BLOCK *, void *);
142 static int nv_ospackettx(void *, void *, unsigned long);
143 static int nv_ospacketrx(void *, void *, unsigned long, unsigned char *, unsigned char);
144 static int nv_oslinkchg(void *, int);
145 static int nv_osalloctimer(void *, void **);
146 static int nv_osfreetimer(void *, void *);
147 static int nv_osinittimer(void *, void *, PTIMER_FUNC, void *);
148 static int nv_ossettimer(void *, void *, unsigned long);
149 static int nv_oscanceltimer(void *, void *);
150 static int nv_ospreprocpkt(void *, void *, void **, unsigned char *, unsigned char);
151 static void *nv_ospreprocpktnopq(void *, void *);
152 static int nv_osindicatepkt(void *, void **, unsigned long);
153 static int nv_oslockalloc(void *, int, void **);
154 static int nv_oslockacquire(void *, int, void *);
155 static int nv_oslockrelease(void *, int, void *);
156 static void *nv_osreturnbufvirt(void *, void *);
158 static device_method_t nv_methods[] = {
159 /* Device interface */
160 DEVMETHOD(device_probe, nv_probe),
161 DEVMETHOD(device_attach, nv_attach),
162 DEVMETHOD(device_detach, nv_detach),
163 DEVMETHOD(device_shutdown, nv_shutdown),
166 DEVMETHOD(bus_print_child, bus_generic_print_child),
167 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
170 DEVMETHOD(miibus_readreg, nv_miibus_readreg),
171 DEVMETHOD(miibus_writereg, nv_miibus_writereg),
176 static driver_t nv_driver = {
179 sizeof(struct nv_softc)
182 static devclass_t nv_devclass;
184 static int nv_pollinterval = 0;
185 SYSCTL_INT(_hw, OID_AUTO, nv_pollinterval, CTLFLAG_RW,
186 &nv_pollinterval, 0, "delay between interface polls");
188 DRIVER_MODULE(nv, pci, nv_driver, nv_devclass, 0, 0);
189 DRIVER_MODULE(miibus, nv, miibus_driver, miibus_devclass, 0, 0);
191 static struct nv_type nv_devs[] = {
192 {NVIDIA_VENDORID, NFORCE_MCPNET1_DEVICEID,
193 "NVIDIA nForce MCP Networking Adapter"},
194 {NVIDIA_VENDORID, NFORCE_MCPNET2_DEVICEID,
195 "NVIDIA nForce MCP2 Networking Adapter"},
196 {NVIDIA_VENDORID, NFORCE_MCPNET3_DEVICEID,
197 "NVIDIA nForce MCP3 Networking Adapter"},
201 /* DMA MEM map callback function to get data segment physical address */
203 nv_dmamap_cb(void *arg, bus_dma_segment_t * segs, int nsegs, int error)
209 ("Too many DMA segments returned when mapping DMA memory"));
210 *(bus_addr_t *)arg = segs->ds_addr;
213 /* DMA RX map callback function to get data segment physical address */
215 nv_dmamap_rx_cb(void *arg, bus_dma_segment_t * segs, int nsegs, bus_size_t mapsize, int error)
219 *(bus_addr_t *)arg = segs->ds_addr;
223 * DMA TX buffer callback function to allocate fragment data segment
227 nv_dmamap_tx_cb(void *arg, bus_dma_segment_t * segs, int nsegs, bus_size_t mapsize, int error)
229 struct nv_tx_desc *info = arg;
233 KASSERT(nsegs < NV_MAX_FRAGS,
234 ("Too many DMA segments returned when mapping mbuf"));
235 info->numfrags = nsegs;
236 bcopy(segs, info->frags, nsegs * sizeof(bus_dma_segment_t));
239 /* Probe for supported hardware ID's */
241 nv_probe(device_t dev)
243 struct nv_type *t = nv_devs;
245 /* Check for matching PCI DEVICE ID's */
246 while (t->name != NULL) {
247 if ((pci_get_vendor(dev) == t->vid_id) &&
248 (pci_get_device(dev) == t->dev_id)) {
249 device_set_desc(dev, t->name);
258 /* Attach driver and initialise hardware for use */
260 nv_attach(device_t dev)
262 u_char eaddr[ETHER_ADDR_LEN];
266 ADAPTER_OPEN_PARAMS OpenParams;
267 int error = 0, i, rid;
269 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_attach - entry\n");
271 sc = device_get_softc(dev);
275 /* Preinitialize data structures */
276 bzero(&OpenParams, sizeof(ADAPTER_OPEN_PARAMS));
278 /* Enable bus mastering */
279 pci_enable_busmaster(dev);
281 /* Allocate memory mapped address space */
283 sc->res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
284 0, ~0, 1, RF_ACTIVE);
286 if (sc->res == NULL) {
287 device_printf(dev, "couldn't map memory\n");
291 sc->sc_st = rman_get_bustag(sc->res);
292 sc->sc_sh = rman_get_bushandle(sc->res);
294 /* Allocate interrupt */
296 sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
297 RF_SHAREABLE | RF_ACTIVE);
299 if (sc->irq == NULL) {
300 device_printf(dev, "couldn't map interrupt\n");
304 /* Allocate DMA tags */
305 error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
306 BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * NV_MAX_FRAGS,
307 NV_MAX_FRAGS, MCLBYTES, 0,
310 device_printf(dev, "couldn't allocate dma tag\n");
313 error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
314 BUS_SPACE_MAXADDR, NULL, NULL,
315 sizeof(struct nv_rx_desc) * RX_RING_SIZE, 1,
316 sizeof(struct nv_rx_desc) * RX_RING_SIZE, 0,
319 device_printf(dev, "couldn't allocate dma tag\n");
322 error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
323 BUS_SPACE_MAXADDR, NULL, NULL,
324 sizeof(struct nv_tx_desc) * TX_RING_SIZE, 1,
325 sizeof(struct nv_tx_desc) * TX_RING_SIZE, 0,
328 device_printf(dev, "couldn't allocate dma tag\n");
331 /* Allocate DMA safe memory and get the DMA addresses. */
332 error = bus_dmamem_alloc(sc->ttag, (void **)&sc->tx_desc,
333 BUS_DMA_NOWAIT, &sc->tmap);
335 device_printf(dev, "couldn't allocate dma memory\n");
338 bzero(sc->tx_desc, sizeof(struct nv_tx_desc) * TX_RING_SIZE);
339 error = bus_dmamap_load(sc->ttag, sc->tmap, sc->tx_desc,
340 sizeof(struct nv_tx_desc) * TX_RING_SIZE, nv_dmamap_cb,
343 device_printf(dev, "couldn't map dma memory\n");
346 error = bus_dmamem_alloc(sc->rtag, (void **)&sc->rx_desc,
347 BUS_DMA_NOWAIT, &sc->rmap);
349 device_printf(dev, "couldn't allocate dma memory\n");
352 bzero(sc->rx_desc, sizeof(struct nv_rx_desc) * RX_RING_SIZE);
353 error = bus_dmamap_load(sc->rtag, sc->rmap, sc->rx_desc,
354 sizeof(struct nv_rx_desc) * RX_RING_SIZE, nv_dmamap_cb,
357 device_printf(dev, "couldn't map dma memory\n");
360 /* Initialize rings. */
361 if (nv_init_rings(sc)) {
362 device_printf(dev, "failed to init rings\n");
366 /* Setup NVIDIA API callback routines */
369 osapi->pfnAllocMemory = nv_osalloc;
370 osapi->pfnFreeMemory = nv_osfree;
371 osapi->pfnAllocMemoryEx = nv_osallocex;
372 osapi->pfnFreeMemoryEx = nv_osfreeex;
373 osapi->pfnClearMemory = nv_osclear;
374 osapi->pfnStallExecution = nv_osdelay;
375 osapi->pfnAllocReceiveBuffer = nv_osallocrxbuf;
376 osapi->pfnFreeReceiveBuffer = nv_osfreerxbuf;
377 osapi->pfnPacketWasSent = nv_ospackettx;
378 osapi->pfnPacketWasReceived = nv_ospacketrx;
379 osapi->pfnLinkStateHasChanged = nv_oslinkchg;
380 osapi->pfnAllocTimer = nv_osalloctimer;
381 osapi->pfnFreeTimer = nv_osfreetimer;
382 osapi->pfnInitializeTimer = nv_osinittimer;
383 osapi->pfnSetTimer = nv_ossettimer;
384 osapi->pfnCancelTimer = nv_oscanceltimer;
385 osapi->pfnPreprocessPacket = nv_ospreprocpkt;
386 osapi->pfnPreprocessPacketNopq = nv_ospreprocpktnopq;
387 osapi->pfnIndicatePackets = nv_osindicatepkt;
388 osapi->pfnLockAlloc = nv_oslockalloc;
389 osapi->pfnLockAcquire = nv_oslockacquire;
390 osapi->pfnLockRelease = nv_oslockrelease;
391 osapi->pfnReturnBufferVirtual = nv_osreturnbufvirt;
393 /* Set NVIDIA API startup parameters */
394 OpenParams.MaxDpcLoop = 2;
395 OpenParams.MaxRxPkt = RX_RING_SIZE;
396 OpenParams.MaxTxPkt = TX_RING_SIZE;
397 OpenParams.SentPacketStatusSuccess = 1;
398 OpenParams.SentPacketStatusFailure = 0;
399 OpenParams.MaxRxPktToAccumulate = 6;
400 OpenParams.ulPollInterval = nv_pollinterval;
401 OpenParams.SetForcedModeEveryNthRxPacket = 0;
402 OpenParams.SetForcedModeEveryNthTxPacket = 0;
403 OpenParams.RxForcedInterrupt = 0;
404 OpenParams.TxForcedInterrupt = 0;
405 OpenParams.pOSApi = osapi;
406 OpenParams.pvHardwareBaseAddress = rman_get_virtual(sc->res);
409 /* Open NVIDIA Hardware API */
410 error = ADAPTER_Open(&OpenParams, (void **)&(sc->hwapi), &sc->phyaddr);
412 device_printf(dev, "failed to open NVIDIA Hardware API: 0x%x\n", error);
415 /* MAC is loaded backwards into h/w reg */
416 sc->hwapi->pfnGetNodeAddress(sc->hwapi->pADCX, sc->original_mac_addr);
417 for (i = 0; i < 6; i++) {
418 eaddr[i] = sc->original_mac_addr[5 - i];
420 sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, eaddr);
421 bcopy(eaddr, (char *)&sc->sc_macaddr, ETHER_ADDR_LEN);
423 /* Display ethernet address ,... */
424 device_printf(dev, "Ethernet address %6D\n", sc->sc_macaddr, ":");
426 DEBUGOUT(NV_DEBUG_INIT, "nv: do mii_phy_probe\n");
428 /* Probe device for MII interface to PHY */
429 if (mii_phy_probe(dev, &sc->miibus,
430 nv_ifmedia_upd, nv_ifmedia_sts)) {
431 device_printf(dev, "MII without any phy!\n");
435 /* Setup interface parameters */
438 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
439 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
440 ifp->if_ioctl = nv_ioctl;
441 ifp->if_start = nv_ifstart;
442 ifp->if_watchdog = nv_watchdog;
444 ifp->if_init = nv_init;
445 ifp->if_mtu = ETHERMTU;
446 ifp->if_baudrate = IF_Mbps(100);
447 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
449 /* Attach to OS's managers. */
450 ether_ifattach(ifp, sc->sc_macaddr);
451 callout_handle_init(&sc->stat_ch);
453 /* Activate our interrupt handler. - attach last to avoid lock */
454 error = bus_setup_intr(sc->dev, sc->irq, INTR_TYPE_NET,
455 nv_intr, sc, &sc->sc_ih);
457 device_printf(sc->dev, "couldn't set up interrupt handler\n");
460 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_attach - exit\n");
469 /* Detach interface for module unload */
471 nv_detach(device_t dev)
473 struct nv_softc *sc = device_get_softc(dev);
478 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_detach - entry\n");
480 ifp = &sc->arpcom.ac_if;
482 if (device_is_attached(dev)) {
488 device_delete_child(dev, sc->miibus);
489 bus_generic_detach(dev);
491 /* Reload unreversed address back into MAC in original state */
492 if (sc->original_mac_addr)
493 sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, sc->original_mac_addr);
495 DEBUGOUT(NV_DEBUG_DEINIT, "nv: do pfnClose\n");
496 /* Detach from NVIDIA hardware API */
497 if (sc->hwapi->pfnClose)
498 sc->hwapi->pfnClose(sc->hwapi->pADCX);
499 /* Release resources */
501 bus_teardown_intr(sc->dev, sc->irq, sc->sc_ih);
503 bus_release_resource(sc->dev, SYS_RES_IRQ, 0, sc->irq);
505 bus_release_resource(sc->dev, SYS_RES_MEMORY, NV_RID, sc->res);
510 bus_dmamap_unload(sc->rtag, sc->rmap);
511 bus_dmamem_free(sc->rtag, sc->rx_desc, sc->rmap);
512 bus_dmamap_destroy(sc->rtag, sc->rmap);
515 bus_dma_tag_destroy(sc->mtag);
517 bus_dma_tag_destroy(sc->ttag);
519 bus_dma_tag_destroy(sc->rtag);
523 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_detach - exit\n");
528 /* Initialise interface and start it "RUNNING" */
532 struct nv_softc *sc = xsc;
538 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init - entry (%d)\n", sc->linkup);
542 /* Do nothing if already running */
543 if (ifp->if_flags & IFF_RUNNING)
548 DEBUGOUT(NV_DEBUG_INIT, "nv: do pfnInit\n");
549 /* Setup Hardware interface and allocate memory structures */
550 error = sc->hwapi->pfnInit(sc->hwapi->pADCX, 0, 0, 0, &sc->linkup);
552 device_printf(sc->dev, "failed to start NVIDIA Hardware interface\n");
555 /* Set the MAC address */
556 sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, sc->sc_macaddr);
557 sc->hwapi->pfnEnableInterrupts(sc->hwapi->pADCX);
558 sc->hwapi->pfnStart(sc->hwapi->pADCX);
560 /* Setup multicast filter */
564 /* Update interface parameters */
565 ifp->if_flags |= IFF_RUNNING;
566 ifp->if_flags &= ~IFF_OACTIVE;
568 sc->stat_ch = timeout(nv_tick, sc, hz);
570 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init - exit\n");
578 /* Stop interface activity ie. not "RUNNING" */
580 nv_stop(struct nv_softc *sc)
586 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_stop - entry\n");
591 /* Cancel tick timer */
592 untimeout(nv_tick, sc, sc->stat_ch);
594 /* Stop hardware activity */
595 sc->hwapi->pfnDisableInterrupts(sc->hwapi->pADCX);
596 sc->hwapi->pfnStop(sc->hwapi->pADCX, 0);
598 DEBUGOUT(NV_DEBUG_DEINIT, "nv: do pfnDeinit\n");
599 /* Shutdown interface and deallocate memory buffers */
600 if (sc->hwapi->pfnDeinit)
601 sc->hwapi->pfnDeinit(sc->hwapi->pADCX, 0);
606 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
608 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_stop - exit\n");
615 /* Shutdown interface for unload/reboot */
617 nv_shutdown(device_t dev)
621 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_shutdown\n");
623 sc = device_get_softc(dev);
625 /* Stop hardware activity */
629 /* Allocate TX ring buffers */
631 nv_init_rings(struct nv_softc *sc)
637 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init_rings - entry\n");
639 sc->cur_rx = sc->cur_tx = sc->pending_rxs = sc->pending_txs = 0;
640 /* Initialise RX ring */
641 for (i = 0; i < RX_RING_SIZE; i++) {
642 struct nv_rx_desc *desc = sc->rx_desc + i;
643 struct nv_map_buffer *buf = &desc->buf;
645 buf->mbuf = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
646 if (buf->mbuf == NULL) {
647 device_printf(sc->dev, "couldn't allocate mbuf\n");
652 buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES;
653 m_adj(buf->mbuf, ETHER_ALIGN);
655 error = bus_dmamap_create(sc->mtag, 0, &buf->map);
657 device_printf(sc->dev, "couldn't create dma map\n");
661 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, buf->mbuf,
662 nv_dmamap_rx_cb, &desc->paddr, 0);
664 device_printf(sc->dev, "couldn't dma map mbuf\n");
668 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_PREREAD);
670 desc->buflength = buf->mbuf->m_len;
671 desc->vaddr = mtod(buf->mbuf, PVOID);
673 bus_dmamap_sync(sc->rtag, sc->rmap,
674 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
676 /* Initialize TX ring */
677 for (i = 0; i < TX_RING_SIZE; i++) {
678 struct nv_tx_desc *desc = sc->tx_desc + i;
679 struct nv_map_buffer *buf = &desc->buf;
683 error = bus_dmamap_create(sc->mtag, 0, &buf->map);
685 device_printf(sc->dev, "couldn't create dma map\n");
690 bus_dmamap_sync(sc->ttag, sc->tmap,
691 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
693 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init_rings - exit\n");
701 /* Free the TX ring buffers */
703 nv_free_rings(struct nv_softc *sc)
709 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_free_rings - entry\n");
711 for (i = 0; i < RX_RING_SIZE; i++) {
712 struct nv_rx_desc *desc = sc->rx_desc + i;
713 struct nv_map_buffer *buf = &desc->buf;
716 bus_dmamap_unload(sc->mtag, buf->map);
717 bus_dmamap_destroy(sc->mtag, buf->map);
723 for (i = 0; i < TX_RING_SIZE; i++) {
724 struct nv_tx_desc *desc = sc->tx_desc + i;
725 struct nv_map_buffer *buf = &desc->buf;
728 bus_dmamap_unload(sc->mtag, buf->map);
729 bus_dmamap_destroy(sc->mtag, buf->map);
735 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_free_rings - exit\n");
740 /* Main loop for sending packets from OS to interface */
742 nv_ifstart(struct ifnet *ifp)
744 struct nv_softc *sc = ifp->if_softc;
745 struct nv_map_buffer *buf;
747 struct nv_tx_desc *desc;
748 ADAPTER_WRITE_DATA txdata;
751 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_ifstart - entry\n");
753 /* If link is down/busy or queue is empty do nothing */
754 if (ifp->if_flags & IFF_OACTIVE || ifp->if_snd.ifq_head == NULL)
757 /* Transmit queued packets until sent or TX ring is full */
758 while (sc->pending_txs < TX_RING_SIZE) {
759 desc = sc->tx_desc + sc->cur_tx;
762 /* Get next packet to send. */
763 IF_DEQUEUE(&ifp->if_snd, m0);
765 /* If nothing to send, return. */
769 /* Map MBUF for DMA access */
770 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, m0,
771 nv_dmamap_tx_cb, desc, BUS_DMA_NOWAIT);
773 if (error && error != EFBIG) {
779 * Packet has too many fragments - defrag into new mbuf
783 m = m_defrag(m0, MB_DONTWAIT);
792 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, m,
793 nv_dmamap_tx_cb, desc, BUS_DMA_NOWAIT);
800 /* Do sync on DMA bounce buffer */
801 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_PREWRITE);
804 txdata.ulNumberOfElements = desc->numfrags;
805 txdata.pvID = (PVOID)desc;
807 /* Put fragments into API element list */
808 txdata.ulTotalLength = buf->mbuf->m_len;
809 for (i = 0; i < desc->numfrags; i++) {
810 txdata.sElement[i].ulLength = (ulong)desc->frags[i].ds_len;
811 txdata.sElement[i].pPhysical = (PVOID)desc->frags[i].ds_addr;
814 /* Send packet to Nvidia API for transmission */
815 error = sc->hwapi->pfnWrite(sc->hwapi->pADCX, &txdata);
818 case ADAPTERERR_NONE:
819 /* Packet was queued in API TX queue successfully */
821 sc->cur_tx = (sc->cur_tx + 1) % TX_RING_SIZE;
824 case ADAPTERERR_TRANSMIT_QUEUE_FULL:
825 /* The API TX queue is full - requeue the packet */
826 device_printf(sc->dev, "nv_ifstart: transmit queue is full\n");
827 ifp->if_flags |= IFF_OACTIVE;
828 bus_dmamap_unload(sc->mtag, buf->map);
829 IF_PREPEND(&ifp->if_snd, buf->mbuf);
834 /* The API failed to queue/send the packet so dump it */
835 device_printf(sc->dev, "nv_ifstart: transmit error\n");
836 bus_dmamap_unload(sc->mtag, buf->map);
842 /* Set watchdog timer. */
845 /* Copy packet to BPF tap */
848 ifp->if_flags |= IFF_OACTIVE;
850 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_ifstart - exit\n");
853 /* Handle IOCTL events */
855 nv_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr)
857 struct nv_softc *sc = ifp->if_softc;
858 struct ifreq *ifr = (struct ifreq *) data;
859 struct mii_data *mii;
864 DEBUGOUT(NV_DEBUG_IOCTL, "nv: nv_ioctl - entry\n");
869 if (ifp->if_mtu == ifr->ifr_mtu)
871 if (ifr->ifr_mtu + ifp->if_hdrlen <= MAX_PACKET_SIZE) {
872 ifp->if_mtu = ifr->ifr_mtu;
880 /* Setup interface flags */
881 if (ifp->if_flags & IFF_UP) {
882 if ((ifp->if_flags & IFF_RUNNING) == 0) {
887 if (ifp->if_flags & IFF_RUNNING) {
893 /* Handle IFF_PROMISC and IFF_ALLMULTI flags. */
899 /* Setup multicast filter */
900 if (ifp->if_flags & IFF_RUNNING) {
906 /* Get/Set interface media parameters */
907 mii = device_get_softc(sc->miibus);
908 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
912 /* Everything else we forward to generic ether ioctl */
913 error = ether_ioctl(ifp, (int)command, data);
917 DEBUGOUT(NV_DEBUG_IOCTL, "nv: nv_ioctl - exit\n");
924 /* Interrupt service routine */
928 struct nv_softc *sc = arg;
929 struct ifnet *ifp = &sc->sc_if;
931 DEBUGOUT(NV_DEBUG_INTERRUPT, "nv: nv_intr - entry\n");
933 if (!ifp->if_flags & IFF_UP) {
937 /* Handle interrupt event */
938 if (sc->hwapi->pfnQueryInterrupt(sc->hwapi->pADCX)) {
939 sc->hwapi->pfnHandleInterrupt(sc->hwapi->pADCX);
940 sc->hwapi->pfnEnableInterrupts(sc->hwapi->pADCX);
942 if (ifp->if_snd.ifq_head != NULL)
945 /* If no pending packets we don't need a timeout */
946 if (sc->pending_txs == 0)
947 sc->sc_if.if_timer = 0;
949 DEBUGOUT(NV_DEBUG_INTERRUPT, "nv: nv_intr - exit\n");
954 /* Setup multicast filters */
956 nv_setmulti(struct nv_softc *sc)
959 struct ifmultiaddr *ifma;
960 PACKET_FILTER hwfilter;
967 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_setmulti - entry\n");
971 /* Initialize filter */
972 hwfilter.ulFilterFlags = 0;
973 for (i = 0; i < 6; i++) {
974 hwfilter.acMulticastAddress[i] = 0;
975 hwfilter.acMulticastMask[i] = 0;
978 if (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) {
979 /* Accept all packets */
980 hwfilter.ulFilterFlags |= ACCEPT_ALL_PACKETS;
981 sc->hwapi->pfnSetPacketFilter(sc->hwapi->pADCX, &hwfilter);
985 /* Setup multicast filter */
986 LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
989 if (ifma->ifma_addr->sa_family != AF_LINK)
992 addrp = LLADDR((struct sockaddr_dl *) ifma->ifma_addr);
993 for (i = 0; i < 6; i++) {
994 u_int8_t mcaddr = addrp[i];
995 andaddr[i] &= mcaddr;
999 for (i = 0; i < 6; i++) {
1000 hwfilter.acMulticastAddress[i] = andaddr[i] & oraddr[i];
1001 hwfilter.acMulticastMask[i] = andaddr[i] | (~oraddr[i]);
1004 /* Send filter to NVIDIA API */
1005 sc->hwapi->pfnSetPacketFilter(sc->hwapi->pADCX, &hwfilter);
1009 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_setmulti - exit\n");
1014 /* Change the current media/mediaopts */
1016 nv_ifmedia_upd(struct ifnet *ifp)
1018 struct nv_softc *sc = ifp->if_softc;
1019 struct mii_data *mii;
1021 DEBUGOUT(NV_DEBUG_MII, "nv: nv_ifmedia_upd\n");
1023 mii = device_get_softc(sc->miibus);
1025 if (mii->mii_instance) {
1026 struct mii_softc *miisc;
1027 for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
1028 miisc = LIST_NEXT(miisc, mii_list)) {
1029 mii_phy_reset(miisc);
1037 /* Update current miibus PHY status of media */
1039 nv_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
1041 struct nv_softc *sc;
1042 struct mii_data *mii;
1044 DEBUGOUT(NV_DEBUG_MII, "nv: nv_ifmedia_sts\n");
1047 mii = device_get_softc(sc->miibus);
1050 ifmr->ifm_active = mii->mii_media_active;
1051 ifmr->ifm_status = mii->mii_media_status;
1056 /* miibus tick timer - maintain link status */
1060 struct nv_softc *sc = xsc;
1061 struct mii_data *mii;
1067 nv_update_stats(sc);
1069 mii = device_get_softc(sc->miibus);
1072 if (mii->mii_media_status & IFM_ACTIVE &&
1073 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
1074 if (ifp->if_snd.ifq_head != NULL)
1077 sc->stat_ch = timeout(nv_tick, sc, hz);
1084 /* Update ifnet data structure with collected interface stats from API */
1086 nv_update_stats(struct nv_softc *sc)
1088 struct ifnet *ifp = &sc->sc_if;
1089 ADAPTER_STATS stats;
1094 sc->hwapi->pfnGetStatistics(sc->hwapi->pADCX, &stats);
1096 ifp->if_ipackets = stats.ulSuccessfulReceptions;
1097 ifp->if_ierrors = stats.ulMissedFrames +
1098 stats.ulFailedReceptions +
1100 stats.ulFramingErrors +
1101 stats.ulOverFlowErrors;
1103 ifp->if_opackets = stats.ulSuccessfulTransmissions;
1104 ifp->if_oerrors = sc->tx_errors +
1105 stats.ulFailedTransmissions +
1106 stats.ulRetryErrors +
1107 stats.ulUnderflowErrors +
1108 stats.ulLossOfCarrierErrors +
1109 stats.ulLateCollisionErrors;
1111 ifp->if_collisions = stats.ulLateCollisionErrors;
1118 /* miibus Read PHY register wrapper - calls Nvidia API entry point */
1120 nv_miibus_readreg(device_t dev, int phy, int reg)
1122 struct nv_softc *sc = device_get_softc(dev);
1125 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_readreg - entry\n");
1127 ADAPTER_ReadPhy(sc->hwapi->pADCX, phy, reg, &data);
1129 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_readreg - exit\n");
1134 /* miibus Write PHY register wrapper - calls Nvidia API entry point */
1136 nv_miibus_writereg(device_t dev, int phy, int reg, int data)
1138 struct nv_softc *sc = device_get_softc(dev);
1140 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_writereg - entry\n");
1142 ADAPTER_WritePhy(sc->hwapi->pADCX, phy, reg, (ulong)data);
1144 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_writereg - exit\n");
1149 /* Watchdog timer to prevent PHY lockups */
1151 nv_watchdog(struct ifnet *ifp)
1153 struct nv_softc *sc = ifp->if_softc;
1155 device_printf(sc->dev, "device timeout\n");
1160 ifp->if_flags &= ~IFF_RUNNING;
1163 if (ifp->if_snd.ifq_head != NULL)
1169 /* --- Start of NVOSAPI interface --- */
1171 /* Allocate DMA enabled general use memory for API */
1173 nv_osalloc(void *ctx, MEMORY_BLOCK *mem)
1175 struct nv_softc *sc;
1176 bus_addr_t mem_physical;
1178 DEBUGOUT(NV_DEBUG_API, "nv: nv_osalloc - %d\n", mem->uiLength);
1180 sc = (struct nv_softc *)ctx;
1182 mem->pLogical = (PVOID)contigmalloc(mem->uiLength, M_DEVBUF,
1183 M_NOWAIT | M_ZERO, 0, ~0, PAGE_SIZE, 0);
1185 if (!mem->pLogical) {
1186 device_printf(sc->dev, "memory allocation failed\n");
1189 memset(mem->pLogical, 0, (ulong)mem->uiLength);
1190 mem_physical = vtophys(mem->pLogical);
1191 mem->pPhysical = (PVOID)mem_physical;
1193 DEBUGOUT(NV_DEBUG_API, "nv: nv_osalloc 0x%x/0x%x - %d\n",
1194 (u_int32_t) mem->pLogical,
1195 (u_int32_t) mem->pPhysical, mem->uiLength);
1200 /* Free allocated memory */
1202 nv_osfree(void *ctx, MEMORY_BLOCK *mem)
1204 DEBUGOUT(NV_DEBUG_API, "nv: nv_osfree - 0x%x - %d\n",
1205 (u_int32_t) mem->pLogical, mem->uiLength);
1207 contigfree(mem->pLogical, PAGE_SIZE, M_DEVBUF);
1211 /* Copied directly from nvnet.c */
1213 nv_osallocex(void *ctx, MEMORY_BLOCKEX *mem_block_ex)
1215 MEMORY_BLOCK mem_block;
1217 DEBUGOUT(NV_DEBUG_API, "nv: nv_osallocex\n");
1219 mem_block_ex->pLogical = NULL;
1220 mem_block_ex->uiLengthOrig = mem_block_ex->uiLength;
1222 if ((mem_block_ex->AllocFlags & ALLOC_MEMORY_ALIGNED) &&
1223 (mem_block_ex->AlignmentSize > 1)) {
1224 DEBUGOUT(NV_DEBUG_API, " aligning on %d\n",
1225 mem_block_ex->AlignmentSize);
1226 mem_block_ex->uiLengthOrig += mem_block_ex->AlignmentSize;
1228 mem_block.uiLength = mem_block_ex->uiLengthOrig;
1230 if (nv_osalloc(ctx, &mem_block) == 0) {
1233 mem_block_ex->pLogicalOrig = mem_block.pLogical;
1234 mem_block_ex->pPhysicalOrigLow = (ULONG)mem_block.pPhysical;
1235 mem_block_ex->pPhysicalOrigHigh = 0;
1237 mem_block_ex->pPhysical = mem_block.pPhysical;
1238 mem_block_ex->pLogical = mem_block.pLogical;
1240 if (mem_block_ex->uiLength != mem_block_ex->uiLengthOrig) {
1241 unsigned int offset;
1242 offset = mem_block_ex->pPhysicalOrigLow & (mem_block_ex->AlignmentSize - 1);
1245 mem_block_ex->pPhysical = (PVOID)((ULONG)mem_block_ex->pPhysical +
1246 mem_block_ex->AlignmentSize - offset);
1247 mem_block_ex->pLogical = (PVOID)((ULONG)mem_block_ex->pLogical +
1248 mem_block_ex->AlignmentSize - offset);
1250 } /* if (mem_block_ex->uiLength !=
1251 * mem_block_ex->uiLengthOrig) */
1255 /* Copied directly from nvnet.c */
1257 nv_osfreeex(void *ctx, MEMORY_BLOCKEX *mem_block_ex)
1259 MEMORY_BLOCK mem_block;
1261 DEBUGOUT(NV_DEBUG_API, "nv: nv_osfreeex\n");
1263 mem_block.pLogical = mem_block_ex->pLogicalOrig;
1264 mem_block.pPhysical = (PVOID)mem_block_ex->pPhysicalOrigLow;
1265 mem_block.uiLength = mem_block_ex->uiLengthOrig;
1267 return (nv_osfree(ctx, &mem_block));
1270 /* Clear memory region */
1272 nv_osclear(void *ctx, void *mem, int length)
1274 DEBUGOUT(NV_DEBUG_API, "nv: nv_osclear\n");
1275 memset(mem, 0, length);
1279 /* Sleep for a tick */
1281 nv_osdelay(void *ctx, unsigned long usec)
1287 /* Allocate memory for rx buffer */
1289 nv_osallocrxbuf(void *ctx, MEMORY_BLOCK *mem, void **id)
1291 struct nv_softc *sc = ctx;
1292 struct nv_rx_desc *desc;
1293 struct nv_map_buffer *buf;
1298 DEBUGOUT(NV_DEBUG_API, "nv: nv_osallocrxbuf\n");
1300 if (sc->pending_rxs == RX_RING_SIZE) {
1301 device_printf(sc->dev, "rx ring buffer is full\n");
1304 desc = sc->rx_desc + sc->cur_rx;
1307 if (buf->mbuf == NULL) {
1308 buf->mbuf = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
1309 if (buf->mbuf == NULL) {
1310 device_printf(sc->dev, "failed to allocate memory\n");
1313 buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES;
1314 m_adj(buf->mbuf, ETHER_ALIGN);
1316 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, buf->mbuf,
1317 nv_dmamap_rx_cb, &desc->paddr, 0);
1319 device_printf(sc->dev, "failed to dmamap mbuf\n");
1324 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_PREREAD);
1325 desc->buflength = buf->mbuf->m_len;
1326 desc->vaddr = mtod(buf->mbuf, PVOID);
1329 sc->cur_rx = (sc->cur_rx + 1) % RX_RING_SIZE;
1331 mem->pLogical = (void *)desc->vaddr;
1332 mem->pPhysical = (void *)desc->paddr;
1333 mem->uiLength = desc->buflength;
1343 /* Free the rx buffer */
1345 nv_osfreerxbuf(void *ctx, MEMORY_BLOCK *mem, void *id)
1347 struct nv_softc *sc = ctx;
1348 struct nv_rx_desc *desc;
1349 struct nv_map_buffer *buf;
1353 DEBUGOUT(NV_DEBUG_API, "nv: nv_osfreerxbuf\n");
1355 desc = (struct nv_rx_desc *) id;
1359 bus_dmamap_unload(sc->mtag, buf->map);
1360 bus_dmamap_destroy(sc->mtag, buf->map);
1371 /* This gets called by the Nvidia API after our TX packet has been sent */
1373 nv_ospackettx(void *ctx, void *id, unsigned long success)
1375 struct nv_softc *sc = ctx;
1376 struct nv_map_buffer *buf;
1377 struct nv_tx_desc *desc = (struct nv_tx_desc *) id;
1382 DEBUGOUT(NV_DEBUG_API, "nv: nv_ospackettx\n");
1388 if (buf->mbuf == NULL)
1391 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTWRITE);
1392 bus_dmamap_unload(sc->mtag, buf->map);
1398 if (ifp->if_snd.ifq_head != NULL && sc->pending_txs < TX_RING_SIZE)
1407 /* This gets called by the Nvidia API when a new packet has been received */
1408 /* XXX What is newbuf used for? XXX */
1410 nv_ospacketrx(void *ctx, void *data, unsigned long success,
1411 unsigned char *newbuf, unsigned char priority)
1413 struct nv_softc *sc = ctx;
1415 struct nv_rx_desc *desc;
1416 struct nv_map_buffer *buf;
1417 ADAPTER_READ_DATA *readdata;
1420 DEBUGOUT(NV_DEBUG_API, "nv: nv_ospacketrx\n");
1424 readdata = (ADAPTER_READ_DATA *) data;
1425 desc = readdata->pvID;
1427 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTREAD);
1430 /* Sync DMA bounce buffer. */
1431 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTREAD);
1433 /* First mbuf in packet holds the ethernet and packet headers */
1434 buf->mbuf->m_pkthdr.rcvif = ifp;
1435 buf->mbuf->m_pkthdr.len = buf->mbuf->m_len = readdata->ulTotalLength;
1437 bus_dmamap_unload(sc->mtag, buf->map);
1439 /* Give mbuf to OS. */
1440 (*ifp->if_input) (ifp, buf->mbuf);
1441 if (readdata->ulFilterMatch & ADREADFL_MULTICAST_MATCH)
1444 /* Blat the mbuf pointer, kernel will free the mbuf cluster */
1447 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTREAD);
1448 bus_dmamap_unload(sc->mtag, buf->map);
1453 sc->cur_rx = desc - sc->rx_desc;
1461 /* This gets called by NVIDIA API when the PHY link state changes */
1463 nv_oslinkchg(void *ctx, int enabled)
1465 struct nv_softc *sc = (struct nv_softc *)ctx;
1468 DEBUGOUT(NV_DEBUG_API, "nv: nv_oslinkchg\n");
1473 ifp->if_flags |= IFF_UP;
1475 ifp->if_flags &= ~IFF_UP;
1482 /* Setup a watchdog timer */
1484 nv_osalloctimer(void *ctx, void **timer)
1486 struct nv_softc *sc = (struct nv_softc *)ctx;
1488 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osalloctimer\n");
1490 callout_handle_init(&sc->ostimer);
1491 *timer = &sc->ostimer;
1496 /* Free the timer */
1498 nv_osfreetimer(void *ctx, void *timer)
1500 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osfreetimer\n");
1505 /* Setup timer parameters */
1507 nv_osinittimer(void *ctx, void *timer, PTIMER_FUNC func, void *parameters)
1509 struct nv_softc *sc = (struct nv_softc *)ctx;
1511 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osinittimer\n");
1513 sc->ostimer_func = func;
1514 sc->ostimer_params = parameters;
1519 /* Set the timer to go off */
1521 nv_ossettimer(void *ctx, void *timer, unsigned long delay)
1523 struct nv_softc *sc = ctx;
1525 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_ossettimer\n");
1527 *(struct callout_handle *) timer = timeout(sc->ostimer_func, sc->ostimer_params, delay);
1532 /* Cancel the timer */
1534 nv_oscanceltimer(void *ctx, void *timer)
1536 struct nv_softc *sc = ctx;
1538 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_oscanceltimer\n");
1540 untimeout(sc->ostimer_func, sc->ostimer_params, *(struct callout_handle *) timer);
1546 nv_ospreprocpkt(void *ctx, void *readdata, void **id, unsigned char *newbuffer,
1547 unsigned char priority)
1549 /* Not implemented */
1550 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_ospreprocpkt\n");
1557 nv_ospreprocpktnopq(void *ctx, void *readdata)
1559 /* Not implemented */
1560 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_ospreprocpkt\n");
1566 nv_osindicatepkt(void *ctx, void **id, unsigned long pktno)
1568 /* Not implemented */
1569 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osindicatepkt\n");
1574 /* Allocate mutex context (already done in nv_attach) */
1576 nv_oslockalloc(void *ctx, int type, void **pLock)
1578 struct nv_softc *sc = (struct nv_softc *)ctx;
1580 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_oslockalloc\n");
1582 *pLock = (void **)sc;
1587 /* Obtain a spin lock */
1589 nv_oslockacquire(void *ctx, int type, void *lock)
1591 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_oslockacquire\n");
1593 NV_OSLOCK((struct nv_softc *)lock);
1600 nv_oslockrelease(void *ctx, int type, void *lock)
1602 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_oslockrelease\n");
1604 NV_OSUNLOCK((struct nv_softc *)lock);
1609 /* I have no idea what this is for */
1611 nv_osreturnbufvirt(void *ctx, void *readdata)
1613 /* Not implemented */
1614 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_osreturnbufvirt\n");
1615 panic("nv: nv_osreturnbufvirtual not implemented\n");
1621 /* --- End on NVOSAPI interface --- */