if_ndis.c (141963) | if_ndis.c (142399) |
---|---|
1/*- 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/dev/if_ndis/if_ndis.c 141963 2005-02-16 05:41:18Z wpaul $"); | 34__FBSDID("$FreeBSD: head/sys/dev/if_ndis/if_ndis.c 142399 2005-02-24 21:49:14Z wpaul $"); |
35 36#include "opt_bdg.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sockio.h> 41#include <sys/mbuf.h> 42#include <sys/malloc.h> --- 380 unchanged lines hidden (view full) --- 423 */ 424int 425ndis_attach(dev) 426 device_t dev; 427{ 428 u_char eaddr[ETHER_ADDR_LEN]; 429 struct ndis_softc *sc; 430 driver_object *drv; | 35 36#include "opt_bdg.h" 37 38#include <sys/param.h> 39#include <sys/systm.h> 40#include <sys/sockio.h> 41#include <sys/mbuf.h> 42#include <sys/malloc.h> --- 380 unchanged lines hidden (view full) --- 423 */ 424int 425ndis_attach(dev) 426 device_t dev; 427{ 428 u_char eaddr[ETHER_ADDR_LEN]; 429 struct ndis_softc *sc; 430 driver_object *drv; |
431 driver_object *pdrv; |
|
431 device_object *pdo; 432 struct ifnet *ifp = NULL; 433 void *img; 434 int error = 0, len; 435 int i; 436 437 sc = device_get_softc(dev); 438 439 mtx_init(&sc->ndis_mtx, "ndis softc lock", 440 MTX_NETWORK_LOCK, MTX_DEF); 441 | 432 device_object *pdo; 433 struct ifnet *ifp = NULL; 434 void *img; 435 int error = 0, len; 436 int i; 437 438 sc = device_get_softc(dev); 439 440 mtx_init(&sc->ndis_mtx, "ndis softc lock", 441 MTX_NETWORK_LOCK, MTX_DEF); 442 |
442 /* | 443 /* |
443 * Hook interrupt early, since calling the driver's | 444 * Hook interrupt early, since calling the driver's |
444 * init routine may trigger an interrupt. | 445 * init routine may trigger an interrupt. Note that 446 * we don't need to do any explicit interrupt setup 447 * for USB. |
445 */ 446 | 448 */ 449 |
447 error = bus_setup_intr(dev, sc->ndis_irq, INTR_TYPE_NET | INTR_MPSAFE, 448 ndis_intr, sc, &sc->ndis_intrhand); | 450 if (sc->ndis_iftype == PCMCIABus || sc->ndis_iftype == PCIBus) { 451 error = bus_setup_intr(dev, sc->ndis_irq, 452 INTR_TYPE_NET | INTR_MPSAFE, 453 ndis_intr, sc, &sc->ndis_intrhand); |
449 | 454 |
450 if (error) { 451 device_printf(dev, "couldn't set up irq\n"); 452 goto fail; | 455 if (error) { 456 device_printf(dev, "couldn't set up irq\n"); 457 goto fail; 458 } |
453 } 454 455 if (sc->ndis_iftype == PCMCIABus) { 456 error = ndis_alloc_amem(sc); 457 if (error) { 458 device_printf(dev, "failed to allocate " 459 "attribute memory\n"); 460 goto fail; --- 4 unchanged lines hidden (view full) --- 465 466#if __FreeBSD_version < 502113 467 sysctl_ctx_init(&sc->ndis_ctx); 468 469#endif 470 /* Create sysctl registry nodes */ 471 ndis_create_sysctls(sc); 472 | 459 } 460 461 if (sc->ndis_iftype == PCMCIABus) { 462 error = ndis_alloc_amem(sc); 463 if (error) { 464 device_printf(dev, "failed to allocate " 465 "attribute memory\n"); 466 goto fail; --- 4 unchanged lines hidden (view full) --- 471 472#if __FreeBSD_version < 502113 473 sysctl_ctx_init(&sc->ndis_ctx); 474 475#endif 476 /* Create sysctl registry nodes */ 477 ndis_create_sysctls(sc); 478 |
479 /* Find the PDO for this device instance. */ 480 481 if (sc->ndis_iftype == PCIBus) 482 pdrv = windrv_lookup(NULL, "PCI Bus"); 483 else if (sc->ndis_iftype == PCMCIABus) 484 pdrv = windrv_lookup(NULL, "PCCARD Bus"); 485 else 486 pdrv = windrv_lookup(NULL, "USB Bus"); 487 pdo = windrv_find_pdo(pdrv, dev); 488 |
|
473 /* 474 * Create a new functional device object for this 475 * device. This is what creates the miniport block 476 * for this device instance. 477 */ 478 479 img = drv_data; | 489 /* 490 * Create a new functional device object for this 491 * device. This is what creates the miniport block 492 * for this device instance. 493 */ 494 495 img = drv_data; |
480 drv = windrv_lookup((vm_offset_t)img); 481 pdo = windrv_find_pdo(drv, dev); | 496 drv = windrv_lookup((vm_offset_t)img, NULL); |
482 if (NdisAddDevice(drv, pdo) != STATUS_SUCCESS) { 483 device_printf(dev, "failed to create FDO!\n"); 484 error = ENXIO; 485 goto fail; 486 } 487 488 /* Tell the user what version of the API the driver is using. */ 489 device_printf(dev, "NDIS API version: %d.%d\n", 490 sc->ndis_chars->nmc_version_major, 491 sc->ndis_chars->nmc_version_minor); 492 493 /* Do resource conversion. */ | 497 if (NdisAddDevice(drv, pdo) != STATUS_SUCCESS) { 498 device_printf(dev, "failed to create FDO!\n"); 499 error = ENXIO; 500 goto fail; 501 } 502 503 /* Tell the user what version of the API the driver is using. */ 504 device_printf(dev, "NDIS API version: %d.%d\n", 505 sc->ndis_chars->nmc_version_major, 506 sc->ndis_chars->nmc_version_minor); 507 508 /* Do resource conversion. */ |
494 ndis_convert_res(sc); | 509 if (sc->ndis_iftype == PCMCIABus || sc->ndis_iftype == PCIBus) 510 ndis_convert_res(sc); |
495 496 /* Install our RX and TX interrupt handlers. */ 497 sc->ndis_block->nmb_senddone_func = ndis_txeof_wrap; 498 sc->ndis_block->nmb_pktind_func = ndis_rxeof_wrap; 499 500 /* Call driver's init routine. */ 501 if (ndis_init_nic(sc)) { 502 device_printf (dev, "init handler failed\n"); --- 349 unchanged lines hidden (view full) --- 852 853 if (sc->ndis_txpool != NULL) 854 NdisFreePacketPool(sc->ndis_txpool); 855 856 ndis_unload_driver(sc); 857 858 /* Destroy the PDO for this device. */ 859 | 511 512 /* Install our RX and TX interrupt handlers. */ 513 sc->ndis_block->nmb_senddone_func = ndis_txeof_wrap; 514 sc->ndis_block->nmb_pktind_func = ndis_rxeof_wrap; 515 516 /* Call driver's init routine. */ 517 if (ndis_init_nic(sc)) { 518 device_printf (dev, "init handler failed\n"); --- 349 unchanged lines hidden (view full) --- 868 869 if (sc->ndis_txpool != NULL) 870 NdisFreePacketPool(sc->ndis_txpool); 871 872 ndis_unload_driver(sc); 873 874 /* Destroy the PDO for this device. */ 875 |
860 drv = windrv_lookup((vm_offset_t)drv_data); | 876 if (sc->ndis_iftype == PCIBus) 877 drv = windrv_lookup(NULL, "PCI Bus"); 878 else if (sc->ndis_iftype == PCMCIABus) 879 drv = windrv_lookup(NULL, "PCCARD Bus"); 880 else 881 drv = windrv_lookup(NULL, "USB Bus"); |
861 if (drv == NULL) 862 panic("couldn't find driver object"); 863 windrv_destroy_pdo(drv, dev); 864 865 if (sc->ndis_iftype == PCIBus) 866 bus_dma_tag_destroy(sc->ndis_parent_tag); 867 868#if __FreeBSD_version < 502113 --- 1538 unchanged lines hidden --- | 882 if (drv == NULL) 883 panic("couldn't find driver object"); 884 windrv_destroy_pdo(drv, dev); 885 886 if (sc->ndis_iftype == PCIBus) 887 bus_dma_tag_destroy(sc->ndis_parent_tag); 888 889#if __FreeBSD_version < 502113 --- 1538 unchanged lines hidden --- |