xref: /onnv-gate/usr/src/uts/sun4/io/px/px_lib.h (revision 2588:6ca5ef0f409c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51540Skini  * Common Development and Distribution License (the "License").
61540Skini  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
221531Skini  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef	_SYS_PX_LIB_H
270Sstevel@tonic-gate #define	_SYS_PX_LIB_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef	__cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * Include all data structures and definitions in this file that are
370Sstevel@tonic-gate  * required between the common and hardware specific code.
380Sstevel@tonic-gate  */
390Sstevel@tonic-gate 
400Sstevel@tonic-gate #define	DIP_TO_HANDLE(dip)	((px_t *)DIP_TO_STATE(dip))->px_dev_hdl
410Sstevel@tonic-gate 
420Sstevel@tonic-gate /*
430Sstevel@tonic-gate  * The following macros define	the mmu page size and related operations.
440Sstevel@tonic-gate  */
450Sstevel@tonic-gate #define	MMU_PAGE_SHIFT		13
460Sstevel@tonic-gate #define	MMU_PAGE_SIZE		(1 << MMU_PAGE_SHIFT)
470Sstevel@tonic-gate #define	MMU_PAGE_MASK		~(MMU_PAGE_SIZE - 1)
480Sstevel@tonic-gate #define	MMU_PAGE_OFFSET		(MMU_PAGE_SIZE - 1)
490Sstevel@tonic-gate #define	MMU_PTOB(x)		(((uint64_t)(x)) << MMU_PAGE_SHIFT)
500Sstevel@tonic-gate #define	MMU_BTOP(x)		((x) >> MMU_PAGE_SHIFT)
510Sstevel@tonic-gate #define	MMU_BTOPR(x)		MMU_BTOP((x) + MMU_PAGE_OFFSET)
520Sstevel@tonic-gate 
530Sstevel@tonic-gate /* MMU map flags */
541617Sgovinda #define	MMU_MAP_PFN		1
551617Sgovinda #define	MMU_MAP_BUF		2
560Sstevel@tonic-gate 
570Sstevel@tonic-gate typedef struct px px_t;
580Sstevel@tonic-gate typedef struct px_msiq px_msiq_t;
590Sstevel@tonic-gate 
600Sstevel@tonic-gate extern int px_lib_dev_init(dev_info_t *dip, devhandle_t *dev_hdl);
610Sstevel@tonic-gate extern int px_lib_dev_fini(dev_info_t *dip);
620Sstevel@tonic-gate extern int px_lib_map_vconfig(dev_info_t *dip, ddi_map_req_t *mp,
630Sstevel@tonic-gate     pci_config_offset_t off, pci_regspec_t *rp, caddr_t *addrp);
64677Sjchu extern void px_lib_map_attr_check(ddi_map_req_t *mp);
651617Sgovinda 
660Sstevel@tonic-gate extern int px_lib_intr_devino_to_sysino(dev_info_t *dip, devino_t devino,
670Sstevel@tonic-gate     sysino_t *sysino);
680Sstevel@tonic-gate extern int px_lib_intr_getvalid(dev_info_t *dip, sysino_t sysino,
690Sstevel@tonic-gate     intr_valid_state_t *intr_valid_state);
700Sstevel@tonic-gate extern int px_lib_intr_setvalid(dev_info_t *dip, sysino_t sysino,
710Sstevel@tonic-gate     intr_valid_state_t intr_valid_state);
720Sstevel@tonic-gate extern int px_lib_intr_getstate(dev_info_t *dip, sysino_t sysino,
730Sstevel@tonic-gate     intr_state_t *intr_state);
740Sstevel@tonic-gate extern int px_lib_intr_setstate(dev_info_t *dip, sysino_t sysino,
750Sstevel@tonic-gate     intr_state_t intr_state);
760Sstevel@tonic-gate extern int px_lib_intr_gettarget(dev_info_t *dip, sysino_t sysino,
770Sstevel@tonic-gate     cpuid_t *cpuid);
780Sstevel@tonic-gate extern int px_lib_intr_settarget(dev_info_t *dip, sysino_t sysino,
790Sstevel@tonic-gate     cpuid_t cpuid);
800Sstevel@tonic-gate extern int px_lib_intr_reset(dev_info_t *dip);
810Sstevel@tonic-gate 
8227Sjchu #ifdef FMA
8327Sjchu extern void px_fill_rc_status(px_fault_t *px_fault_p,
8427Sjchu     pciex_rc_error_regs_t *rc_status);
8527Sjchu #endif
8627Sjchu 
870Sstevel@tonic-gate extern int px_lib_iommu_map(dev_info_t *dip, tsbid_t tsbid, pages_t pages,
881617Sgovinda     io_attributes_t attr, void *addr, size_t pfn_index, int flags);
890Sstevel@tonic-gate extern int px_lib_iommu_demap(dev_info_t *dip, tsbid_t tsbid, pages_t pages);
900Sstevel@tonic-gate extern int px_lib_iommu_getmap(dev_info_t *dip, tsbid_t tsbid,
911617Sgovinda     io_attributes_t *attr_p, r_addr_t *r_addr_p);
921772Sjl139090 extern int px_lib_dma_bypass_rngchk(dev_info_t *dip, ddi_dma_attr_t *attr_p,
931772Sjl139090     uint64_t *lo_p, uint64_t *hi_p);
940Sstevel@tonic-gate extern int px_lib_iommu_getbypass(dev_info_t *dip, r_addr_t ra,
951617Sgovinda     io_attributes_t attr, io_addr_t *io_addr_p);
960Sstevel@tonic-gate extern int px_lib_dma_sync(dev_info_t *dip, dev_info_t *rdip,
970Sstevel@tonic-gate     ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*
1000Sstevel@tonic-gate  * MSIQ Functions:
1010Sstevel@tonic-gate  */
1020Sstevel@tonic-gate extern int px_lib_msiq_init(dev_info_t *dip);
1030Sstevel@tonic-gate extern int px_lib_msiq_fini(dev_info_t *dip);
1040Sstevel@tonic-gate extern int px_lib_msiq_info(dev_info_t *dip, msiqid_t msiq_id,
1050Sstevel@tonic-gate     r_addr_t *ra_p, uint_t *msiq_rec_cnt_p);
1060Sstevel@tonic-gate extern int px_lib_msiq_getvalid(dev_info_t *dip, msiqid_t msiq_id,
1070Sstevel@tonic-gate     pci_msiq_valid_state_t *msiq_valid_state);
1080Sstevel@tonic-gate extern int px_lib_msiq_setvalid(dev_info_t *dip, msiqid_t msiq_id,
1090Sstevel@tonic-gate     pci_msiq_valid_state_t msiq_valid_state);
1100Sstevel@tonic-gate extern int px_lib_msiq_getstate(dev_info_t *dip, msiqid_t msiq_id,
1110Sstevel@tonic-gate     pci_msiq_state_t *msiq_state);
1120Sstevel@tonic-gate extern int px_lib_msiq_setstate(dev_info_t *dip, msiqid_t msiq_id,
1130Sstevel@tonic-gate     pci_msiq_state_t msiq_state);
1140Sstevel@tonic-gate extern int px_lib_msiq_gethead(dev_info_t *dip, msiqid_t msiq_id,
1150Sstevel@tonic-gate     msiqhead_t *msiq_head);
1160Sstevel@tonic-gate extern int px_lib_msiq_sethead(dev_info_t *dip, msiqid_t msiq_id,
1170Sstevel@tonic-gate     msiqhead_t msiq_head);
1180Sstevel@tonic-gate extern int px_lib_msiq_gettail(dev_info_t *dip, msiqid_t msiq_id,
1190Sstevel@tonic-gate     msiqtail_t *msiq_tail);
120*2588Segillett extern void px_lib_get_msiq_rec(dev_info_t *dip, msiqhead_t *msiq_head_p,
1210Sstevel@tonic-gate     msiq_rec_t *msiq_rec_p);
1220Sstevel@tonic-gate /*
1230Sstevel@tonic-gate  * MSI Functions:
1240Sstevel@tonic-gate  */
1250Sstevel@tonic-gate extern int px_lib_msi_init(dev_info_t *dip);
1260Sstevel@tonic-gate extern int px_lib_msi_getmsiq(dev_info_t *dip, msinum_t msi_num,
1270Sstevel@tonic-gate     msiqid_t *msiq_id);
1280Sstevel@tonic-gate extern int px_lib_msi_setmsiq(dev_info_t *dip, msinum_t msi_num,
1290Sstevel@tonic-gate     msiqid_t msiq_id, msi_type_t msitype);
1300Sstevel@tonic-gate extern int px_lib_msi_getvalid(dev_info_t *dip, msinum_t msi_num,
1310Sstevel@tonic-gate     pci_msi_valid_state_t *msi_valid_state);
1320Sstevel@tonic-gate extern int px_lib_msi_setvalid(dev_info_t *dip, msinum_t msi_num,
1330Sstevel@tonic-gate     pci_msi_valid_state_t msi_valid_state);
1340Sstevel@tonic-gate extern int px_lib_msi_getstate(dev_info_t *dip, msinum_t msi_num,
1350Sstevel@tonic-gate     pci_msi_state_t *msi_state);
1360Sstevel@tonic-gate extern int px_lib_msi_setstate(dev_info_t *dip, msinum_t msi_num,
1370Sstevel@tonic-gate     pci_msi_state_t msi_state);
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate /*
1400Sstevel@tonic-gate  * MSG Functions:
1410Sstevel@tonic-gate  */
1420Sstevel@tonic-gate extern int px_lib_msg_getmsiq(dev_info_t *dip, pcie_msg_type_t msg_type,
1430Sstevel@tonic-gate     msiqid_t *msiq_id);
1440Sstevel@tonic-gate extern int px_lib_msg_setmsiq(dev_info_t *dip, pcie_msg_type_t msg_type,
1450Sstevel@tonic-gate     msiqid_t msiq_id);
1460Sstevel@tonic-gate extern int px_lib_msg_getvalid(dev_info_t *dip, pcie_msg_type_t msg_type,
1470Sstevel@tonic-gate     pcie_msg_valid_state_t *msg_valid_state);
1480Sstevel@tonic-gate extern int px_lib_msg_setvalid(dev_info_t *dip, pcie_msg_type_t msg_type,
1490Sstevel@tonic-gate     pcie_msg_valid_state_t msg_valid_state);
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate /*
1521648Sjchu  * PM/CPR Functions:
1530Sstevel@tonic-gate  */
1540Sstevel@tonic-gate extern int px_lib_suspend(dev_info_t *dip);
1550Sstevel@tonic-gate extern void px_lib_resume(dev_info_t *dip);
1561648Sjchu extern void px_cpr_add_callb(px_t *);
1571648Sjchu extern void px_cpr_rem_callb(px_t *);
1581648Sjchu extern int px_lib_pmctl(int cmd, px_t *px_p);
1591648Sjchu extern uint_t px_pmeq_intr(caddr_t arg);
1600Sstevel@tonic-gate 
1610Sstevel@tonic-gate /*
1622053Sschwartz  * Common range property functions and definitions.
1630Sstevel@tonic-gate  */
1642053Sschwartz #define	PX_RANGE_PROP_MASK	0x7ff
1652053Sschwartz extern uint64_t px_get_rng_parent_hi_mask(px_t *px_p);
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate /*
1680Sstevel@tonic-gate  * Peek and poke access ddi_ctlops helper functions
1690Sstevel@tonic-gate  */
1700Sstevel@tonic-gate extern int px_lib_ctlops_poke(dev_info_t *dip, dev_info_t *rdip,
1710Sstevel@tonic-gate     peekpoke_ctlops_t *in_args);
1720Sstevel@tonic-gate extern int px_lib_ctlops_peek(dev_info_t *dip, dev_info_t *rdip,
1730Sstevel@tonic-gate     peekpoke_ctlops_t *in_args, void *result);
1740Sstevel@tonic-gate 
17527Sjchu /*
17627Sjchu  * Error handling functions
17727Sjchu  */
17827Sjchu #define	PX_INTR_PAYLOAD_SIZE	8	/* 64 bit words */
17927Sjchu typedef struct px_fault {
18027Sjchu 	dev_info_t	*px_fh_dip;
18127Sjchu 	sysino_t	px_fh_sysino;
18227Sjchu 	uint_t		(*px_err_func)(caddr_t px_fault);
18327Sjchu 	devino_t	px_intr_ino;
18427Sjchu 	uint64_t	px_intr_payload[PX_INTR_PAYLOAD_SIZE];
18527Sjchu } px_fault_t;
18627Sjchu 
18727Sjchu extern int px_err_add_intr(px_fault_t *px_fault_p);
18827Sjchu extern void px_err_rem_intr(px_fault_t *px_fault_p);
1891648Sjchu extern int px_cb_add_intr(px_fault_t *);
1901648Sjchu extern void px_cb_rem_intr(px_fault_t *);
1911648Sjchu extern void px_cb_intr_redist(px_t *);
192383Set142600 extern uint32_t px_fab_get(px_t *px_p, pcie_req_id_t bdf,
193383Set142600     uint16_t offset);
194383Set142600 extern void px_fab_set(px_t *px_p, pcie_req_id_t bdf, uint16_t offset,
195383Set142600     uint32_t val);
19627Sjchu 
197435Sjchu /*
198435Sjchu  * CPR callback
199435Sjchu  */
200435Sjchu extern void px_cpr_add_callb(px_t *);
201435Sjchu extern void px_cpr_rem_callb(px_t *);
202435Sjchu 
2031531Skini /*
2041531Skini  * Hotplug functions
2051531Skini  */
2061531Skini extern int px_lib_hotplug_init(dev_info_t *dip, void *regops);
2071531Skini extern void px_lib_hotplug_uninit(dev_info_t *dip);
2081531Skini 
2092476Sdwoods extern boolean_t px_lib_is_in_drain_state(px_t *px_p);
2102476Sdwoods 
2110Sstevel@tonic-gate #ifdef	__cplusplus
2120Sstevel@tonic-gate }
2130Sstevel@tonic-gate #endif
2140Sstevel@tonic-gate 
2150Sstevel@tonic-gate #endif	/* _SYS_PX_LIB_H */
216