3627 bge_t *bgep; /* Our private data */
3628 mac_register_t *macp;
3629 chip_id_t *cidp;
3630 caddr_t regs;
3631 int instance;
3632 int err;
3633 int intr_types;
3634 int *props = NULL;
3635 uint_t numProps;
3636 uint32_t regval;
3637 uint32_t pci_state_reg;
3638 #ifdef BGE_IPMI_ASF
3639 uint32_t mhcrValue;
3640 #ifdef __sparc
3641 uint16_t value16;
3642 #endif
3643 #ifdef BGE_NETCONSOLE
3644 int retval;
3645 #endif
3646 #endif
3647
3648 instance = ddi_get_instance(devinfo);
3649
3650 BGE_GTRACE(("bge_attach($%p, %d) instance %d",
3651 (void *)devinfo, cmd, instance));
3652 BGE_BRKPT(NULL, "bge_attach");
3653
3654 switch (cmd) {
3655 default:
3656 return (DDI_FAILURE);
3657
3658 case DDI_RESUME:
3659 return (bge_resume(devinfo));
3660
3661 case DDI_ATTACH:
3662 break;
3663 }
3664
3665 bgep = kmem_zalloc(sizeof (*bgep), KM_SLEEP);
3666 bgep->pstats = kmem_zalloc(sizeof (bge_statistics_reg_t), KM_SLEEP);
3667 ddi_set_driver_private(devinfo, bgep);
3668 bgep->bge_guard = BGE_GUARD;
3669 bgep->devinfo = devinfo;
3670 bgep->param_drain_max = 64;
3671 bgep->param_msi_cnt = 0;
3672 bgep->param_loop_mode = 0;
3673
3674 /*
3675 * Initialize more fields in BGE private data
3676 */
3677 bgep->debug = ddi_prop_get_int(DDI_DEV_T_ANY, devinfo,
3678 DDI_PROP_DONTPASS, debug_propname, bge_debug);
3679 (void) snprintf(bgep->ifname, sizeof (bgep->ifname), "%s%d",
3680 BGE_DRIVER_NAME, instance);
3681
3682 /*
3683 * Initialize for fma support
3684 */
3685 bgep->fm_capabilities = ddi_prop_get_int(DDI_DEV_T_ANY, devinfo,
3686 DDI_PROP_DONTPASS, fm_cap,
3687 DDI_FM_EREPORT_CAPABLE | DDI_FM_ACCCHK_CAPABLE |
3688 DDI_FM_DMACHK_CAPABLE | DDI_FM_ERRCB_CAPABLE);
3689 BGE_DEBUG(("bgep->fm_capabilities = %d", bgep->fm_capabilities));
3690 bge_fm_init(bgep);
3691
3692 /*
3693 * Look up the IOMMU's page size for DVMA mappings (must be
3694 * a power of 2) and convert to a mask. This can be used to
3695 * determine whether a message buffer crosses a page boundary.
3696 * Note: in 2s complement binary notation, if X is a power of
3697 * 2, then -X has the representation "11...1100...00".
3698 */
3699 bgep->pagemask = dvma_pagesize(devinfo);
3700 ASSERT(ddi_ffs(bgep->pagemask) == ddi_fls(bgep->pagemask));
3701 bgep->pagemask = -bgep->pagemask;
3702
|
3627 bge_t *bgep; /* Our private data */
3628 mac_register_t *macp;
3629 chip_id_t *cidp;
3630 caddr_t regs;
3631 int instance;
3632 int err;
3633 int intr_types;
3634 int *props = NULL;
3635 uint_t numProps;
3636 uint32_t regval;
3637 uint32_t pci_state_reg;
3638 #ifdef BGE_IPMI_ASF
3639 uint32_t mhcrValue;
3640 #ifdef __sparc
3641 uint16_t value16;
3642 #endif
3643 #ifdef BGE_NETCONSOLE
3644 int retval;
3645 #endif
3646 #endif
3647 int prop_len = 128;
3648 char *prop_name, *prop_val;
3649
3650 instance = ddi_get_instance(devinfo);
3651
3652 BGE_GTRACE(("bge_attach($%p, %d) instance %d",
3653 (void *)devinfo, cmd, instance));
3654 BGE_BRKPT(NULL, "bge_attach");
3655
3656 switch (cmd) {
3657 default:
3658 return (DDI_FAILURE);
3659
3660 case DDI_RESUME:
3661 return (bge_resume(devinfo));
3662
3663 case DDI_ATTACH:
3664 break;
3665 }
3666
3667 bgep = kmem_zalloc(sizeof (*bgep), KM_SLEEP);
3668 bgep->pstats = kmem_zalloc(sizeof (bge_statistics_reg_t), KM_SLEEP);
3669 ddi_set_driver_private(devinfo, bgep);
3670 bgep->bge_guard = BGE_GUARD;
3671 bgep->devinfo = devinfo;
3672 bgep->param_drain_max = 64;
3673 bgep->param_msi_cnt = 0;
3674 bgep->param_loop_mode = 0;
3675
3676 /*
3677 * Initialize more fields in BGE private data
3678 */
3679 bgep->debug = ddi_prop_get_int(DDI_DEV_T_ANY, devinfo,
3680 DDI_PROP_DONTPASS, debug_propname, bge_debug);
3681 (void) snprintf(bgep->ifname, sizeof (bgep->ifname), "%s%d",
3682 BGE_DRIVER_NAME, instance);
3683
3684 /*
3685 * Check whether this specific instance has been disabled.
3686 */
3687 prop_name = kmem_zalloc(prop_len, KM_SLEEP);
3688 (void) snprintf(prop_name, prop_len, "disable-%s", bgep->ifname);
3689 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, devinfo, 0, prop_name,
3690 &prop_val) == DDI_SUCCESS) {
3691 if (strcmp(prop_val, "true") == 0) {
3692 ddi_prop_free(prop_val);
3693 kmem_free(prop_name, prop_len);
3694 goto attach_fail;
3695 }
3696 ddi_prop_free(prop_val);
3697 }
3698 kmem_free(prop_name, prop_len);
3699
3700 /*
3701 * Initialize for fma support
3702 */
3703 bgep->fm_capabilities = ddi_prop_get_int(DDI_DEV_T_ANY, devinfo,
3704 DDI_PROP_DONTPASS, fm_cap,
3705 DDI_FM_EREPORT_CAPABLE | DDI_FM_ACCCHK_CAPABLE |
3706 DDI_FM_DMACHK_CAPABLE | DDI_FM_ERRCB_CAPABLE);
3707 BGE_DEBUG(("bgep->fm_capabilities = %d", bgep->fm_capabilities));
3708 bge_fm_init(bgep);
3709
3710 /*
3711 * Look up the IOMMU's page size for DVMA mappings (must be
3712 * a power of 2) and convert to a mask. This can be used to
3713 * determine whether a message buffer crosses a page boundary.
3714 * Note: in 2s complement binary notation, if X is a power of
3715 * 2, then -X has the representation "11...1100...00".
3716 */
3717 bgep->pagemask = dvma_pagesize(devinfo);
3718 ASSERT(ddi_ffs(bgep->pagemask) == ddi_fls(bgep->pagemask));
3719 bgep->pagemask = -bgep->pagemask;
3720
|