xref: /onnv-gate/usr/src/uts/sun4/io/px/px_lib.h (revision 27:c1f182000c0a)
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
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
220Sstevel@tonic-gate /*
230Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_SYS_PX_LIB_H
280Sstevel@tonic-gate #define	_SYS_PX_LIB_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate /*
370Sstevel@tonic-gate  * Include all data structures and definitions in this file that are
380Sstevel@tonic-gate  * required between the common and hardware specific code.
390Sstevel@tonic-gate  */
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #define	DIP_TO_HANDLE(dip)	((px_t *)DIP_TO_STATE(dip))->px_dev_hdl
420Sstevel@tonic-gate 
430Sstevel@tonic-gate /*
440Sstevel@tonic-gate  * The following macros define	the mmu page size and related operations.
450Sstevel@tonic-gate  */
460Sstevel@tonic-gate #define	MMU_PAGE_SHIFT		13
470Sstevel@tonic-gate #define	MMU_PAGE_SIZE		(1 << MMU_PAGE_SHIFT)
480Sstevel@tonic-gate #define	MMU_PAGE_MASK		~(MMU_PAGE_SIZE - 1)
490Sstevel@tonic-gate #define	MMU_PAGE_OFFSET		(MMU_PAGE_SIZE - 1)
500Sstevel@tonic-gate #define	MMU_PTOB(x)		(((uint64_t)(x)) << MMU_PAGE_SHIFT)
510Sstevel@tonic-gate #define	MMU_BTOP(x)		((x) >> MMU_PAGE_SHIFT)
520Sstevel@tonic-gate #define	MMU_BTOPR(x)		MMU_BTOP((x) + MMU_PAGE_OFFSET)
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /* MMU map flags */
550Sstevel@tonic-gate #define	MMU_MAP_MP		0
560Sstevel@tonic-gate #define	MMU_MAP_BUF		1
570Sstevel@tonic-gate 
580Sstevel@tonic-gate typedef struct px px_t;
590Sstevel@tonic-gate typedef struct px_msiq px_msiq_t;
600Sstevel@tonic-gate 
610Sstevel@tonic-gate extern int px_lib_dev_init(dev_info_t *dip, devhandle_t *dev_hdl);
620Sstevel@tonic-gate extern int px_lib_dev_fini(dev_info_t *dip);
630Sstevel@tonic-gate extern int px_lib_map_vconfig(dev_info_t *dip, ddi_map_req_t *mp,
640Sstevel@tonic-gate     pci_config_offset_t off, pci_regspec_t *rp, caddr_t *addrp);
650Sstevel@tonic-gate extern int px_lib_intr_devino_to_sysino(dev_info_t *dip, devino_t devino,
660Sstevel@tonic-gate     sysino_t *sysino);
670Sstevel@tonic-gate extern int px_lib_intr_getvalid(dev_info_t *dip, sysino_t sysino,
680Sstevel@tonic-gate     intr_valid_state_t *intr_valid_state);
690Sstevel@tonic-gate extern int px_lib_intr_setvalid(dev_info_t *dip, sysino_t sysino,
700Sstevel@tonic-gate     intr_valid_state_t intr_valid_state);
710Sstevel@tonic-gate extern int px_lib_intr_getstate(dev_info_t *dip, sysino_t sysino,
720Sstevel@tonic-gate     intr_state_t *intr_state);
730Sstevel@tonic-gate extern int px_lib_intr_setstate(dev_info_t *dip, sysino_t sysino,
740Sstevel@tonic-gate     intr_state_t intr_state);
750Sstevel@tonic-gate extern int px_lib_intr_gettarget(dev_info_t *dip, sysino_t sysino,
760Sstevel@tonic-gate     cpuid_t *cpuid);
770Sstevel@tonic-gate extern int px_lib_intr_settarget(dev_info_t *dip, sysino_t sysino,
780Sstevel@tonic-gate     cpuid_t cpuid);
790Sstevel@tonic-gate extern int px_lib_intr_reset(dev_info_t *dip);
800Sstevel@tonic-gate 
81*27Sjchu #ifdef FMA
82*27Sjchu extern void px_fill_rc_status(px_fault_t *px_fault_p,
83*27Sjchu     pciex_rc_error_regs_t *rc_status);
84*27Sjchu #endif
85*27Sjchu 
860Sstevel@tonic-gate extern int px_lib_iommu_map(dev_info_t *dip, tsbid_t tsbid, pages_t pages,
870Sstevel@tonic-gate     io_attributes_t io_attributes, void *addr, size_t pfn_index, int flag);
880Sstevel@tonic-gate extern int px_lib_iommu_demap(dev_info_t *dip, tsbid_t tsbid, pages_t pages);
890Sstevel@tonic-gate extern int px_lib_iommu_getmap(dev_info_t *dip, tsbid_t tsbid,
900Sstevel@tonic-gate     io_attributes_t *attributes_p, r_addr_t *r_addr_p);
910Sstevel@tonic-gate extern int px_lib_dma_bypass_rngchk(ddi_dma_attr_t *attrp, uint64_t *lo_p,
920Sstevel@tonic-gate     uint64_t *hi_p);
930Sstevel@tonic-gate extern int px_lib_iommu_getbypass(dev_info_t *dip, r_addr_t ra,
940Sstevel@tonic-gate     io_attributes_t io_attributes, io_addr_t *io_addr_p);
950Sstevel@tonic-gate extern int px_lib_dma_sync(dev_info_t *dip, dev_info_t *rdip,
960Sstevel@tonic-gate     ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
970Sstevel@tonic-gate 
980Sstevel@tonic-gate /*
990Sstevel@tonic-gate  * MSIQ Functions:
1000Sstevel@tonic-gate  */
1010Sstevel@tonic-gate extern int px_lib_msiq_init(dev_info_t *dip);
1020Sstevel@tonic-gate extern int px_lib_msiq_fini(dev_info_t *dip);
1030Sstevel@tonic-gate extern int px_lib_msiq_info(dev_info_t *dip, msiqid_t msiq_id,
1040Sstevel@tonic-gate     r_addr_t *ra_p, uint_t *msiq_rec_cnt_p);
1050Sstevel@tonic-gate extern int px_lib_msiq_getvalid(dev_info_t *dip, msiqid_t msiq_id,
1060Sstevel@tonic-gate     pci_msiq_valid_state_t *msiq_valid_state);
1070Sstevel@tonic-gate extern int px_lib_msiq_setvalid(dev_info_t *dip, msiqid_t msiq_id,
1080Sstevel@tonic-gate     pci_msiq_valid_state_t msiq_valid_state);
1090Sstevel@tonic-gate extern int px_lib_msiq_getstate(dev_info_t *dip, msiqid_t msiq_id,
1100Sstevel@tonic-gate     pci_msiq_state_t *msiq_state);
1110Sstevel@tonic-gate extern int px_lib_msiq_setstate(dev_info_t *dip, msiqid_t msiq_id,
1120Sstevel@tonic-gate     pci_msiq_state_t msiq_state);
1130Sstevel@tonic-gate extern int px_lib_msiq_gethead(dev_info_t *dip, msiqid_t msiq_id,
1140Sstevel@tonic-gate     msiqhead_t *msiq_head);
1150Sstevel@tonic-gate extern int px_lib_msiq_sethead(dev_info_t *dip, msiqid_t msiq_id,
1160Sstevel@tonic-gate     msiqhead_t msiq_head);
1170Sstevel@tonic-gate extern int px_lib_msiq_gettail(dev_info_t *dip, msiqid_t msiq_id,
1180Sstevel@tonic-gate     msiqtail_t *msiq_tail);
1190Sstevel@tonic-gate extern void px_lib_get_msiq_rec(dev_info_t *dip, px_msiq_t *msiq_p,
1200Sstevel@tonic-gate     msiq_rec_t *msiq_rec_p);
1210Sstevel@tonic-gate 
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 /*
1520Sstevel@tonic-gate  * CPR Suspend/Resume 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);
1560Sstevel@tonic-gate 
1570Sstevel@tonic-gate /*
1580Sstevel@tonic-gate  * PCI tool Functions:
1590Sstevel@tonic-gate  */
1600Sstevel@tonic-gate extern int px_lib_tools_dev_reg_ops(dev_info_t *dip, void *arg,
1610Sstevel@tonic-gate     int cmd, int mode);
1620Sstevel@tonic-gate extern int px_lib_tools_bus_reg_ops(dev_info_t *dip, void *arg, int cmd,
1630Sstevel@tonic-gate     int mode);
1640Sstevel@tonic-gate extern int px_lib_tools_intr_admn(dev_info_t *dip, void *arg, int cmd,
1650Sstevel@tonic-gate     int mode);
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate /*
1680Sstevel@tonic-gate  * PPM interface
1690Sstevel@tonic-gate  */
1700Sstevel@tonic-gate extern int px_lib_pmctl(int cmd, px_t *px_p);
1710Sstevel@tonic-gate 
1720Sstevel@tonic-gate /*
1730Sstevel@tonic-gate  * Misc Functions:
1740Sstevel@tonic-gate  */
175*27Sjchu extern uint64_t px_lib_get_cb(dev_info_t *dip);
176*27Sjchu extern void px_lib_set_cb(dev_info_t *dip, uint64_t val);
1770Sstevel@tonic-gate 
1780Sstevel@tonic-gate /*
1790Sstevel@tonic-gate  * Peek and poke access ddi_ctlops helper functions
1800Sstevel@tonic-gate  */
1810Sstevel@tonic-gate extern int px_lib_ctlops_poke(dev_info_t *dip, dev_info_t *rdip,
1820Sstevel@tonic-gate     peekpoke_ctlops_t *in_args);
1830Sstevel@tonic-gate extern int px_lib_ctlops_peek(dev_info_t *dip, dev_info_t *rdip,
1840Sstevel@tonic-gate     peekpoke_ctlops_t *in_args, void *result);
1850Sstevel@tonic-gate 
186*27Sjchu /*
187*27Sjchu  * Error handling functions
188*27Sjchu  */
189*27Sjchu #define	PX_INTR_PAYLOAD_SIZE	8	/* 64 bit words */
190*27Sjchu typedef struct px_fault {
191*27Sjchu 	dev_info_t	*px_fh_dip;
192*27Sjchu 	sysino_t	px_fh_sysino;
193*27Sjchu 	uint_t		(*px_err_func)(caddr_t px_fault);
194*27Sjchu 	devino_t	px_intr_ino;
195*27Sjchu 	uint64_t	px_intr_payload[PX_INTR_PAYLOAD_SIZE];
196*27Sjchu } px_fault_t;
197*27Sjchu 
198*27Sjchu extern int px_err_add_intr(px_fault_t *px_fault_p);
199*27Sjchu extern void px_err_rem_intr(px_fault_t *px_fault_p);
200*27Sjchu 
2010Sstevel@tonic-gate #ifdef	__cplusplus
2020Sstevel@tonic-gate }
2030Sstevel@tonic-gate #endif
2040Sstevel@tonic-gate 
2050Sstevel@tonic-gate #endif	/* _SYS_PX_LIB_H */
206