998 dip = dev->d_dip;
999
1000 rv = ddi_intr_get_nintrs(dip, intr_type, &count);
1001 if ((rv != DDI_SUCCESS) || (count == 0)) {
1002 yge_error(dev, NULL,
1003 "ddi_intr_get_nintrs failed, rv %d, count %d", rv, count);
1004 return (DDI_FAILURE);
1005 }
1006
1007 /*
1008 * Allocate the interrupt. Note that we only bother with a single
1009 * interrupt. One could argue that for MSI devices with dual ports,
1010 * it would be nice to have a separate interrupt per port. But right
1011 * now I don't know how to configure that, so we'll just settle for
1012 * a single interrupt.
1013 */
1014 dev->d_intrcnt = 1;
1015
1016 dev->d_intrsize = count * sizeof (ddi_intr_handle_t);
1017 dev->d_intrh = kmem_zalloc(dev->d_intrsize, KM_SLEEP);
1018 if (dev->d_intrh == NULL) {
1019 yge_error(dev, NULL, "Unable to allocate interrupt handle");
1020 return (DDI_FAILURE);
1021 }
1022
1023 rv = ddi_intr_alloc(dip, dev->d_intrh, intr_type, 0, dev->d_intrcnt,
1024 &actual, DDI_INTR_ALLOC_STRICT);
1025 if ((rv != DDI_SUCCESS) || (actual == 0)) {
1026 yge_error(dev, NULL,
1027 "Unable to allocate interrupt, %d, count %d",
1028 rv, actual);
1029 kmem_free(dev->d_intrh, dev->d_intrsize);
1030 return (DDI_FAILURE);
1031 }
1032
1033 if ((rv = ddi_intr_get_pri(dev->d_intrh[0], &dev->d_intrpri)) !=
1034 DDI_SUCCESS) {
1035 for (i = 0; i < dev->d_intrcnt; i++)
1036 (void) ddi_intr_free(dev->d_intrh[i]);
1037 yge_error(dev, NULL,
1038 "Unable to get interrupt priority, %d", rv);
1039 kmem_free(dev->d_intrh, dev->d_intrsize);
1040 return (DDI_FAILURE);
1041 }
|
998 dip = dev->d_dip;
999
1000 rv = ddi_intr_get_nintrs(dip, intr_type, &count);
1001 if ((rv != DDI_SUCCESS) || (count == 0)) {
1002 yge_error(dev, NULL,
1003 "ddi_intr_get_nintrs failed, rv %d, count %d", rv, count);
1004 return (DDI_FAILURE);
1005 }
1006
1007 /*
1008 * Allocate the interrupt. Note that we only bother with a single
1009 * interrupt. One could argue that for MSI devices with dual ports,
1010 * it would be nice to have a separate interrupt per port. But right
1011 * now I don't know how to configure that, so we'll just settle for
1012 * a single interrupt.
1013 */
1014 dev->d_intrcnt = 1;
1015
1016 dev->d_intrsize = count * sizeof (ddi_intr_handle_t);
1017 dev->d_intrh = kmem_zalloc(dev->d_intrsize, KM_SLEEP);
1018
1019 rv = ddi_intr_alloc(dip, dev->d_intrh, intr_type, 0, dev->d_intrcnt,
1020 &actual, DDI_INTR_ALLOC_STRICT);
1021 if ((rv != DDI_SUCCESS) || (actual == 0)) {
1022 yge_error(dev, NULL,
1023 "Unable to allocate interrupt, %d, count %d",
1024 rv, actual);
1025 kmem_free(dev->d_intrh, dev->d_intrsize);
1026 return (DDI_FAILURE);
1027 }
1028
1029 if ((rv = ddi_intr_get_pri(dev->d_intrh[0], &dev->d_intrpri)) !=
1030 DDI_SUCCESS) {
1031 for (i = 0; i < dev->d_intrcnt; i++)
1032 (void) ddi_intr_free(dev->d_intrh[i]);
1033 yge_error(dev, NULL,
1034 "Unable to get interrupt priority, %d", rv);
1035 kmem_free(dev->d_intrh, dev->d_intrsize);
1036 return (DDI_FAILURE);
1037 }
|