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.1 2004/08/28 15:08:02 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, unit;
269 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_attach - entry\n");
271 sc = device_get_softc(dev);
272 unit = device_get_unit(dev);
277 /* Preinitialize data structures */
278 bzero(&OpenParams, sizeof(ADAPTER_OPEN_PARAMS));
280 /* Enable bus mastering */
281 pci_enable_busmaster(dev);
283 /* Allocate memory mapped address space */
285 sc->res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
286 0, ~0, 1, RF_ACTIVE);
288 if (sc->res == NULL) {
289 device_printf(dev, "couldn't map memory\n");
293 sc->sc_st = rman_get_bustag(sc->res);
294 sc->sc_sh = rman_get_bushandle(sc->res);
296 /* Allocate interrupt */
298 sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
299 RF_SHAREABLE | RF_ACTIVE);
301 if (sc->irq == NULL) {
302 device_printf(dev, "couldn't map interrupt\n");
306 /* Allocate DMA tags */
307 error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
308 BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES * NV_MAX_FRAGS,
309 NV_MAX_FRAGS, MCLBYTES, 0,
312 device_printf(dev, "couldn't allocate dma tag\n");
315 error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
316 BUS_SPACE_MAXADDR, NULL, NULL,
317 sizeof(struct nv_rx_desc) * RX_RING_SIZE, 1,
318 sizeof(struct nv_rx_desc) * RX_RING_SIZE, 0,
321 device_printf(dev, "couldn't allocate dma tag\n");
324 error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
325 BUS_SPACE_MAXADDR, NULL, NULL,
326 sizeof(struct nv_tx_desc) * TX_RING_SIZE, 1,
327 sizeof(struct nv_tx_desc) * TX_RING_SIZE, 0,
330 device_printf(dev, "couldn't allocate dma tag\n");
333 /* Allocate DMA safe memory and get the DMA addresses. */
334 error = bus_dmamem_alloc(sc->ttag, (void **)&sc->tx_desc,
335 BUS_DMA_NOWAIT, &sc->tmap);
337 device_printf(dev, "couldn't allocate dma memory\n");
340 bzero(sc->tx_desc, sizeof(struct nv_tx_desc) * TX_RING_SIZE);
341 error = bus_dmamap_load(sc->ttag, sc->tmap, sc->tx_desc,
342 sizeof(struct nv_tx_desc) * TX_RING_SIZE, nv_dmamap_cb,
345 device_printf(dev, "couldn't map dma memory\n");
348 error = bus_dmamem_alloc(sc->rtag, (void **)&sc->rx_desc,
349 BUS_DMA_NOWAIT, &sc->rmap);
351 device_printf(dev, "couldn't allocate dma memory\n");
354 bzero(sc->rx_desc, sizeof(struct nv_rx_desc) * RX_RING_SIZE);
355 error = bus_dmamap_load(sc->rtag, sc->rmap, sc->rx_desc,
356 sizeof(struct nv_rx_desc) * RX_RING_SIZE, nv_dmamap_cb,
359 device_printf(dev, "couldn't map dma memory\n");
362 /* Initialize rings. */
363 if (nv_init_rings(sc)) {
364 device_printf(dev, "failed to init rings\n");
368 /* Setup NVIDIA API callback routines */
371 osapi->pfnAllocMemory = nv_osalloc;
372 osapi->pfnFreeMemory = nv_osfree;
373 osapi->pfnAllocMemoryEx = nv_osallocex;
374 osapi->pfnFreeMemoryEx = nv_osfreeex;
375 osapi->pfnClearMemory = nv_osclear;
376 osapi->pfnStallExecution = nv_osdelay;
377 osapi->pfnAllocReceiveBuffer = nv_osallocrxbuf;
378 osapi->pfnFreeReceiveBuffer = nv_osfreerxbuf;
379 osapi->pfnPacketWasSent = nv_ospackettx;
380 osapi->pfnPacketWasReceived = nv_ospacketrx;
381 osapi->pfnLinkStateHasChanged = nv_oslinkchg;
382 osapi->pfnAllocTimer = nv_osalloctimer;
383 osapi->pfnFreeTimer = nv_osfreetimer;
384 osapi->pfnInitializeTimer = nv_osinittimer;
385 osapi->pfnSetTimer = nv_ossettimer;
386 osapi->pfnCancelTimer = nv_oscanceltimer;
387 osapi->pfnPreprocessPacket = nv_ospreprocpkt;
388 osapi->pfnPreprocessPacketNopq = nv_ospreprocpktnopq;
389 osapi->pfnIndicatePackets = nv_osindicatepkt;
390 osapi->pfnLockAlloc = nv_oslockalloc;
391 osapi->pfnLockAcquire = nv_oslockacquire;
392 osapi->pfnLockRelease = nv_oslockrelease;
393 osapi->pfnReturnBufferVirtual = nv_osreturnbufvirt;
395 /* Set NVIDIA API startup parameters */
396 OpenParams.MaxDpcLoop = 2;
397 OpenParams.MaxRxPkt = RX_RING_SIZE;
398 OpenParams.MaxTxPkt = TX_RING_SIZE;
399 OpenParams.SentPacketStatusSuccess = 1;
400 OpenParams.SentPacketStatusFailure = 0;
401 OpenParams.MaxRxPktToAccumulate = 6;
402 OpenParams.ulPollInterval = nv_pollinterval;
403 OpenParams.SetForcedModeEveryNthRxPacket = 0;
404 OpenParams.SetForcedModeEveryNthTxPacket = 0;
405 OpenParams.RxForcedInterrupt = 0;
406 OpenParams.TxForcedInterrupt = 0;
407 OpenParams.pOSApi = osapi;
408 OpenParams.pvHardwareBaseAddress = rman_get_virtual(sc->res);
411 /* Open NVIDIA Hardware API */
412 error = ADAPTER_Open(&OpenParams, (void **)&(sc->hwapi), &sc->phyaddr);
414 device_printf(dev, "failed to open NVIDIA Hardware API: 0x%x\n", error);
417 /* MAC is loaded backwards into h/w reg */
418 sc->hwapi->pfnGetNodeAddress(sc->hwapi->pADCX, sc->original_mac_addr);
419 for (i = 0; i < 6; i++) {
420 eaddr[i] = sc->original_mac_addr[5 - i];
422 sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, eaddr);
423 bcopy(eaddr, (char *)&sc->sc_macaddr, ETHER_ADDR_LEN);
425 /* Display ethernet address ,... */
426 device_printf(dev, "Ethernet address %6D\n", sc->sc_macaddr, ":");
428 DEBUGOUT(NV_DEBUG_INIT, "nv: do mii_phy_probe\n");
430 /* Probe device for MII interface to PHY */
431 if (mii_phy_probe(dev, &sc->miibus,
432 nv_ifmedia_upd, nv_ifmedia_sts)) {
433 device_printf(dev, "MII without any phy!\n");
437 /* Setup interface parameters */
440 if_initname(ifp, "nv", unit);
441 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
442 ifp->if_ioctl = nv_ioctl;
443 ifp->if_start = nv_ifstart;
444 ifp->if_watchdog = nv_watchdog;
446 ifp->if_init = nv_init;
447 ifp->if_mtu = ETHERMTU;
448 ifp->if_baudrate = IF_Mbps(100);
449 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
451 /* Attach to OS's managers. */
452 ether_ifattach(ifp, sc->sc_macaddr);
453 callout_handle_init(&sc->stat_ch);
455 /* Activate our interrupt handler. - attach last to avoid lock */
456 error = bus_setup_intr(sc->dev, sc->irq, INTR_TYPE_NET,
457 nv_intr, sc, &sc->sc_ih);
459 device_printf(sc->dev, "couldn't set up interrupt handler\n");
462 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_attach - exit\n");
471 /* Detach interface for module unload */
473 nv_detach(device_t dev)
475 struct nv_softc *sc = device_get_softc(dev);
480 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_detach - entry\n");
482 ifp = &sc->arpcom.ac_if;
484 if (device_is_attached(dev)) {
490 device_delete_child(dev, sc->miibus);
491 bus_generic_detach(dev);
493 /* Reload unreversed address back into MAC in original state */
494 if (sc->original_mac_addr)
495 sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, sc->original_mac_addr);
497 DEBUGOUT(NV_DEBUG_DEINIT, "nv: do pfnClose\n");
498 /* Detach from NVIDIA hardware API */
499 if (sc->hwapi->pfnClose)
500 sc->hwapi->pfnClose(sc->hwapi->pADCX);
501 /* Release resources */
503 bus_teardown_intr(sc->dev, sc->irq, sc->sc_ih);
505 bus_release_resource(sc->dev, SYS_RES_IRQ, 0, sc->irq);
507 bus_release_resource(sc->dev, SYS_RES_MEMORY, NV_RID, sc->res);
512 bus_dmamap_unload(sc->rtag, sc->rmap);
513 bus_dmamem_free(sc->rtag, sc->rx_desc, sc->rmap);
514 bus_dmamap_destroy(sc->rtag, sc->rmap);
517 bus_dma_tag_destroy(sc->mtag);
519 bus_dma_tag_destroy(sc->ttag);
521 bus_dma_tag_destroy(sc->rtag);
525 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_detach - exit\n");
530 /* Initialise interface and start it "RUNNING" */
534 struct nv_softc *sc = xsc;
540 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init - entry (%d)\n", sc->linkup);
544 /* Do nothing if already running */
545 if (ifp->if_flags & IFF_RUNNING)
550 DEBUGOUT(NV_DEBUG_INIT, "nv: do pfnInit\n");
551 /* Setup Hardware interface and allocate memory structures */
552 error = sc->hwapi->pfnInit(sc->hwapi->pADCX, 0, 0, 0, &sc->linkup);
554 device_printf(sc->dev, "failed to start NVIDIA Hardware interface\n");
557 /* Set the MAC address */
558 sc->hwapi->pfnSetNodeAddress(sc->hwapi->pADCX, sc->sc_macaddr);
559 sc->hwapi->pfnEnableInterrupts(sc->hwapi->pADCX);
560 sc->hwapi->pfnStart(sc->hwapi->pADCX);
562 /* Setup multicast filter */
566 /* Update interface parameters */
567 ifp->if_flags |= IFF_RUNNING;
568 ifp->if_flags &= ~IFF_OACTIVE;
570 sc->stat_ch = timeout(nv_tick, sc, hz);
572 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init - exit\n");
580 /* Stop interface activity ie. not "RUNNING" */
582 nv_stop(struct nv_softc *sc)
588 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_stop - entry\n");
593 /* Cancel tick timer */
594 untimeout(nv_tick, sc, sc->stat_ch);
596 /* Stop hardware activity */
597 sc->hwapi->pfnDisableInterrupts(sc->hwapi->pADCX);
598 sc->hwapi->pfnStop(sc->hwapi->pADCX, 0);
600 DEBUGOUT(NV_DEBUG_DEINIT, "nv: do pfnDeinit\n");
601 /* Shutdown interface and deallocate memory buffers */
602 if (sc->hwapi->pfnDeinit)
603 sc->hwapi->pfnDeinit(sc->hwapi->pADCX, 0);
608 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
610 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_stop - exit\n");
617 /* Shutdown interface for unload/reboot */
619 nv_shutdown(device_t dev)
623 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_shutdown\n");
625 sc = device_get_softc(dev);
627 /* Stop hardware activity */
631 /* Allocate TX ring buffers */
633 nv_init_rings(struct nv_softc *sc)
639 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init_rings - entry\n");
641 sc->cur_rx = sc->cur_tx = sc->pending_rxs = sc->pending_txs = 0;
642 /* Initialise RX ring */
643 for (i = 0; i < RX_RING_SIZE; i++) {
644 struct nv_rx_desc *desc = sc->rx_desc + i;
645 struct nv_map_buffer *buf = &desc->buf;
647 buf->mbuf = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
648 if (buf->mbuf == NULL) {
649 device_printf(sc->dev, "couldn't allocate mbuf\n");
654 buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES;
655 m_adj(buf->mbuf, ETHER_ALIGN);
657 error = bus_dmamap_create(sc->mtag, 0, &buf->map);
659 device_printf(sc->dev, "couldn't create dma map\n");
663 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, buf->mbuf,
664 nv_dmamap_rx_cb, &desc->paddr, 0);
666 device_printf(sc->dev, "couldn't dma map mbuf\n");
670 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_PREREAD);
672 desc->buflength = buf->mbuf->m_len;
673 desc->vaddr = mtod(buf->mbuf, PVOID);
675 bus_dmamap_sync(sc->rtag, sc->rmap,
676 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
678 /* Initialize TX ring */
679 for (i = 0; i < TX_RING_SIZE; i++) {
680 struct nv_tx_desc *desc = sc->tx_desc + i;
681 struct nv_map_buffer *buf = &desc->buf;
685 error = bus_dmamap_create(sc->mtag, 0, &buf->map);
687 device_printf(sc->dev, "couldn't create dma map\n");
692 bus_dmamap_sync(sc->ttag, sc->tmap,
693 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
695 DEBUGOUT(NV_DEBUG_INIT, "nv: nv_init_rings - exit\n");
703 /* Free the TX ring buffers */
705 nv_free_rings(struct nv_softc *sc)
711 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_free_rings - entry\n");
713 for (i = 0; i < RX_RING_SIZE; i++) {
714 struct nv_rx_desc *desc = sc->rx_desc + i;
715 struct nv_map_buffer *buf = &desc->buf;
718 bus_dmamap_unload(sc->mtag, buf->map);
719 bus_dmamap_destroy(sc->mtag, buf->map);
725 for (i = 0; i < TX_RING_SIZE; i++) {
726 struct nv_tx_desc *desc = sc->tx_desc + i;
727 struct nv_map_buffer *buf = &desc->buf;
730 bus_dmamap_unload(sc->mtag, buf->map);
731 bus_dmamap_destroy(sc->mtag, buf->map);
737 DEBUGOUT(NV_DEBUG_DEINIT, "nv: nv_free_rings - exit\n");
742 /* Main loop for sending packets from OS to interface */
744 nv_ifstart(struct ifnet *ifp)
746 struct nv_softc *sc = ifp->if_softc;
747 struct nv_map_buffer *buf;
749 struct nv_tx_desc *desc;
750 ADAPTER_WRITE_DATA txdata;
753 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_ifstart - entry\n");
755 /* If link is down/busy or queue is empty do nothing */
756 if (ifp->if_flags & IFF_OACTIVE || ifp->if_snd.ifq_head == NULL)
759 /* Transmit queued packets until sent or TX ring is full */
760 while (sc->pending_txs < TX_RING_SIZE) {
761 desc = sc->tx_desc + sc->cur_tx;
764 /* Get next packet to send. */
765 IF_DEQUEUE(&ifp->if_snd, m0);
767 /* If nothing to send, return. */
771 /* Map MBUF for DMA access */
772 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, m0,
773 nv_dmamap_tx_cb, desc, BUS_DMA_NOWAIT);
775 if (error && error != EFBIG) {
781 * Packet has too many fragments - defrag into new mbuf
785 m = m_defrag(m0, MB_DONTWAIT);
794 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, m,
795 nv_dmamap_tx_cb, desc, BUS_DMA_NOWAIT);
802 /* Do sync on DMA bounce buffer */
803 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_PREWRITE);
806 txdata.ulNumberOfElements = desc->numfrags;
807 txdata.pvID = (PVOID)desc;
809 /* Put fragments into API element list */
810 txdata.ulTotalLength = buf->mbuf->m_len;
811 for (i = 0; i < desc->numfrags; i++) {
812 txdata.sElement[i].ulLength = (ulong)desc->frags[i].ds_len;
813 txdata.sElement[i].pPhysical = (PVOID)desc->frags[i].ds_addr;
816 /* Send packet to Nvidia API for transmission */
817 error = sc->hwapi->pfnWrite(sc->hwapi->pADCX, &txdata);
820 case ADAPTERERR_NONE:
821 /* Packet was queued in API TX queue successfully */
823 sc->cur_tx = (sc->cur_tx + 1) % TX_RING_SIZE;
826 case ADAPTERERR_TRANSMIT_QUEUE_FULL:
827 /* The API TX queue is full - requeue the packet */
828 device_printf(sc->dev, "nv_ifstart: transmit queue is full\n");
829 ifp->if_flags |= IFF_OACTIVE;
830 bus_dmamap_unload(sc->mtag, buf->map);
831 IF_PREPEND(&ifp->if_snd, buf->mbuf);
836 /* The API failed to queue/send the packet so dump it */
837 device_printf(sc->dev, "nv_ifstart: transmit error\n");
838 bus_dmamap_unload(sc->mtag, buf->map);
844 /* Set watchdog timer. */
847 /* Copy packet to BPF tap */
850 ifp->if_flags |= IFF_OACTIVE;
852 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_ifstart - exit\n");
855 /* Handle IOCTL events */
857 nv_ioctl(struct ifnet *ifp, u_long command, caddr_t data, struct ucred *cr)
859 struct nv_softc *sc = ifp->if_softc;
860 struct ifreq *ifr = (struct ifreq *) data;
861 struct mii_data *mii;
866 DEBUGOUT(NV_DEBUG_IOCTL, "nv: nv_ioctl - entry\n");
871 if (ifp->if_mtu == ifr->ifr_mtu)
873 if (ifr->ifr_mtu + ifp->if_hdrlen <= MAX_PACKET_SIZE) {
874 ifp->if_mtu = ifr->ifr_mtu;
882 /* Setup interface flags */
883 if (ifp->if_flags & IFF_UP) {
884 if ((ifp->if_flags & IFF_RUNNING) == 0) {
889 if (ifp->if_flags & IFF_RUNNING) {
895 /* Handle IFF_PROMISC and IFF_ALLMULTI flags. */
901 /* Setup multicast filter */
902 if (ifp->if_flags & IFF_RUNNING) {
908 /* Get/Set interface media parameters */
909 mii = device_get_softc(sc->miibus);
910 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command);
914 /* Everything else we forward to generic ether ioctl */
915 error = ether_ioctl(ifp, (int)command, data);
919 DEBUGOUT(NV_DEBUG_IOCTL, "nv: nv_ioctl - exit\n");
926 /* Interrupt service routine */
930 struct nv_softc *sc = arg;
931 struct ifnet *ifp = &sc->sc_if;
933 DEBUGOUT(NV_DEBUG_INTERRUPT, "nv: nv_intr - entry\n");
935 if (!ifp->if_flags & IFF_UP) {
939 /* Handle interrupt event */
940 if (sc->hwapi->pfnQueryInterrupt(sc->hwapi->pADCX)) {
941 sc->hwapi->pfnHandleInterrupt(sc->hwapi->pADCX);
942 sc->hwapi->pfnEnableInterrupts(sc->hwapi->pADCX);
944 if (ifp->if_snd.ifq_head != NULL)
947 /* If no pending packets we don't need a timeout */
948 if (sc->pending_txs == 0)
949 sc->sc_if.if_timer = 0;
951 DEBUGOUT(NV_DEBUG_INTERRUPT, "nv: nv_intr - exit\n");
956 /* Setup multicast filters */
958 nv_setmulti(struct nv_softc *sc)
961 struct ifmultiaddr *ifma;
962 PACKET_FILTER hwfilter;
969 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_setmulti - entry\n");
973 /* Initialize filter */
974 hwfilter.ulFilterFlags = 0;
975 for (i = 0; i < 6; i++) {
976 hwfilter.acMulticastAddress[i] = 0;
977 hwfilter.acMulticastMask[i] = 0;
980 if (ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI)) {
981 /* Accept all packets */
982 hwfilter.ulFilterFlags |= ACCEPT_ALL_PACKETS;
983 sc->hwapi->pfnSetPacketFilter(sc->hwapi->pADCX, &hwfilter);
987 /* Setup multicast filter */
988 LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
991 if (ifma->ifma_addr->sa_family != AF_LINK)
994 addrp = LLADDR((struct sockaddr_dl *) ifma->ifma_addr);
995 for (i = 0; i < 6; i++) {
996 u_int8_t mcaddr = addrp[i];
997 andaddr[i] &= mcaddr;
1001 for (i = 0; i < 6; i++) {
1002 hwfilter.acMulticastAddress[i] = andaddr[i] & oraddr[i];
1003 hwfilter.acMulticastMask[i] = andaddr[i] | (~oraddr[i]);
1006 /* Send filter to NVIDIA API */
1007 sc->hwapi->pfnSetPacketFilter(sc->hwapi->pADCX, &hwfilter);
1011 DEBUGOUT(NV_DEBUG_RUNNING, "nv: nv_setmulti - exit\n");
1016 /* Change the current media/mediaopts */
1018 nv_ifmedia_upd(struct ifnet *ifp)
1020 struct nv_softc *sc = ifp->if_softc;
1021 struct mii_data *mii;
1023 DEBUGOUT(NV_DEBUG_MII, "nv: nv_ifmedia_upd\n");
1025 mii = device_get_softc(sc->miibus);
1027 if (mii->mii_instance) {
1028 struct mii_softc *miisc;
1029 for (miisc = LIST_FIRST(&mii->mii_phys); miisc != NULL;
1030 miisc = LIST_NEXT(miisc, mii_list)) {
1031 mii_phy_reset(miisc);
1039 /* Update current miibus PHY status of media */
1041 nv_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
1043 struct nv_softc *sc;
1044 struct mii_data *mii;
1046 DEBUGOUT(NV_DEBUG_MII, "nv: nv_ifmedia_sts\n");
1049 mii = device_get_softc(sc->miibus);
1052 ifmr->ifm_active = mii->mii_media_active;
1053 ifmr->ifm_status = mii->mii_media_status;
1058 /* miibus tick timer - maintain link status */
1062 struct nv_softc *sc = xsc;
1063 struct mii_data *mii;
1069 nv_update_stats(sc);
1071 mii = device_get_softc(sc->miibus);
1074 if (mii->mii_media_status & IFM_ACTIVE &&
1075 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
1076 if (ifp->if_snd.ifq_head != NULL)
1079 sc->stat_ch = timeout(nv_tick, sc, hz);
1086 /* Update ifnet data structure with collected interface stats from API */
1088 nv_update_stats(struct nv_softc *sc)
1090 struct ifnet *ifp = &sc->sc_if;
1091 ADAPTER_STATS stats;
1096 sc->hwapi->pfnGetStatistics(sc->hwapi->pADCX, &stats);
1098 ifp->if_ipackets = stats.ulSuccessfulReceptions;
1099 ifp->if_ierrors = stats.ulMissedFrames +
1100 stats.ulFailedReceptions +
1102 stats.ulFramingErrors +
1103 stats.ulOverFlowErrors;
1105 ifp->if_opackets = stats.ulSuccessfulTransmissions;
1106 ifp->if_oerrors = sc->tx_errors +
1107 stats.ulFailedTransmissions +
1108 stats.ulRetryErrors +
1109 stats.ulUnderflowErrors +
1110 stats.ulLossOfCarrierErrors +
1111 stats.ulLateCollisionErrors;
1113 ifp->if_collisions = stats.ulLateCollisionErrors;
1120 /* miibus Read PHY register wrapper - calls Nvidia API entry point */
1122 nv_miibus_readreg(device_t dev, int phy, int reg)
1124 struct nv_softc *sc = device_get_softc(dev);
1127 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_readreg - entry\n");
1129 ADAPTER_ReadPhy(sc->hwapi->pADCX, phy, reg, &data);
1131 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_readreg - exit\n");
1136 /* miibus Write PHY register wrapper - calls Nvidia API entry point */
1138 nv_miibus_writereg(device_t dev, int phy, int reg, int data)
1140 struct nv_softc *sc = device_get_softc(dev);
1142 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_writereg - entry\n");
1144 ADAPTER_WritePhy(sc->hwapi->pADCX, phy, reg, (ulong)data);
1146 DEBUGOUT(NV_DEBUG_MII, "nv: nv_miibus_writereg - exit\n");
1151 /* Watchdog timer to prevent PHY lockups */
1153 nv_watchdog(struct ifnet *ifp)
1155 struct nv_softc *sc = ifp->if_softc;
1157 device_printf(sc->dev, "device timeout\n");
1162 ifp->if_flags &= ~IFF_RUNNING;
1165 if (ifp->if_snd.ifq_head != NULL)
1171 /* --- Start of NVOSAPI interface --- */
1173 /* Allocate DMA enabled general use memory for API */
1175 nv_osalloc(void *ctx, MEMORY_BLOCK *mem)
1177 struct nv_softc *sc;
1178 bus_addr_t mem_physical;
1180 DEBUGOUT(NV_DEBUG_API, "nv: nv_osalloc - %d\n", mem->uiLength);
1182 sc = (struct nv_softc *)ctx;
1184 mem->pLogical = (PVOID)contigmalloc(mem->uiLength, M_DEVBUF,
1185 M_NOWAIT | M_ZERO, 0, ~0, PAGE_SIZE, 0);
1187 if (!mem->pLogical) {
1188 device_printf(sc->dev, "memory allocation failed\n");
1191 memset(mem->pLogical, 0, (ulong)mem->uiLength);
1192 mem_physical = vtophys(mem->pLogical);
1193 mem->pPhysical = (PVOID)mem_physical;
1195 DEBUGOUT(NV_DEBUG_API, "nv: nv_osalloc 0x%x/0x%x - %d\n",
1196 (u_int32_t) mem->pLogical,
1197 (u_int32_t) mem->pPhysical, mem->uiLength);
1202 /* Free allocated memory */
1204 nv_osfree(void *ctx, MEMORY_BLOCK *mem)
1206 DEBUGOUT(NV_DEBUG_API, "nv: nv_osfree - 0x%x - %d\n",
1207 (u_int32_t) mem->pLogical, mem->uiLength);
1209 contigfree(mem->pLogical, PAGE_SIZE, M_DEVBUF);
1213 /* Copied directly from nvnet.c */
1215 nv_osallocex(void *ctx, MEMORY_BLOCKEX *mem_block_ex)
1217 MEMORY_BLOCK mem_block;
1219 DEBUGOUT(NV_DEBUG_API, "nv: nv_osallocex\n");
1221 mem_block_ex->pLogical = NULL;
1222 mem_block_ex->uiLengthOrig = mem_block_ex->uiLength;
1224 if ((mem_block_ex->AllocFlags & ALLOC_MEMORY_ALIGNED) &&
1225 (mem_block_ex->AlignmentSize > 1)) {
1226 DEBUGOUT(NV_DEBUG_API, " aligning on %d\n",
1227 mem_block_ex->AlignmentSize);
1228 mem_block_ex->uiLengthOrig += mem_block_ex->AlignmentSize;
1230 mem_block.uiLength = mem_block_ex->uiLengthOrig;
1232 if (nv_osalloc(ctx, &mem_block) == 0) {
1235 mem_block_ex->pLogicalOrig = mem_block.pLogical;
1236 mem_block_ex->pPhysicalOrigLow = (ULONG)mem_block.pPhysical;
1237 mem_block_ex->pPhysicalOrigHigh = 0;
1239 mem_block_ex->pPhysical = mem_block.pPhysical;
1240 mem_block_ex->pLogical = mem_block.pLogical;
1242 if (mem_block_ex->uiLength != mem_block_ex->uiLengthOrig) {
1243 unsigned int offset;
1244 offset = mem_block_ex->pPhysicalOrigLow & (mem_block_ex->AlignmentSize - 1);
1247 mem_block_ex->pPhysical = (PVOID)((ULONG)mem_block_ex->pPhysical +
1248 mem_block_ex->AlignmentSize - offset);
1249 mem_block_ex->pLogical = (PVOID)((ULONG)mem_block_ex->pLogical +
1250 mem_block_ex->AlignmentSize - offset);
1252 } /* if (mem_block_ex->uiLength !=
1253 * mem_block_ex->uiLengthOrig) */
1257 /* Copied directly from nvnet.c */
1259 nv_osfreeex(void *ctx, MEMORY_BLOCKEX *mem_block_ex)
1261 MEMORY_BLOCK mem_block;
1263 DEBUGOUT(NV_DEBUG_API, "nv: nv_osfreeex\n");
1265 mem_block.pLogical = mem_block_ex->pLogicalOrig;
1266 mem_block.pPhysical = (PVOID)mem_block_ex->pPhysicalOrigLow;
1267 mem_block.uiLength = mem_block_ex->uiLengthOrig;
1269 return (nv_osfree(ctx, &mem_block));
1272 /* Clear memory region */
1274 nv_osclear(void *ctx, void *mem, int length)
1276 DEBUGOUT(NV_DEBUG_API, "nv: nv_osclear\n");
1277 memset(mem, 0, length);
1281 /* Sleep for a tick */
1283 nv_osdelay(void *ctx, unsigned long usec)
1289 /* Allocate memory for rx buffer */
1291 nv_osallocrxbuf(void *ctx, MEMORY_BLOCK *mem, void **id)
1293 struct nv_softc *sc = ctx;
1294 struct nv_rx_desc *desc;
1295 struct nv_map_buffer *buf;
1300 DEBUGOUT(NV_DEBUG_API, "nv: nv_osallocrxbuf\n");
1302 if (sc->pending_rxs == RX_RING_SIZE) {
1303 device_printf(sc->dev, "rx ring buffer is full\n");
1306 desc = sc->rx_desc + sc->cur_rx;
1309 if (buf->mbuf == NULL) {
1310 buf->mbuf = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
1311 if (buf->mbuf == NULL) {
1312 device_printf(sc->dev, "failed to allocate memory\n");
1315 buf->mbuf->m_len = buf->mbuf->m_pkthdr.len = MCLBYTES;
1316 m_adj(buf->mbuf, ETHER_ALIGN);
1318 error = bus_dmamap_load_mbuf(sc->mtag, buf->map, buf->mbuf,
1319 nv_dmamap_rx_cb, &desc->paddr, 0);
1321 device_printf(sc->dev, "failed to dmamap mbuf\n");
1326 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_PREREAD);
1327 desc->buflength = buf->mbuf->m_len;
1328 desc->vaddr = mtod(buf->mbuf, PVOID);
1331 sc->cur_rx = (sc->cur_rx + 1) % RX_RING_SIZE;
1333 mem->pLogical = (void *)desc->vaddr;
1334 mem->pPhysical = (void *)desc->paddr;
1335 mem->uiLength = desc->buflength;
1345 /* Free the rx buffer */
1347 nv_osfreerxbuf(void *ctx, MEMORY_BLOCK *mem, void *id)
1349 struct nv_softc *sc = ctx;
1350 struct nv_rx_desc *desc;
1351 struct nv_map_buffer *buf;
1355 DEBUGOUT(NV_DEBUG_API, "nv: nv_osfreerxbuf\n");
1357 desc = (struct nv_rx_desc *) id;
1361 bus_dmamap_unload(sc->mtag, buf->map);
1362 bus_dmamap_destroy(sc->mtag, buf->map);
1373 /* This gets called by the Nvidia API after our TX packet has been sent */
1375 nv_ospackettx(void *ctx, void *id, unsigned long success)
1377 struct nv_softc *sc = ctx;
1378 struct nv_map_buffer *buf;
1379 struct nv_tx_desc *desc = (struct nv_tx_desc *) id;
1384 DEBUGOUT(NV_DEBUG_API, "nv: nv_ospackettx\n");
1390 if (buf->mbuf == NULL)
1393 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTWRITE);
1394 bus_dmamap_unload(sc->mtag, buf->map);
1400 if (ifp->if_snd.ifq_head != NULL && sc->pending_txs < TX_RING_SIZE)
1409 /* This gets called by the Nvidia API when a new packet has been received */
1410 /* XXX What is newbuf used for? XXX */
1412 nv_ospacketrx(void *ctx, void *data, unsigned long success,
1413 unsigned char *newbuf, unsigned char priority)
1415 struct nv_softc *sc = ctx;
1417 struct nv_rx_desc *desc;
1418 struct nv_map_buffer *buf;
1419 ADAPTER_READ_DATA *readdata;
1422 DEBUGOUT(NV_DEBUG_API, "nv: nv_ospacketrx\n");
1426 readdata = (ADAPTER_READ_DATA *) data;
1427 desc = readdata->pvID;
1429 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTREAD);
1432 /* Sync DMA bounce buffer. */
1433 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTREAD);
1435 /* First mbuf in packet holds the ethernet and packet headers */
1436 buf->mbuf->m_pkthdr.rcvif = ifp;
1437 buf->mbuf->m_pkthdr.len = buf->mbuf->m_len = readdata->ulTotalLength;
1439 bus_dmamap_unload(sc->mtag, buf->map);
1441 /* Give mbuf to OS. */
1442 (*ifp->if_input) (ifp, buf->mbuf);
1443 if (readdata->ulFilterMatch & ADREADFL_MULTICAST_MATCH)
1446 /* Blat the mbuf pointer, kernel will free the mbuf cluster */
1449 bus_dmamap_sync(sc->mtag, buf->map, BUS_DMASYNC_POSTREAD);
1450 bus_dmamap_unload(sc->mtag, buf->map);
1455 sc->cur_rx = desc - sc->rx_desc;
1463 /* This gets called by NVIDIA API when the PHY link state changes */
1465 nv_oslinkchg(void *ctx, int enabled)
1467 struct nv_softc *sc = (struct nv_softc *)ctx;
1470 DEBUGOUT(NV_DEBUG_API, "nv: nv_oslinkchg\n");
1475 ifp->if_flags |= IFF_UP;
1477 ifp->if_flags &= ~IFF_UP;
1484 /* Setup a watchdog timer */
1486 nv_osalloctimer(void *ctx, void **timer)
1488 struct nv_softc *sc = (struct nv_softc *)ctx;
1490 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osalloctimer\n");
1492 callout_handle_init(&sc->ostimer);
1493 *timer = &sc->ostimer;
1498 /* Free the timer */
1500 nv_osfreetimer(void *ctx, void *timer)
1502 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osfreetimer\n");
1507 /* Setup timer parameters */
1509 nv_osinittimer(void *ctx, void *timer, PTIMER_FUNC func, void *parameters)
1511 struct nv_softc *sc = (struct nv_softc *)ctx;
1513 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osinittimer\n");
1515 sc->ostimer_func = func;
1516 sc->ostimer_params = parameters;
1521 /* Set the timer to go off */
1523 nv_ossettimer(void *ctx, void *timer, unsigned long delay)
1525 struct nv_softc *sc = ctx;
1527 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_ossettimer\n");
1529 *(struct callout_handle *) timer = timeout(sc->ostimer_func, sc->ostimer_params, delay);
1534 /* Cancel the timer */
1536 nv_oscanceltimer(void *ctx, void *timer)
1538 struct nv_softc *sc = ctx;
1540 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_oscanceltimer\n");
1542 untimeout(sc->ostimer_func, sc->ostimer_params, *(struct callout_handle *) timer);
1548 nv_ospreprocpkt(void *ctx, void *readdata, void **id, unsigned char *newbuffer,
1549 unsigned char priority)
1551 /* Not implemented */
1552 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_ospreprocpkt\n");
1559 nv_ospreprocpktnopq(void *ctx, void *readdata)
1561 /* Not implemented */
1562 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_ospreprocpkt\n");
1568 nv_osindicatepkt(void *ctx, void **id, unsigned long pktno)
1570 /* Not implemented */
1571 DEBUGOUT(NV_DEBUG_BROKEN, "nv: nv_osindicatepkt\n");
1576 /* Allocate mutex context (already done in nv_attach) */
1578 nv_oslockalloc(void *ctx, int type, void **pLock)
1580 struct nv_softc *sc = (struct nv_softc *)ctx;
1582 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_oslockalloc\n");
1584 *pLock = (void **)sc;
1589 /* Obtain a spin lock */
1591 nv_oslockacquire(void *ctx, int type, void *lock)
1593 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_oslockacquire\n");
1595 NV_OSLOCK((struct nv_softc *)lock);
1602 nv_oslockrelease(void *ctx, int type, void *lock)
1604 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_oslockrelease\n");
1606 NV_OSUNLOCK((struct nv_softc *)lock);
1611 /* I have no idea what this is for */
1613 nv_osreturnbufvirt(void *ctx, void *readdata)
1615 /* Not implemented */
1616 DEBUGOUT(NV_DEBUG_LOCK, "nv: nv_osreturnbufvirt\n");
1617 panic("nv: nv_osreturnbufvirtual not implemented\n");
1623 /* --- End on NVOSAPI interface --- */