xref: /illumos-gate/usr/src/uts/i86pc/io/pcplusmp/apic_introp.c (revision aaceae985c2e78cadef76bf0b7b50ed887ccb3a6)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5685482d6Sjohnny  * Common Development and Distribution License (the "License").
6685482d6Sjohnny  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
224e30c628SEvan Yan  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
238181b438SGarrett D'Amore  * Copyright 2013 Pluribus Networks, Inc.
24*30acb30dSHans Rosenfeld  * Copyright 2017 Joyent, Inc.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
287c478bd9Sstevel@tonic-gate  * apic_introp.c:
297c478bd9Sstevel@tonic-gate  *	Has code for Advanced DDI interrupt framework support.
307c478bd9Sstevel@tonic-gate  */
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/cpuvar.h>
337c478bd9Sstevel@tonic-gate #include <sys/psm.h>
34ae115bc7Smrj #include <sys/archsystm.h>
35ae115bc7Smrj #include <sys/apic.h>
367c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
377c478bd9Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
387a364d25Sschwartz #include <sys/mach_intr.h>
397a364d25Sschwartz #include <sys/sysmacros.h>
407c478bd9Sstevel@tonic-gate #include <sys/trap.h>
417c478bd9Sstevel@tonic-gate #include <sys/pci.h>
427c478bd9Sstevel@tonic-gate #include <sys/pci_intr_lib.h>
437ff178cdSJimmy Vetayases #include <sys/apic_common.h>
447c478bd9Sstevel@tonic-gate 
457a364d25Sschwartz extern struct av_head autovect[];
467a364d25Sschwartz 
477c478bd9Sstevel@tonic-gate /*
487c478bd9Sstevel@tonic-gate  *	Local Function Prototypes
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate apic_irq_t	*apic_find_irq(dev_info_t *, struct intrspec *, int);
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * apic_pci_msi_enable_vector:
547c478bd9Sstevel@tonic-gate  *	Set the address/data fields in the MSI/X capability structure
557c478bd9Sstevel@tonic-gate  *	XXX: MSI-X support
567c478bd9Sstevel@tonic-gate  */
577c478bd9Sstevel@tonic-gate /* ARGSUSED */
58a7639048Sjohnny void
apic_pci_msi_enable_vector(apic_irq_t * irq_ptr,int type,int inum,int vector,int count,int target_apic_id)59bb8220baSVikram Hegde apic_pci_msi_enable_vector(apic_irq_t *irq_ptr, int type, int inum, int vector,
607c478bd9Sstevel@tonic-gate     int count, int target_apic_id)
617c478bd9Sstevel@tonic-gate {
627c478bd9Sstevel@tonic-gate 	uint64_t		msi_addr, msi_data;
63d12abe7cSanish 	ushort_t		msi_ctrl;
64bb8220baSVikram Hegde 	dev_info_t		*dip = irq_ptr->airq_dip;
65d12abe7cSanish 	int			cap_ptr = i_ddi_get_msi_msix_cap_ptr(dip);
66d12abe7cSanish 	ddi_acc_handle_t	handle = i_ddi_get_pci_config_handle(dip);
67bb8220baSVikram Hegde 	msi_regs_t		msi_regs;
687ff178cdSJimmy Vetayases 	int			irqno, i;
697ff178cdSJimmy Vetayases 	void			*intrmap_tbl[PCI_MSI_MAX_INTRS];
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_pci_msi_enable_vector: dip=0x%p\n"
727c478bd9Sstevel@tonic-gate 	    "\tdriver = %s, inum=0x%x vector=0x%x apicid=0x%x\n", (void *)dip,
737c478bd9Sstevel@tonic-gate 	    ddi_driver_name(dip), inum, vector, target_apic_id));
747c478bd9Sstevel@tonic-gate 
75a7639048Sjohnny 	ASSERT((handle != NULL) && (cap_ptr != 0));
76d12abe7cSanish 
77bb8220baSVikram Hegde 	msi_regs.mr_data = vector;
78bb8220baSVikram Hegde 	msi_regs.mr_addr = target_apic_id;
79bb8220baSVikram Hegde 
802edb3dccSJudy Chen 	for (i = 0; i < count; i++) {
812edb3dccSJudy Chen 		irqno = apic_vector_to_irq[vector + i];
822edb3dccSJudy Chen 		intrmap_tbl[i] = apic_irq_table[irqno]->airq_intrmap_private;
832edb3dccSJudy Chen 	}
847ff178cdSJimmy Vetayases 	apic_vt_ops->apic_intrmap_alloc_entry(intrmap_tbl, dip, type,
857ff178cdSJimmy Vetayases 	    count, 0xff);
867ff178cdSJimmy Vetayases 	for (i = 0; i < count; i++) {
877ff178cdSJimmy Vetayases 		irqno = apic_vector_to_irq[vector + i];
887ff178cdSJimmy Vetayases 		apic_irq_table[irqno]->airq_intrmap_private =
897ff178cdSJimmy Vetayases 		    intrmap_tbl[i];
907ff178cdSJimmy Vetayases 	}
917ff178cdSJimmy Vetayases 
927ff178cdSJimmy Vetayases 	apic_vt_ops->apic_intrmap_map_entry(irq_ptr->airq_intrmap_private,
937ff178cdSJimmy Vetayases 	    (void *)&msi_regs, type, count);
947ff178cdSJimmy Vetayases 	apic_vt_ops->apic_intrmap_record_msi(irq_ptr->airq_intrmap_private,
957ff178cdSJimmy Vetayases 	    &msi_regs);
966bdf0ab5SVikram Hegde 
977c478bd9Sstevel@tonic-gate 	/* MSI Address */
98bb8220baSVikram Hegde 	msi_addr = msi_regs.mr_addr;
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	/* MSI Data: MSI is edge triggered according to spec */
101bb8220baSVikram Hegde 	msi_data = msi_regs.mr_data;
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_pci_msi_enable_vector: addr=0x%lx "
1047c478bd9Sstevel@tonic-gate 	    "data=0x%lx\n", (long)msi_addr, (long)msi_data));
1057c478bd9Sstevel@tonic-gate 
106d12abe7cSanish 	if (type == DDI_INTR_TYPE_MSI) {
107d12abe7cSanish 		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSI_CTRL);
108d12abe7cSanish 
109d12abe7cSanish 		/* Set the bits to inform how many MSIs are enabled */
110d12abe7cSanish 		msi_ctrl |= ((highbit(count) -1) << PCI_MSI_MME_SHIFT);
111d12abe7cSanish 		pci_config_put16(handle, cap_ptr + PCI_MSI_CTRL, msi_ctrl);
112d12abe7cSanish 
113349b53ddSStuart Maybee 		/*
114349b53ddSStuart Maybee 		 * Only set vector if not on hypervisor
115349b53ddSStuart Maybee 		 */
116d12abe7cSanish 		pci_config_put32(handle,
117d12abe7cSanish 		    cap_ptr + PCI_MSI_ADDR_OFFSET, msi_addr);
118d12abe7cSanish 
119d12abe7cSanish 		if (msi_ctrl &  PCI_MSI_64BIT_MASK) {
120d12abe7cSanish 			pci_config_put32(handle,
121d12abe7cSanish 			    cap_ptr + PCI_MSI_ADDR_OFFSET + 4, msi_addr >> 32);
122d12abe7cSanish 			pci_config_put16(handle,
123d12abe7cSanish 			    cap_ptr + PCI_MSI_64BIT_DATA, msi_data);
124d12abe7cSanish 		} else {
125d12abe7cSanish 			pci_config_put16(handle,
126d12abe7cSanish 			    cap_ptr + PCI_MSI_32BIT_DATA, msi_data);
127d12abe7cSanish 		}
128d12abe7cSanish 
129d12abe7cSanish 	} else if (type == DDI_INTR_TYPE_MSIX) {
130d12abe7cSanish 		uintptr_t	off;
131d12abe7cSanish 		ddi_intr_msix_t	*msix_p = i_ddi_get_msix(dip);
132d12abe7cSanish 
133fbb8dc2cSlipeng sang - Sun Microsystems - Beijing China 		ASSERT(msix_p != NULL);
134fbb8dc2cSlipeng sang - Sun Microsystems - Beijing China 
135d12abe7cSanish 		/* Offset into the "inum"th entry in the MSI-X table */
136d12abe7cSanish 		off = (uintptr_t)msix_p->msix_tbl_addr +
137d12abe7cSanish 		    (inum  * PCI_MSIX_VECTOR_SIZE);
138d12abe7cSanish 
139d12abe7cSanish 		ddi_put32(msix_p->msix_tbl_hdl,
140d12abe7cSanish 		    (uint32_t *)(off + PCI_MSIX_DATA_OFFSET), msi_data);
1418181b438SGarrett D'Amore 		ddi_put32(msix_p->msix_tbl_hdl,
1428181b438SGarrett D'Amore 		    (uint32_t *)(off + PCI_MSIX_LOWER_ADDR_OFFSET), msi_addr);
1438181b438SGarrett D'Amore 		ddi_put32(msix_p->msix_tbl_hdl,
1448181b438SGarrett D'Amore 		    (uint32_t *)(off + PCI_MSIX_UPPER_ADDR_OFFSET),
1458181b438SGarrett D'Amore 		    msi_addr >> 32);
1467c478bd9Sstevel@tonic-gate 	}
1477c478bd9Sstevel@tonic-gate }
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /*
1507c478bd9Sstevel@tonic-gate  * This function returns the no. of vectors available for the pri.
1517c478bd9Sstevel@tonic-gate  * dip is not used at this moment.  If we really don't need that,
1527c478bd9Sstevel@tonic-gate  * it will be removed.
1537c478bd9Sstevel@tonic-gate  */
1547c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1557c478bd9Sstevel@tonic-gate int
apic_navail_vector(dev_info_t * dip,int pri)1567c478bd9Sstevel@tonic-gate apic_navail_vector(dev_info_t *dip, int pri)
1577c478bd9Sstevel@tonic-gate {
1587c478bd9Sstevel@tonic-gate 	int	lowest, highest, i, navail, count;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_navail_vector: dip: %p, pri: %x\n",
1617c478bd9Sstevel@tonic-gate 	    (void *)dip, pri));
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate 	highest = apic_ipltopri[pri] + APIC_VECTOR_MASK;
1647c478bd9Sstevel@tonic-gate 	lowest = apic_ipltopri[pri - 1] + APIC_VECTOR_PER_IPL;
1657c478bd9Sstevel@tonic-gate 	navail = count = 0;
1667c478bd9Sstevel@tonic-gate 
167b6917abeSmishra 	if (highest < lowest) /* Both ipl and ipl - 1 map to same pri */
168b6917abeSmishra 		lowest -= APIC_VECTOR_PER_IPL;
169b6917abeSmishra 
1707c478bd9Sstevel@tonic-gate 	/* It has to be contiguous */
17126896e4cSGuoli Shu 	for (i = lowest; i <= highest; i++) {
1727c478bd9Sstevel@tonic-gate 		count = 0;
1737c478bd9Sstevel@tonic-gate 		while ((apic_vector_to_irq[i] == APIC_RESV_IRQ) &&
17426896e4cSGuoli Shu 		    (i <= highest)) {
1750ccf9e79Sjohnny 			if (APIC_CHECK_RESERVE_VECTORS(i))
1767c478bd9Sstevel@tonic-gate 				break;
1777c478bd9Sstevel@tonic-gate 			count++;
1787c478bd9Sstevel@tonic-gate 			i++;
1797c478bd9Sstevel@tonic-gate 		}
1807c478bd9Sstevel@tonic-gate 		if (count > navail)
1817c478bd9Sstevel@tonic-gate 			navail = count;
1827c478bd9Sstevel@tonic-gate 	}
1837c478bd9Sstevel@tonic-gate 	return (navail);
1847c478bd9Sstevel@tonic-gate }
1857c478bd9Sstevel@tonic-gate 
1860ccf9e79Sjohnny /*
1870ccf9e79Sjohnny  * Finds "count" contiguous MSI vectors starting at the proper alignment
1880ccf9e79Sjohnny  * at "pri".
1890ccf9e79Sjohnny  * Caller needs to make sure that count has to be power of 2 and should not
1900ccf9e79Sjohnny  * be < 1.
1910ccf9e79Sjohnny  */
192ae115bc7Smrj uchar_t
apic_find_multi_vectors(int pri,int count)1937c478bd9Sstevel@tonic-gate apic_find_multi_vectors(int pri, int count)
1947c478bd9Sstevel@tonic-gate {
1950ccf9e79Sjohnny 	int	lowest, highest, i, navail, start, msibits;
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_find_mult: pri: %x, count: %x\n",
1987c478bd9Sstevel@tonic-gate 	    pri, count));
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate 	highest = apic_ipltopri[pri] + APIC_VECTOR_MASK;
2017c478bd9Sstevel@tonic-gate 	lowest = apic_ipltopri[pri - 1] + APIC_VECTOR_PER_IPL;
2027c478bd9Sstevel@tonic-gate 	navail = 0;
2037c478bd9Sstevel@tonic-gate 
204b6917abeSmishra 	if (highest < lowest) /* Both ipl and ipl - 1 map to same pri */
205b6917abeSmishra 		lowest -= APIC_VECTOR_PER_IPL;
206b6917abeSmishra 
2070ccf9e79Sjohnny 	/*
2080ccf9e79Sjohnny 	 * msibits is the no. of lower order message data bits for the
2090ccf9e79Sjohnny 	 * allocated MSI vectors and is used to calculate the aligned
2100ccf9e79Sjohnny 	 * starting vector
2110ccf9e79Sjohnny 	 */
2120ccf9e79Sjohnny 	msibits = count - 1;
2130ccf9e79Sjohnny 
2147c478bd9Sstevel@tonic-gate 	/* It has to be contiguous */
21526896e4cSGuoli Shu 	for (i = lowest; i <= highest; i++) {
2167c478bd9Sstevel@tonic-gate 		navail = 0;
2170ccf9e79Sjohnny 
2180ccf9e79Sjohnny 		/*
2190ccf9e79Sjohnny 		 * starting vector has to be aligned accordingly for
2200ccf9e79Sjohnny 		 * multiple MSIs
2210ccf9e79Sjohnny 		 */
2220ccf9e79Sjohnny 		if (msibits)
2230ccf9e79Sjohnny 			i = (i + msibits) & ~msibits;
2247c478bd9Sstevel@tonic-gate 		start = i;
2257c478bd9Sstevel@tonic-gate 		while ((apic_vector_to_irq[i] == APIC_RESV_IRQ) &&
22626896e4cSGuoli Shu 		    (i <= highest)) {
2270ccf9e79Sjohnny 			if (APIC_CHECK_RESERVE_VECTORS(i))
2287c478bd9Sstevel@tonic-gate 				break;
2297c478bd9Sstevel@tonic-gate 			navail++;
230*30acb30dSHans Rosenfeld 			if (navail >= count) {
231*30acb30dSHans Rosenfeld 				ASSERT(start >= 0 && start <= UCHAR_MAX);
232*30acb30dSHans Rosenfeld 				return ((uchar_t)start);
233*30acb30dSHans Rosenfeld 			}
2347c478bd9Sstevel@tonic-gate 			i++;
2357c478bd9Sstevel@tonic-gate 		}
2367c478bd9Sstevel@tonic-gate 	}
2377c478bd9Sstevel@tonic-gate 	return (0);
2387c478bd9Sstevel@tonic-gate }
2397c478bd9Sstevel@tonic-gate 
240ae115bc7Smrj 
2417c478bd9Sstevel@tonic-gate /*
2427c478bd9Sstevel@tonic-gate  * It finds the apic_irq_t associates with the dip, ispec and type.
2437c478bd9Sstevel@tonic-gate  */
2447c478bd9Sstevel@tonic-gate apic_irq_t *
apic_find_irq(dev_info_t * dip,struct intrspec * ispec,int type)2457c478bd9Sstevel@tonic-gate apic_find_irq(dev_info_t *dip, struct intrspec *ispec, int type)
2467c478bd9Sstevel@tonic-gate {
2477c478bd9Sstevel@tonic-gate 	apic_irq_t	*irqp;
2487c478bd9Sstevel@tonic-gate 	int i;
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_find_irq: dip=0x%p vec=0x%x "
2517c478bd9Sstevel@tonic-gate 	    "ipl=0x%x type=0x%x\n", (void *)dip, ispec->intrspec_vec,
2527c478bd9Sstevel@tonic-gate 	    ispec->intrspec_pri, type));
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate 	for (i = apic_min_device_irq; i <= apic_max_device_irq; i++) {
25586a9c507SGuoli Shu 		for (irqp = apic_irq_table[i]; irqp; irqp = irqp->airq_next) {
2567c478bd9Sstevel@tonic-gate 			if ((irqp->airq_dip == dip) &&
2577c478bd9Sstevel@tonic-gate 			    (irqp->airq_origirq == ispec->intrspec_vec) &&
2587c478bd9Sstevel@tonic-gate 			    (irqp->airq_ipl == ispec->intrspec_pri)) {
259a7639048Sjohnny 				if (type == DDI_INTR_TYPE_MSI) {
26086a9c507SGuoli Shu 					if (irqp->airq_mps_intr_index ==
26186a9c507SGuoli Shu 					    MSI_INDEX)
262a7639048Sjohnny 						return (irqp);
263a7639048Sjohnny 				} else if (type == DDI_INTR_TYPE_MSIX) {
26486a9c507SGuoli Shu 					if (irqp->airq_mps_intr_index ==
26586a9c507SGuoli Shu 					    MSIX_INDEX)
2667c478bd9Sstevel@tonic-gate 						return (irqp);
2677c478bd9Sstevel@tonic-gate 				} else
2687c478bd9Sstevel@tonic-gate 					return (irqp);
2697c478bd9Sstevel@tonic-gate 			}
2707c478bd9Sstevel@tonic-gate 		}
27186a9c507SGuoli Shu 	}
2727c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_find_irq: return NULL\n"));
2737c478bd9Sstevel@tonic-gate 	return (NULL);
2747c478bd9Sstevel@tonic-gate }
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /*
2777c478bd9Sstevel@tonic-gate  * This function will return the pending bit of the irqp.
2787c478bd9Sstevel@tonic-gate  * It either comes from the IRR register of the APIC or the RDT
2797c478bd9Sstevel@tonic-gate  * entry of the I/O APIC.
2807c478bd9Sstevel@tonic-gate  * For the IRR to work, it needs to be to its binding CPU
2817c478bd9Sstevel@tonic-gate  */
2827c478bd9Sstevel@tonic-gate static int
apic_get_pending(apic_irq_t * irqp,int type)2837c478bd9Sstevel@tonic-gate apic_get_pending(apic_irq_t *irqp, int type)
2847c478bd9Sstevel@tonic-gate {
2857c478bd9Sstevel@tonic-gate 	int			bit, index, irr, pending;
2867c478bd9Sstevel@tonic-gate 	int			intin_no;
287ae115bc7Smrj 	int			apic_ix;
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_get_pending: irqp: %p, cpuid: %x "
2907c478bd9Sstevel@tonic-gate 	    "type: %x\n", (void *)irqp, irqp->airq_cpu & ~IRQ_USER_BOUND,
2917c478bd9Sstevel@tonic-gate 	    type));
2927c478bd9Sstevel@tonic-gate 
2937c478bd9Sstevel@tonic-gate 	/* need to get on the bound cpu */
2947c478bd9Sstevel@tonic-gate 	mutex_enter(&cpu_lock);
2957c478bd9Sstevel@tonic-gate 	affinity_set(irqp->airq_cpu & ~IRQ_USER_BOUND);
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	index = irqp->airq_vector / 32;
2987c478bd9Sstevel@tonic-gate 	bit = irqp->airq_vector % 32;
299b6917abeSmishra 	irr = apic_reg_ops->apic_read(APIC_IRR_REG + index);
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate 	affinity_clear();
3027c478bd9Sstevel@tonic-gate 	mutex_exit(&cpu_lock);
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 	pending = (irr & (1 << bit)) ? 1 : 0;
3057c478bd9Sstevel@tonic-gate 	if (!pending && (type == DDI_INTR_TYPE_FIXED)) {
3067c478bd9Sstevel@tonic-gate 		/* check I/O APIC for fixed interrupt */
3077c478bd9Sstevel@tonic-gate 		intin_no = irqp->airq_intin_no;
308ae115bc7Smrj 		apic_ix = irqp->airq_ioapicindex;
309ae115bc7Smrj 		pending = (READ_IOAPIC_RDT_ENTRY_LOW_DWORD(apic_ix, intin_no) &
3107c478bd9Sstevel@tonic-gate 		    AV_PENDING) ? 1 : 0;
3117c478bd9Sstevel@tonic-gate 	}
3127c478bd9Sstevel@tonic-gate 	return (pending);
3137c478bd9Sstevel@tonic-gate }
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * This function will clear the mask for the interrupt on the I/O APIC
3187c478bd9Sstevel@tonic-gate  */
3197c478bd9Sstevel@tonic-gate static void
apic_clear_mask(apic_irq_t * irqp)3207c478bd9Sstevel@tonic-gate apic_clear_mask(apic_irq_t *irqp)
3217c478bd9Sstevel@tonic-gate {
3227c478bd9Sstevel@tonic-gate 	int			intin_no;
323ae115bc7Smrj 	ulong_t			iflag;
3247c478bd9Sstevel@tonic-gate 	int32_t			rdt_entry;
325ae115bc7Smrj 	int			apic_ix;
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_clear_mask: irqp: %p\n",
3287c478bd9Sstevel@tonic-gate 	    (void *)irqp));
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate 	intin_no = irqp->airq_intin_no;
331ae115bc7Smrj 	apic_ix = irqp->airq_ioapicindex;
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate 	iflag = intr_clear();
3347c478bd9Sstevel@tonic-gate 	lock_set(&apic_ioapic_lock);
3357c478bd9Sstevel@tonic-gate 
336ae115bc7Smrj 	rdt_entry = READ_IOAPIC_RDT_ENTRY_LOW_DWORD(apic_ix, intin_no);
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 	/* clear mask */
339ae115bc7Smrj 	WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(apic_ix, intin_no,
3407c478bd9Sstevel@tonic-gate 	    ((~AV_MASK) & rdt_entry));
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate 	lock_clear(&apic_ioapic_lock);
3437c478bd9Sstevel@tonic-gate 	intr_restore(iflag);
3447c478bd9Sstevel@tonic-gate }
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate /*
3487c478bd9Sstevel@tonic-gate  * This function will mask the interrupt on the I/O APIC
3497c478bd9Sstevel@tonic-gate  */
3507c478bd9Sstevel@tonic-gate static void
apic_set_mask(apic_irq_t * irqp)3517c478bd9Sstevel@tonic-gate apic_set_mask(apic_irq_t *irqp)
3527c478bd9Sstevel@tonic-gate {
3537c478bd9Sstevel@tonic-gate 	int			intin_no;
354ae115bc7Smrj 	int			apic_ix;
355ae115bc7Smrj 	ulong_t			iflag;
3567c478bd9Sstevel@tonic-gate 	int32_t			rdt_entry;
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_set_mask: irqp: %p\n", (void *)irqp));
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate 	intin_no = irqp->airq_intin_no;
361ae115bc7Smrj 	apic_ix = irqp->airq_ioapicindex;
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate 	iflag = intr_clear();
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate 	lock_set(&apic_ioapic_lock);
3667c478bd9Sstevel@tonic-gate 
367ae115bc7Smrj 	rdt_entry = READ_IOAPIC_RDT_ENTRY_LOW_DWORD(apic_ix, intin_no);
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate 	/* mask it */
370ae115bc7Smrj 	WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(apic_ix, intin_no,
3717c478bd9Sstevel@tonic-gate 	    (AV_MASK | rdt_entry));
3727c478bd9Sstevel@tonic-gate 
3737c478bd9Sstevel@tonic-gate 	lock_clear(&apic_ioapic_lock);
3747c478bd9Sstevel@tonic-gate 	intr_restore(iflag);
3757c478bd9Sstevel@tonic-gate }
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate void
apic_free_vectors(dev_info_t * dip,int inum,int count,int pri,int type)3797c478bd9Sstevel@tonic-gate apic_free_vectors(dev_info_t *dip, int inum, int count, int pri, int type)
3807c478bd9Sstevel@tonic-gate {
3817c478bd9Sstevel@tonic-gate 	int i;
3827c478bd9Sstevel@tonic-gate 	apic_irq_t *irqptr;
3837c478bd9Sstevel@tonic-gate 	struct intrspec ispec;
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_free_vectors: dip: %p inum: %x "
3867c478bd9Sstevel@tonic-gate 	    "count: %x pri: %x type: %x\n",
3877c478bd9Sstevel@tonic-gate 	    (void *)dip, inum, count, pri, type));
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate 	/* for MSI/X only */
3907c478bd9Sstevel@tonic-gate 	if (!DDI_INTR_IS_MSI_OR_MSIX(type))
3917c478bd9Sstevel@tonic-gate 		return;
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate 	for (i = 0; i < count; i++) {
3947c478bd9Sstevel@tonic-gate 		DDI_INTR_IMPLDBG((CE_CONT, "apic_free_vectors: inum=0x%x "
3957c478bd9Sstevel@tonic-gate 		    "pri=0x%x count=0x%x\n", inum, pri, count));
3967c478bd9Sstevel@tonic-gate 		ispec.intrspec_vec = inum + i;
3977c478bd9Sstevel@tonic-gate 		ispec.intrspec_pri = pri;
3987c478bd9Sstevel@tonic-gate 		if ((irqptr = apic_find_irq(dip, &ispec, type)) == NULL) {
3997c478bd9Sstevel@tonic-gate 			DDI_INTR_IMPLDBG((CE_CONT, "apic_free_vectors: "
4007c478bd9Sstevel@tonic-gate 			    "dip=0x%p inum=0x%x pri=0x%x apic_find_irq() "
4017c478bd9Sstevel@tonic-gate 			    "failed\n", (void *)dip, inum, pri));
4027c478bd9Sstevel@tonic-gate 			continue;
4037c478bd9Sstevel@tonic-gate 		}
4047c478bd9Sstevel@tonic-gate 		irqptr->airq_mps_intr_index = FREE_INDEX;
4057c478bd9Sstevel@tonic-gate 		apic_vector_to_irq[irqptr->airq_vector] = APIC_RESV_IRQ;
4067c478bd9Sstevel@tonic-gate 	}
4077c478bd9Sstevel@tonic-gate }
4087c478bd9Sstevel@tonic-gate 
409d12abe7cSanish /*
410d12abe7cSanish  * apic_pci_msi_enable_mode:
411d12abe7cSanish  */
412a7639048Sjohnny void
apic_pci_msi_enable_mode(dev_info_t * rdip,int type,int inum)413d12abe7cSanish apic_pci_msi_enable_mode(dev_info_t *rdip, int type, int inum)
414d12abe7cSanish {
415d12abe7cSanish 	ushort_t		msi_ctrl;
416d12abe7cSanish 	int			cap_ptr = i_ddi_get_msi_msix_cap_ptr(rdip);
417d12abe7cSanish 	ddi_acc_handle_t	handle = i_ddi_get_pci_config_handle(rdip);
418d12abe7cSanish 
419a7639048Sjohnny 	ASSERT((handle != NULL) && (cap_ptr != 0));
420d12abe7cSanish 
421d12abe7cSanish 	if (type == DDI_INTR_TYPE_MSI) {
422d12abe7cSanish 		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSI_CTRL);
423d12abe7cSanish 		if ((msi_ctrl & PCI_MSI_ENABLE_BIT))
424a7639048Sjohnny 			return;
425d12abe7cSanish 
426d12abe7cSanish 		msi_ctrl |= PCI_MSI_ENABLE_BIT;
427d12abe7cSanish 		pci_config_put16(handle, cap_ptr + PCI_MSI_CTRL, msi_ctrl);
428d12abe7cSanish 
429d12abe7cSanish 	} else if (type == DDI_INTR_TYPE_MSIX) {
430d12abe7cSanish 		uintptr_t	off;
431a7639048Sjohnny 		uint32_t	mask;
432d12abe7cSanish 		ddi_intr_msix_t	*msix_p;
433d12abe7cSanish 
434d12abe7cSanish 		msix_p = i_ddi_get_msix(rdip);
435d12abe7cSanish 
436fbb8dc2cSlipeng sang - Sun Microsystems - Beijing China 		ASSERT(msix_p != NULL);
437fbb8dc2cSlipeng sang - Sun Microsystems - Beijing China 
438d12abe7cSanish 		/* Offset into "inum"th entry in the MSI-X table & clear mask */
439d12abe7cSanish 		off = (uintptr_t)msix_p->msix_tbl_addr + (inum *
440d12abe7cSanish 		    PCI_MSIX_VECTOR_SIZE) + PCI_MSIX_VECTOR_CTRL_OFFSET;
441d12abe7cSanish 
442a7639048Sjohnny 		mask = ddi_get32(msix_p->msix_tbl_hdl, (uint32_t *)off);
443a7639048Sjohnny 
444a7639048Sjohnny 		ddi_put32(msix_p->msix_tbl_hdl, (uint32_t *)off, (mask & ~1));
445a7639048Sjohnny 
446a7639048Sjohnny 		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSIX_CTRL);
447a7639048Sjohnny 
448a7639048Sjohnny 		if (!(msi_ctrl & PCI_MSIX_ENABLE_BIT)) {
449a7639048Sjohnny 			msi_ctrl |= PCI_MSIX_ENABLE_BIT;
450a7639048Sjohnny 			pci_config_put16(handle, cap_ptr + PCI_MSIX_CTRL,
451a7639048Sjohnny 			    msi_ctrl);
452a7639048Sjohnny 		}
453a7639048Sjohnny 	}
454d12abe7cSanish }
455d12abe7cSanish 
4562917a9c9Sschwartz static int
apic_set_cpu(int irqno,int cpu,int * result)45709b1eac2SEvan Yan apic_set_cpu(int irqno, int cpu, int *result)
4582917a9c9Sschwartz {
4592917a9c9Sschwartz 	apic_irq_t *irqp;
460a563a037Sbholler 	ulong_t iflag;
4612917a9c9Sschwartz 	int ret;
4622917a9c9Sschwartz 
4632917a9c9Sschwartz 	DDI_INTR_IMPLDBG((CE_CONT, "APIC_SET_CPU\n"));
4642917a9c9Sschwartz 
4652917a9c9Sschwartz 	mutex_enter(&airq_mutex);
46609b1eac2SEvan Yan 	irqp = apic_irq_table[irqno];
4672917a9c9Sschwartz 	mutex_exit(&airq_mutex);
4682917a9c9Sschwartz 
4692917a9c9Sschwartz 	if (irqp == NULL) {
4702917a9c9Sschwartz 		*result = ENXIO;
4712917a9c9Sschwartz 		return (PSM_FAILURE);
4722917a9c9Sschwartz 	}
4732917a9c9Sschwartz 
4742917a9c9Sschwartz 	/* Fail if this is an MSI intr and is part of a group. */
4752917a9c9Sschwartz 	if ((irqp->airq_mps_intr_index == MSI_INDEX) &&
4762917a9c9Sschwartz 	    (irqp->airq_intin_no > 1)) {
4772917a9c9Sschwartz 		*result = ENXIO;
4782917a9c9Sschwartz 		return (PSM_FAILURE);
4792917a9c9Sschwartz 	}
4802917a9c9Sschwartz 
4812917a9c9Sschwartz 	iflag = intr_clear();
4822917a9c9Sschwartz 	lock_set(&apic_ioapic_lock);
4832917a9c9Sschwartz 
4842917a9c9Sschwartz 	ret = apic_rebind_all(irqp, cpu);
4852917a9c9Sschwartz 
4862917a9c9Sschwartz 	lock_clear(&apic_ioapic_lock);
4872917a9c9Sschwartz 	intr_restore(iflag);
4882917a9c9Sschwartz 
4892917a9c9Sschwartz 	if (ret) {
4902917a9c9Sschwartz 		*result = EIO;
4912917a9c9Sschwartz 		return (PSM_FAILURE);
4922917a9c9Sschwartz 	}
49309b1eac2SEvan Yan 	/*
49409b1eac2SEvan Yan 	 * keep tracking the default interrupt cpu binding
49509b1eac2SEvan Yan 	 */
49609b1eac2SEvan Yan 	irqp->airq_cpu = cpu;
49709b1eac2SEvan Yan 
4982917a9c9Sschwartz 	*result = 0;
4992917a9c9Sschwartz 	return (PSM_SUCCESS);
5002917a9c9Sschwartz }
5012917a9c9Sschwartz 
5022917a9c9Sschwartz static int
apic_grp_set_cpu(int irqno,int new_cpu,int * result)50309b1eac2SEvan Yan apic_grp_set_cpu(int irqno, int new_cpu, int *result)
5042917a9c9Sschwartz {
5052917a9c9Sschwartz 	dev_info_t *orig_dip;
506b6917abeSmishra 	uint32_t orig_cpu;
507a563a037Sbholler 	ulong_t iflag;
5082917a9c9Sschwartz 	apic_irq_t *irqps[PCI_MSI_MAX_INTRS];
5092917a9c9Sschwartz 	int i;
5102917a9c9Sschwartz 	int cap_ptr;
511*30acb30dSHans Rosenfeld 	int msi_mask_off = 0;
5122917a9c9Sschwartz 	ushort_t msi_ctrl;
513*30acb30dSHans Rosenfeld 	uint32_t msi_pvm = 0;
5142917a9c9Sschwartz 	ddi_acc_handle_t handle;
5152917a9c9Sschwartz 	int num_vectors = 0;
51609b1eac2SEvan Yan 	uint32_t vector;
5172917a9c9Sschwartz 
5182917a9c9Sschwartz 	DDI_INTR_IMPLDBG((CE_CONT, "APIC_GRP_SET_CPU\n"));
5192917a9c9Sschwartz 
5202917a9c9Sschwartz 	/*
5212917a9c9Sschwartz 	 * Take mutex to insure that table doesn't change out from underneath
5222917a9c9Sschwartz 	 * us while we're playing with it.
5232917a9c9Sschwartz 	 */
5242917a9c9Sschwartz 	mutex_enter(&airq_mutex);
52509b1eac2SEvan Yan 	irqps[0] = apic_irq_table[irqno];
5262917a9c9Sschwartz 	orig_cpu = irqps[0]->airq_temp_cpu;
5272917a9c9Sschwartz 	orig_dip = irqps[0]->airq_dip;
5282917a9c9Sschwartz 	num_vectors = irqps[0]->airq_intin_no;
52909b1eac2SEvan Yan 	vector = irqps[0]->airq_vector;
5302917a9c9Sschwartz 
5312917a9c9Sschwartz 	/* A "group" of 1 */
5322917a9c9Sschwartz 	if (num_vectors == 1) {
5332917a9c9Sschwartz 		mutex_exit(&airq_mutex);
53409b1eac2SEvan Yan 		return (apic_set_cpu(irqno, new_cpu, result));
5352917a9c9Sschwartz 	}
5362917a9c9Sschwartz 
5372917a9c9Sschwartz 	*result = ENXIO;
5382917a9c9Sschwartz 
5392917a9c9Sschwartz 	if (irqps[0]->airq_mps_intr_index != MSI_INDEX) {
5402917a9c9Sschwartz 		mutex_exit(&airq_mutex);
5412917a9c9Sschwartz 		DDI_INTR_IMPLDBG((CE_CONT, "set_grp: intr not MSI\n"));
5422917a9c9Sschwartz 		goto set_grp_intr_done;
5432917a9c9Sschwartz 	}
5442917a9c9Sschwartz 	if ((num_vectors < 1) || ((num_vectors - 1) & vector)) {
5452917a9c9Sschwartz 		mutex_exit(&airq_mutex);
5462917a9c9Sschwartz 		DDI_INTR_IMPLDBG((CE_CONT,
5472917a9c9Sschwartz 		    "set_grp: base vec not part of a grp or not aligned: "
5482917a9c9Sschwartz 		    "vec:0x%x, num_vec:0x%x\n", vector, num_vectors));
5492917a9c9Sschwartz 		goto set_grp_intr_done;
5502917a9c9Sschwartz 	}
5512917a9c9Sschwartz 	DDI_INTR_IMPLDBG((CE_CONT, "set_grp: num intrs in grp: %d\n",
5522917a9c9Sschwartz 	    num_vectors));
5532917a9c9Sschwartz 
5542917a9c9Sschwartz 	ASSERT((num_vectors + vector) < APIC_MAX_VECTOR);
5552917a9c9Sschwartz 
5562917a9c9Sschwartz 	*result = EIO;
5572917a9c9Sschwartz 
5582917a9c9Sschwartz 	/*
5592917a9c9Sschwartz 	 * All IRQ entries in the table for the given device will be not
5602917a9c9Sschwartz 	 * shared.  Since they are not shared, the dip in the table will
5612917a9c9Sschwartz 	 * be true to the device of interest.
5622917a9c9Sschwartz 	 */
5632917a9c9Sschwartz 	for (i = 1; i < num_vectors; i++) {
5642917a9c9Sschwartz 		irqps[i] = apic_irq_table[apic_vector_to_irq[vector + i]];
5652917a9c9Sschwartz 		if (irqps[i] == NULL) {
5662917a9c9Sschwartz 			mutex_exit(&airq_mutex);
5672917a9c9Sschwartz 			goto set_grp_intr_done;
5682917a9c9Sschwartz 		}
5692917a9c9Sschwartz #ifdef DEBUG
5702917a9c9Sschwartz 		/* Sanity check: CPU and dip is the same for all entries. */
5712917a9c9Sschwartz 		if ((irqps[i]->airq_dip != orig_dip) ||
5722917a9c9Sschwartz 		    (irqps[i]->airq_temp_cpu != orig_cpu)) {
5732917a9c9Sschwartz 			mutex_exit(&airq_mutex);
5742917a9c9Sschwartz 			DDI_INTR_IMPLDBG((CE_CONT,
5752917a9c9Sschwartz 			    "set_grp: cpu or dip for vec 0x%x difft than for "
5762917a9c9Sschwartz 			    "vec 0x%x\n", vector, vector + i));
5772917a9c9Sschwartz 			DDI_INTR_IMPLDBG((CE_CONT,
5782917a9c9Sschwartz 			    "  cpu: %d vs %d, dip: 0x%p vs 0x%p\n", orig_cpu,
5792917a9c9Sschwartz 			    irqps[i]->airq_temp_cpu, (void *)orig_dip,
5802917a9c9Sschwartz 			    (void *)irqps[i]->airq_dip));
5812917a9c9Sschwartz 			goto set_grp_intr_done;
5822917a9c9Sschwartz 		}
5832917a9c9Sschwartz #endif /* DEBUG */
5842917a9c9Sschwartz 	}
5852917a9c9Sschwartz 	mutex_exit(&airq_mutex);
5862917a9c9Sschwartz 
5872917a9c9Sschwartz 	cap_ptr = i_ddi_get_msi_msix_cap_ptr(orig_dip);
5882917a9c9Sschwartz 	handle = i_ddi_get_pci_config_handle(orig_dip);
5892917a9c9Sschwartz 	msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSI_CTRL);
5902917a9c9Sschwartz 
5912917a9c9Sschwartz 	/* MSI Per vector masking is supported. */
5922917a9c9Sschwartz 	if (msi_ctrl & PCI_MSI_PVM_MASK) {
5932917a9c9Sschwartz 		if (msi_ctrl &  PCI_MSI_64BIT_MASK)
5942917a9c9Sschwartz 			msi_mask_off = cap_ptr + PCI_MSI_64BIT_MASKBITS;
5952917a9c9Sschwartz 		else
5962917a9c9Sschwartz 			msi_mask_off = cap_ptr + PCI_MSI_32BIT_MASK;
5972917a9c9Sschwartz 		msi_pvm = pci_config_get32(handle, msi_mask_off);
5982917a9c9Sschwartz 		pci_config_put32(handle, msi_mask_off, (uint32_t)-1);
5992917a9c9Sschwartz 		DDI_INTR_IMPLDBG((CE_CONT,
6002917a9c9Sschwartz 		    "set_grp: pvm supported.  Mask set to 0x%x\n",
6012917a9c9Sschwartz 		    pci_config_get32(handle, msi_mask_off)));
6022917a9c9Sschwartz 	}
6032917a9c9Sschwartz 
6042917a9c9Sschwartz 	iflag = intr_clear();
6052917a9c9Sschwartz 	lock_set(&apic_ioapic_lock);
6062917a9c9Sschwartz 
6072917a9c9Sschwartz 	/*
6082917a9c9Sschwartz 	 * Do the first rebind and check for errors.  Apic_rebind_all returns
6092917a9c9Sschwartz 	 * an error if the CPU is not accepting interrupts.  If the first one
6102917a9c9Sschwartz 	 * succeeds they all will.
6112917a9c9Sschwartz 	 */
6122917a9c9Sschwartz 	if (apic_rebind_all(irqps[0], new_cpu))
6132917a9c9Sschwartz 		(void) apic_rebind_all(irqps[0], orig_cpu);
6142917a9c9Sschwartz 	else {
61509b1eac2SEvan Yan 		irqps[0]->airq_cpu = new_cpu;
61609b1eac2SEvan Yan 
61709b1eac2SEvan Yan 		for (i = 1; i < num_vectors; i++) {
6182917a9c9Sschwartz 			(void) apic_rebind_all(irqps[i], new_cpu);
61909b1eac2SEvan Yan 			irqps[i]->airq_cpu = new_cpu;
62009b1eac2SEvan Yan 		}
6212917a9c9Sschwartz 		*result = 0;	/* SUCCESS */
6222917a9c9Sschwartz 	}
6232917a9c9Sschwartz 
6242917a9c9Sschwartz 	lock_clear(&apic_ioapic_lock);
6252917a9c9Sschwartz 	intr_restore(iflag);
6262917a9c9Sschwartz 
6272917a9c9Sschwartz 	/* Reenable vectors if per vector masking is supported. */
6282917a9c9Sschwartz 	if (msi_ctrl & PCI_MSI_PVM_MASK) {
6292917a9c9Sschwartz 		pci_config_put32(handle, msi_mask_off, msi_pvm);
6302917a9c9Sschwartz 		DDI_INTR_IMPLDBG((CE_CONT,
6312917a9c9Sschwartz 		    "set_grp: pvm supported.  Mask restored to 0x%x\n",
6322917a9c9Sschwartz 		    pci_config_get32(handle, msi_mask_off)));
6332917a9c9Sschwartz 	}
6342917a9c9Sschwartz 
6352917a9c9Sschwartz set_grp_intr_done:
6362917a9c9Sschwartz 	if (*result != 0)
6372917a9c9Sschwartz 		return (PSM_FAILURE);
6382917a9c9Sschwartz 
6392917a9c9Sschwartz 	return (PSM_SUCCESS);
6402917a9c9Sschwartz }
6412917a9c9Sschwartz 
642843e1988Sjohnlev int
apic_get_vector_intr_info(int vecirq,apic_get_intr_t * intr_params_p)6432917a9c9Sschwartz apic_get_vector_intr_info(int vecirq, apic_get_intr_t *intr_params_p)
6442917a9c9Sschwartz {
6452917a9c9Sschwartz 	struct autovec *av_dev;
6462917a9c9Sschwartz 	uchar_t irqno;
647*30acb30dSHans Rosenfeld 	uint_t i;
6482917a9c9Sschwartz 	apic_irq_t *irq_p;
6492917a9c9Sschwartz 
6502917a9c9Sschwartz 	/* Sanity check the vector/irq argument. */
6512917a9c9Sschwartz 	ASSERT((vecirq >= 0) || (vecirq <= APIC_MAX_VECTOR));
6522917a9c9Sschwartz 
6532917a9c9Sschwartz 	mutex_enter(&airq_mutex);
6542917a9c9Sschwartz 
6552917a9c9Sschwartz 	/*
6562917a9c9Sschwartz 	 * Convert the vecirq arg to an irq using vector_to_irq table
6572917a9c9Sschwartz 	 * if the arg is a vector.  Pass thru if already an irq.
6582917a9c9Sschwartz 	 */
6592917a9c9Sschwartz 	if ((intr_params_p->avgi_req_flags & PSMGI_INTRBY_FLAGS) ==
6602917a9c9Sschwartz 	    PSMGI_INTRBY_VEC)
6612917a9c9Sschwartz 		irqno = apic_vector_to_irq[vecirq];
6622917a9c9Sschwartz 	else
663*30acb30dSHans Rosenfeld 		irqno = (uchar_t)vecirq;
6642917a9c9Sschwartz 
6652917a9c9Sschwartz 	irq_p = apic_irq_table[irqno];
6662917a9c9Sschwartz 
6672917a9c9Sschwartz 	if ((irq_p == NULL) ||
6684e30c628SEvan Yan 	    ((irq_p->airq_mps_intr_index != RESERVE_INDEX) &&
6694e30c628SEvan Yan 	    ((irq_p->airq_temp_cpu == IRQ_UNBOUND) ||
6704e30c628SEvan Yan 	    (irq_p->airq_temp_cpu == IRQ_UNINIT)))) {
6712917a9c9Sschwartz 		mutex_exit(&airq_mutex);
6722917a9c9Sschwartz 		return (PSM_FAILURE);
6732917a9c9Sschwartz 	}
6742917a9c9Sschwartz 
6752917a9c9Sschwartz 	if (intr_params_p->avgi_req_flags & PSMGI_REQ_CPUID) {
6762917a9c9Sschwartz 
6772917a9c9Sschwartz 		/* Get the (temp) cpu from apic_irq table, indexed by irq. */
6782917a9c9Sschwartz 		intr_params_p->avgi_cpu_id = irq_p->airq_temp_cpu;
6792917a9c9Sschwartz 
6802917a9c9Sschwartz 		/* Return user bound info for intrd. */
6812917a9c9Sschwartz 		if (intr_params_p->avgi_cpu_id & IRQ_USER_BOUND) {
6822917a9c9Sschwartz 			intr_params_p->avgi_cpu_id &= ~IRQ_USER_BOUND;
6832917a9c9Sschwartz 			intr_params_p->avgi_cpu_id |= PSMGI_CPU_USER_BOUND;
6842917a9c9Sschwartz 		}
6852917a9c9Sschwartz 	}
6862917a9c9Sschwartz 
6872917a9c9Sschwartz 	if (intr_params_p->avgi_req_flags & PSMGI_REQ_VECTOR)
6882917a9c9Sschwartz 		intr_params_p->avgi_vector = irq_p->airq_vector;
6892917a9c9Sschwartz 
6902917a9c9Sschwartz 	if (intr_params_p->avgi_req_flags &
6912917a9c9Sschwartz 	    (PSMGI_REQ_NUM_DEVS | PSMGI_REQ_GET_DEVS))
6922917a9c9Sschwartz 		/* Get number of devices from apic_irq table shared field. */
6932917a9c9Sschwartz 		intr_params_p->avgi_num_devs = irq_p->airq_share;
6942917a9c9Sschwartz 
6952917a9c9Sschwartz 	if (intr_params_p->avgi_req_flags &  PSMGI_REQ_GET_DEVS) {
6962917a9c9Sschwartz 
6972917a9c9Sschwartz 		intr_params_p->avgi_req_flags  |= PSMGI_REQ_NUM_DEVS;
6982917a9c9Sschwartz 
6992917a9c9Sschwartz 		/* Some devices have NULL dip.  Don't count these. */
7002917a9c9Sschwartz 		if (intr_params_p->avgi_num_devs > 0) {
7012917a9c9Sschwartz 			for (i = 0, av_dev = autovect[irqno].avh_link;
7022917a9c9Sschwartz 			    av_dev; av_dev = av_dev->av_link)
7032917a9c9Sschwartz 				if (av_dev->av_vector && av_dev->av_dip)
7042917a9c9Sschwartz 					i++;
7052917a9c9Sschwartz 			intr_params_p->avgi_num_devs =
706*30acb30dSHans Rosenfeld 			    (uchar_t)MIN(intr_params_p->avgi_num_devs, i);
7072917a9c9Sschwartz 		}
7082917a9c9Sschwartz 
7092917a9c9Sschwartz 		/* There are no viable dips to return. */
7102917a9c9Sschwartz 		if (intr_params_p->avgi_num_devs == 0)
7112917a9c9Sschwartz 			intr_params_p->avgi_dip_list = NULL;
7122917a9c9Sschwartz 
7132917a9c9Sschwartz 		else {	/* Return list of dips */
7142917a9c9Sschwartz 
7152917a9c9Sschwartz 			/* Allocate space in array for that number of devs. */
7162917a9c9Sschwartz 			intr_params_p->avgi_dip_list = kmem_zalloc(
7172917a9c9Sschwartz 			    intr_params_p->avgi_num_devs *
7182917a9c9Sschwartz 			    sizeof (dev_info_t *),
7192917a9c9Sschwartz 			    KM_SLEEP);
7202917a9c9Sschwartz 
7212917a9c9Sschwartz 			/*
7222917a9c9Sschwartz 			 * Loop through the device list of the autovec table
7232917a9c9Sschwartz 			 * filling in the dip array.
7242917a9c9Sschwartz 			 *
7252917a9c9Sschwartz 			 * Note that the autovect table may have some special
7262917a9c9Sschwartz 			 * entries which contain NULL dips.  These will be
7272917a9c9Sschwartz 			 * ignored.
7282917a9c9Sschwartz 			 */
7292917a9c9Sschwartz 			for (i = 0, av_dev = autovect[irqno].avh_link;
7302917a9c9Sschwartz 			    av_dev; av_dev = av_dev->av_link)
7312917a9c9Sschwartz 				if (av_dev->av_vector && av_dev->av_dip)
7322917a9c9Sschwartz 					intr_params_p->avgi_dip_list[i++] =
7332917a9c9Sschwartz 					    av_dev->av_dip;
7342917a9c9Sschwartz 		}
7352917a9c9Sschwartz 	}
7362917a9c9Sschwartz 
7372917a9c9Sschwartz 	mutex_exit(&airq_mutex);
7382917a9c9Sschwartz 
7392917a9c9Sschwartz 	return (PSM_SUCCESS);
7402917a9c9Sschwartz }
7412917a9c9Sschwartz 
742d12abe7cSanish /*
7437c478bd9Sstevel@tonic-gate  * This function provides external interface to the nexus for all
7447c478bd9Sstevel@tonic-gate  * functionalities related to the new DDI interrupt framework.
7457c478bd9Sstevel@tonic-gate  *
7467c478bd9Sstevel@tonic-gate  * Input:
7477c478bd9Sstevel@tonic-gate  * dip     - pointer to the dev_info structure of the requested device
7487c478bd9Sstevel@tonic-gate  * hdlp    - pointer to the internal interrupt handle structure for the
7497c478bd9Sstevel@tonic-gate  *	     requested interrupt
7507c478bd9Sstevel@tonic-gate  * intr_op - opcode for this call
7517c478bd9Sstevel@tonic-gate  * result  - pointer to the integer that will hold the result to be
7527c478bd9Sstevel@tonic-gate  *	     passed back if return value is PSM_SUCCESS
7537c478bd9Sstevel@tonic-gate  *
7547c478bd9Sstevel@tonic-gate  * Output:
7557c478bd9Sstevel@tonic-gate  * return value is either PSM_SUCCESS or PSM_FAILURE
7567c478bd9Sstevel@tonic-gate  */
7577c478bd9Sstevel@tonic-gate int
apic_intr_ops(dev_info_t * dip,ddi_intr_handle_impl_t * hdlp,psm_intr_op_t intr_op,int * result)7587c478bd9Sstevel@tonic-gate apic_intr_ops(dev_info_t *dip, ddi_intr_handle_impl_t *hdlp,
7597c478bd9Sstevel@tonic-gate     psm_intr_op_t intr_op, int *result)
7607c478bd9Sstevel@tonic-gate {
7612917a9c9Sschwartz 	int		cap;
7627c478bd9Sstevel@tonic-gate 	int		count_vec;
7637c478bd9Sstevel@tonic-gate 	int		old_priority;
7647c478bd9Sstevel@tonic-gate 	int		new_priority;
7652917a9c9Sschwartz 	int		new_cpu;
7667c478bd9Sstevel@tonic-gate 	apic_irq_t	*irqp;
7677c478bd9Sstevel@tonic-gate 	struct intrspec *ispec, intr_spec;
7687c478bd9Sstevel@tonic-gate 
7697c478bd9Sstevel@tonic-gate 	DDI_INTR_IMPLDBG((CE_CONT, "apic_intr_ops: dip: %p hdlp: %p "
7707c478bd9Sstevel@tonic-gate 	    "intr_op: %x\n", (void *)dip, (void *)hdlp, intr_op));
7717c478bd9Sstevel@tonic-gate 
7727c478bd9Sstevel@tonic-gate 	ispec = &intr_spec;
7737c478bd9Sstevel@tonic-gate 	ispec->intrspec_pri = hdlp->ih_pri;
7747c478bd9Sstevel@tonic-gate 	ispec->intrspec_vec = hdlp->ih_inum;
7757c478bd9Sstevel@tonic-gate 	ispec->intrspec_func = hdlp->ih_cb_func;
7767c478bd9Sstevel@tonic-gate 
7777c478bd9Sstevel@tonic-gate 	switch (intr_op) {
7787c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_CHECK_MSI:
7797c478bd9Sstevel@tonic-gate 		/*
7807c478bd9Sstevel@tonic-gate 		 * Check MSI/X is supported or not at APIC level and
7817c478bd9Sstevel@tonic-gate 		 * masked off the MSI/X bits in hdlp->ih_type if not
7827c478bd9Sstevel@tonic-gate 		 * supported before return.  If MSI/X is supported,
7837c478bd9Sstevel@tonic-gate 		 * leave the ih_type unchanged and return.
7847c478bd9Sstevel@tonic-gate 		 *
7857c478bd9Sstevel@tonic-gate 		 * hdlp->ih_type passed in from the nexus has all the
7867c478bd9Sstevel@tonic-gate 		 * interrupt types supported by the device.
7877c478bd9Sstevel@tonic-gate 		 */
7887c478bd9Sstevel@tonic-gate 		if (apic_support_msi == 0) {
7897c478bd9Sstevel@tonic-gate 			/*
7907c478bd9Sstevel@tonic-gate 			 * if apic_support_msi is not set, call
7917c478bd9Sstevel@tonic-gate 			 * apic_check_msi_support() to check whether msi
7927c478bd9Sstevel@tonic-gate 			 * is supported first
7937c478bd9Sstevel@tonic-gate 			 */
794685482d6Sjohnny 			if (apic_check_msi_support() == PSM_SUCCESS)
7957c478bd9Sstevel@tonic-gate 				apic_support_msi = 1;
7967c478bd9Sstevel@tonic-gate 			else
7977c478bd9Sstevel@tonic-gate 				apic_support_msi = -1;
7987c478bd9Sstevel@tonic-gate 		}
799a7639048Sjohnny 		if (apic_support_msi == 1) {
800a7639048Sjohnny 			if (apic_msix_enable)
8017c478bd9Sstevel@tonic-gate 				*result = hdlp->ih_type;
8027c478bd9Sstevel@tonic-gate 			else
803a7639048Sjohnny 				*result = hdlp->ih_type & ~DDI_INTR_TYPE_MSIX;
804a7639048Sjohnny 		} else
8057c478bd9Sstevel@tonic-gate 			*result = hdlp->ih_type & ~(DDI_INTR_TYPE_MSI |
8067c478bd9Sstevel@tonic-gate 			    DDI_INTR_TYPE_MSIX);
8077c478bd9Sstevel@tonic-gate 		break;
8087c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_ALLOC_VECTORS:
809a7639048Sjohnny 		if (hdlp->ih_type == DDI_INTR_TYPE_MSI)
810a7639048Sjohnny 			*result = apic_alloc_msi_vectors(dip, hdlp->ih_inum,
811a7639048Sjohnny 			    hdlp->ih_scratch1, hdlp->ih_pri,
812a7639048Sjohnny 			    (int)(uintptr_t)hdlp->ih_scratch2);
813a7639048Sjohnny 		else
814a7639048Sjohnny 			*result = apic_alloc_msix_vectors(dip, hdlp->ih_inum,
815a7639048Sjohnny 			    hdlp->ih_scratch1, hdlp->ih_pri,
8160ccf9e79Sjohnny 			    (int)(uintptr_t)hdlp->ih_scratch2);
8177c478bd9Sstevel@tonic-gate 		break;
8187c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_FREE_VECTORS:
8197c478bd9Sstevel@tonic-gate 		apic_free_vectors(dip, hdlp->ih_inum, hdlp->ih_scratch1,
8207c478bd9Sstevel@tonic-gate 		    hdlp->ih_pri, hdlp->ih_type);
8217c478bd9Sstevel@tonic-gate 		break;
8227c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_NAVAIL_VECTORS:
8237c478bd9Sstevel@tonic-gate 		*result = apic_navail_vector(dip, hdlp->ih_pri);
8247c478bd9Sstevel@tonic-gate 		break;
8257c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_XLATE_VECTOR:
8267a364d25Sschwartz 		ispec = ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp;
8277c478bd9Sstevel@tonic-gate 		*result = apic_introp_xlate(dip, ispec, hdlp->ih_type);
82886a9c507SGuoli Shu 		if (*result == -1)
82986a9c507SGuoli Shu 			return (PSM_FAILURE);
8307c478bd9Sstevel@tonic-gate 		break;
8317c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_GET_PENDING:
8327c478bd9Sstevel@tonic-gate 		if ((irqp = apic_find_irq(dip, ispec, hdlp->ih_type)) == NULL)
8337c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
8347c478bd9Sstevel@tonic-gate 		*result = apic_get_pending(irqp, hdlp->ih_type);
8357c478bd9Sstevel@tonic-gate 		break;
8367c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_CLEAR_MASK:
8377c478bd9Sstevel@tonic-gate 		if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
8387c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
8397c478bd9Sstevel@tonic-gate 		irqp = apic_find_irq(dip, ispec, hdlp->ih_type);
8407c478bd9Sstevel@tonic-gate 		if (irqp == NULL)
8417c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
8427c478bd9Sstevel@tonic-gate 		apic_clear_mask(irqp);
8437c478bd9Sstevel@tonic-gate 		break;
8447c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_SET_MASK:
8457c478bd9Sstevel@tonic-gate 		if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
8467c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
8477c478bd9Sstevel@tonic-gate 		if ((irqp = apic_find_irq(dip, ispec, hdlp->ih_type)) == NULL)
8487c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
8497c478bd9Sstevel@tonic-gate 		apic_set_mask(irqp);
8507c478bd9Sstevel@tonic-gate 		break;
8517c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_GET_CAP:
8527c478bd9Sstevel@tonic-gate 		cap = DDI_INTR_FLAG_PENDING;
8537c478bd9Sstevel@tonic-gate 		if (hdlp->ih_type == DDI_INTR_TYPE_FIXED)
8547c478bd9Sstevel@tonic-gate 			cap |= DDI_INTR_FLAG_MASKABLE;
8557c478bd9Sstevel@tonic-gate 		*result = cap;
8567c478bd9Sstevel@tonic-gate 		break;
8577c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_GET_SHARED:
8587c478bd9Sstevel@tonic-gate 		if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
8597c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
86096f82fefSSophia Li 		ispec = ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp;
8617c478bd9Sstevel@tonic-gate 		if ((irqp = apic_find_irq(dip, ispec, hdlp->ih_type)) == NULL)
8627c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
86396f82fefSSophia Li 		*result = (irqp->airq_share > 1) ? 1: 0;
8647c478bd9Sstevel@tonic-gate 		break;
8657c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_SET_PRI:
8667c478bd9Sstevel@tonic-gate 		old_priority = hdlp->ih_pri;	/* save old value */
8677c478bd9Sstevel@tonic-gate 		new_priority = *(int *)result;	/* try the new value */
8687c478bd9Sstevel@tonic-gate 
86996f82fefSSophia Li 		if (hdlp->ih_type == DDI_INTR_TYPE_FIXED) {
87096f82fefSSophia Li 			return (PSM_SUCCESS);
87196f82fefSSophia Li 		}
8727c478bd9Sstevel@tonic-gate 
8737c478bd9Sstevel@tonic-gate 		/* Now allocate the vectors */
87496f82fefSSophia Li 		if (hdlp->ih_type == DDI_INTR_TYPE_MSI) {
87596f82fefSSophia Li 			/* SET_PRI does not support the case of multiple MSI */
87696f82fefSSophia Li 			if (i_ddi_intr_get_current_nintrs(hdlp->ih_dip) > 1)
87796f82fefSSophia Li 				return (PSM_FAILURE);
87896f82fefSSophia Li 
879a7639048Sjohnny 			count_vec = apic_alloc_msi_vectors(dip, hdlp->ih_inum,
88096f82fefSSophia Li 			    1, new_priority,
881a7639048Sjohnny 			    DDI_INTR_ALLOC_STRICT);
88296f82fefSSophia Li 		} else {
883a7639048Sjohnny 			count_vec = apic_alloc_msix_vectors(dip, hdlp->ih_inum,
88496f82fefSSophia Li 			    1, new_priority,
8850ccf9e79Sjohnny 			    DDI_INTR_ALLOC_STRICT);
88696f82fefSSophia Li 		}
8877c478bd9Sstevel@tonic-gate 
888ae115bc7Smrj 		/* Did we get new vectors? */
8890ccf9e79Sjohnny 		if (!count_vec)
8907c478bd9Sstevel@tonic-gate 			return (PSM_FAILURE);
8917c478bd9Sstevel@tonic-gate 
8927c478bd9Sstevel@tonic-gate 		/* Finally, free the previously allocated vectors */
8937c478bd9Sstevel@tonic-gate 		apic_free_vectors(dip, hdlp->ih_inum, count_vec,
8947c478bd9Sstevel@tonic-gate 		    old_priority, hdlp->ih_type);
8957c478bd9Sstevel@tonic-gate 		break;
8967a364d25Sschwartz 	case PSM_INTR_OP_SET_CPU:
8972917a9c9Sschwartz 	case PSM_INTR_OP_GRP_SET_CPU:
8987a364d25Sschwartz 		/*
8997a364d25Sschwartz 		 * The interrupt handle given here has been allocated
9007a364d25Sschwartz 		 * specifically for this command, and ih_private carries
9017a364d25Sschwartz 		 * a CPU value.
9027a364d25Sschwartz 		 */
9032917a9c9Sschwartz 		new_cpu = (int)(intptr_t)hdlp->ih_private;
9042917a9c9Sschwartz 		if (!apic_cpu_in_range(new_cpu)) {
9052917a9c9Sschwartz 			DDI_INTR_IMPLDBG((CE_CONT,
9062917a9c9Sschwartz 			    "[grp_]set_cpu: cpu out of range: %d\n", new_cpu));
9077a364d25Sschwartz 			*result = EINVAL;
9087a364d25Sschwartz 			return (PSM_FAILURE);
9097a364d25Sschwartz 		}
91009b1eac2SEvan Yan 		if (hdlp->ih_vector > APIC_MAX_VECTOR) {
91109b1eac2SEvan Yan 			DDI_INTR_IMPLDBG((CE_CONT,
91209b1eac2SEvan Yan 			    "[grp_]set_cpu: vector out of range: %d\n",
91309b1eac2SEvan Yan 			    hdlp->ih_vector));
91409b1eac2SEvan Yan 			*result = EINVAL;
91509b1eac2SEvan Yan 			return (PSM_FAILURE);
91609b1eac2SEvan Yan 		}
9177ff178cdSJimmy Vetayases 		if ((hdlp->ih_flags & PSMGI_INTRBY_FLAGS) == PSMGI_INTRBY_VEC)
91809b1eac2SEvan Yan 			hdlp->ih_vector = apic_vector_to_irq[hdlp->ih_vector];
9192917a9c9Sschwartz 		if (intr_op == PSM_INTR_OP_SET_CPU) {
9202917a9c9Sschwartz 			if (apic_set_cpu(hdlp->ih_vector, new_cpu, result) !=
9212917a9c9Sschwartz 			    PSM_SUCCESS)
9222917a9c9Sschwartz 				return (PSM_FAILURE);
9232917a9c9Sschwartz 		} else {
9242917a9c9Sschwartz 			if (apic_grp_set_cpu(hdlp->ih_vector, new_cpu,
9252917a9c9Sschwartz 			    result) != PSM_SUCCESS)
9267a364d25Sschwartz 				return (PSM_FAILURE);
9277a364d25Sschwartz 		}
9287a364d25Sschwartz 		break;
9297a364d25Sschwartz 	case PSM_INTR_OP_GET_INTR:
9307a364d25Sschwartz 		/*
9317a364d25Sschwartz 		 * The interrupt handle given here has been allocated
9327a364d25Sschwartz 		 * specifically for this command, and ih_private carries
9337a364d25Sschwartz 		 * a pointer to a apic_get_intr_t.
9347a364d25Sschwartz 		 */
9357a364d25Sschwartz 		if (apic_get_vector_intr_info(
9367a364d25Sschwartz 		    hdlp->ih_vector, hdlp->ih_private) != PSM_SUCCESS)
9377a364d25Sschwartz 			return (PSM_FAILURE);
9387a364d25Sschwartz 		break;
9392917a9c9Sschwartz 	case PSM_INTR_OP_APIC_TYPE:
9407ff178cdSJimmy Vetayases 		((apic_get_type_t *)(hdlp->ih_private))->avgi_type =
9417ff178cdSJimmy Vetayases 		    apic_get_apic_type();
9427ff178cdSJimmy Vetayases 		((apic_get_type_t *)(hdlp->ih_private))->avgi_num_intr =
9437ff178cdSJimmy Vetayases 		    APIC_MAX_VECTOR;
9447ff178cdSJimmy Vetayases 		((apic_get_type_t *)(hdlp->ih_private))->avgi_num_cpu =
9457ff178cdSJimmy Vetayases 		    boot_ncpus;
9462917a9c9Sschwartz 		hdlp->ih_ver = apic_get_apic_version();
9472917a9c9Sschwartz 		break;
9487c478bd9Sstevel@tonic-gate 	case PSM_INTR_OP_SET_CAP:
9497c478bd9Sstevel@tonic-gate 	default:
9507c478bd9Sstevel@tonic-gate 		return (PSM_FAILURE);
9517c478bd9Sstevel@tonic-gate 	}
9527c478bd9Sstevel@tonic-gate 	return (PSM_SUCCESS);
9537c478bd9Sstevel@tonic-gate }
954