xref: /illumos-gate/usr/src/uts/sun4v/io/px/px_lib4v.h (revision 3d78e6ab)
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
544bb982bSgovinda  * Common Development and Distribution License (the "License").
644bb982bSgovinda  * 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 /*
22*3d78e6abSAlan Adamson, SD OSSD  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate  */
247c478bd9Sstevel@tonic-gate 
257c478bd9Sstevel@tonic-gate #ifndef _SYS_PX_LIB4V_H
267c478bd9Sstevel@tonic-gate #define	_SYS_PX_LIB4V_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
297c478bd9Sstevel@tonic-gate extern "C" {
307c478bd9Sstevel@tonic-gate #endif
317c478bd9Sstevel@tonic-gate 
320ad689d6Sschwartz /*
330ad689d6Sschwartz  * Fasttrap numbers for VPCI hypervisor functions.
340ad689d6Sschwartz  */
350ad689d6Sschwartz 
360ad689d6Sschwartz #define	HVIO_IOMMU_MAP		0xb0
370ad689d6Sschwartz #define	HVIO_IOMMU_DEMAP	0xb1
380ad689d6Sschwartz #define	HVIO_IOMMU_GETMAP	0xb2
390ad689d6Sschwartz #define	HVIO_IOMMU_GETBYPASS	0xb3
400ad689d6Sschwartz 
410ad689d6Sschwartz #define	HVIO_CONFIG_GET		0xb4
420ad689d6Sschwartz #define	HVIO_CONFIG_PUT		0xb5
430ad689d6Sschwartz 
440ad689d6Sschwartz #define	HVIO_PEEK		0xb6
450ad689d6Sschwartz #define	HVIO_POKE		0xb7
460ad689d6Sschwartz 
470ad689d6Sschwartz #define	HVIO_DMA_SYNC		0xb8
480ad689d6Sschwartz 
490ad689d6Sschwartz #define	HVIO_MSIQ_CONF		0xc0
500ad689d6Sschwartz #define	HVIO_MSIQ_INFO		0xc1
510ad689d6Sschwartz #define	HVIO_MSIQ_GETVALID	0xc2
520ad689d6Sschwartz #define	HVIO_MSIQ_SETVALID	0xc3
530ad689d6Sschwartz #define	HVIO_MSIQ_GETSTATE	0xc4
540ad689d6Sschwartz #define	HVIO_MSIQ_SETSTATE	0xc5
550ad689d6Sschwartz #define	HVIO_MSIQ_GETHEAD	0xc6
560ad689d6Sschwartz #define	HVIO_MSIQ_SETHEAD	0xc7
570ad689d6Sschwartz #define	HVIO_MSIQ_GETTAIL	0xc8
580ad689d6Sschwartz 
590ad689d6Sschwartz #define	HVIO_MSI_GETVALID	0xc9
600ad689d6Sschwartz #define	HVIO_MSI_SETVALID	0xca
610ad689d6Sschwartz #define	HVIO_MSI_GETMSIQ	0xcb
620ad689d6Sschwartz #define	HVIO_MSI_SETMSIQ	0xcc
630ad689d6Sschwartz #define	HVIO_MSI_GETSTATE	0xcd
640ad689d6Sschwartz #define	HVIO_MSI_SETSTATE	0xce
650ad689d6Sschwartz 
660ad689d6Sschwartz #define	HVIO_MSG_GETMSIQ	0xd0
670ad689d6Sschwartz #define	HVIO_MSG_SETMSIQ	0xd1
680ad689d6Sschwartz #define	HVIO_MSG_GETVALID	0xd2
690ad689d6Sschwartz #define	HVIO_MSG_SETVALID	0xd3
700ad689d6Sschwartz 
71fc256490SJason Beloro /*
72fc256490SJason Beloro  * Fasttrap numbers for SDIO hypervisor functions.
73fc256490SJason Beloro  */
74fc256490SJason Beloro #define	PCI_IOV_ROOT_CONFIGURED		0xf8
75fc256490SJason Beloro 
76fc256490SJason Beloro /*
77fc256490SJason Beloro  * Fasttrap numbers for SDIO ERR hypervisor functions.
78fc256490SJason Beloro  */
79fc256490SJason Beloro #define	PCI_ERROR_SEND			0xff
80fc256490SJason Beloro 
810ad689d6Sschwartz #ifndef _ASM
820ad689d6Sschwartz 
837c478bd9Sstevel@tonic-gate /*
847c478bd9Sstevel@tonic-gate  * The device handle uniquely identifies a SUN4V device.
857c478bd9Sstevel@tonic-gate  * It consists of the lower 28-bits of the hi-cell of the
867c478bd9Sstevel@tonic-gate  * first entry of the SUN4V device's "reg" property as
877c478bd9Sstevel@tonic-gate  * defined by the SUN4V Bus Binding to Open Firmware.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate #define	DEVHDLE_MASK	0xFFFFFFF
907c478bd9Sstevel@tonic-gate 
9144bb982bSgovinda #define	PX_ADDR2PFN(addr, index, flags, i) \
9244bb982bSgovinda 	((flags & MMU_MAP_PFN) ? \
935bc7e870Sgovinda 	PX_GET_MP_PFN((ddi_dma_impl_t *)(addr), (index + i)) : \
945bc7e870Sgovinda 	hat_getpfnum(kas.a_hat, ((caddr_t)addr + (MMU_PAGE_SIZE * i))))
955bc7e870Sgovinda 
96fc256490SJason Beloro /*
97fc256490SJason Beloro  * Hypercall service versioning
98fc256490SJason Beloro  */
99fc256490SJason Beloro #define	PX_HSVC_MAJOR_VER_1	0x1ull
100*3d78e6abSAlan Adamson, SD OSSD #define	PX_HSVC_MAJOR_VER_2	0x2ull
101fc256490SJason Beloro #define	PX_HSVC_MINOR_VER_0	0x0ull
102fc256490SJason Beloro #define	PX_HSVC_MINOR_VER_1	0x1ull
103fc256490SJason Beloro #define	PX_HSVC_MINOR_VER_2	0x2ull
104fc256490SJason Beloro 
10544bb982bSgovinda /*
10644bb982bSgovinda  * VPCI API versioning.
107*3d78e6abSAlan Adamson, SD OSSD  * Currently PX nexus driver supports VPCI API version 2.0
108*3d78e6abSAlan Adamson, SD OSSD  * 1.0 - Negotiated/supported.
109*3d78e6abSAlan Adamson, SD OSSD  * 1.1/1.2 - Deprecated.
110*3d78e6abSAlan Adamson, SD OSSD  * 2.0 - Negotiated/supported.
11144bb982bSgovinda  */
112*3d78e6abSAlan Adamson, SD OSSD #define	PX_VPCI_MAJOR_VER	PX_HSVC_MAJOR_VER_2
113*3d78e6abSAlan Adamson, SD OSSD #define	PX_VPCI_MINOR_VER	PX_HSVC_MINOR_VER_0
11444bb982bSgovinda 
115fc256490SJason Beloro /*
116fc256490SJason Beloro  * SDIO API versioning.
117fc256490SJason Beloro  * Currently PX nexus driver supports SDIO API version 1.0
118fc256490SJason Beloro  */
119fc256490SJason Beloro #define	PX_SDIO_MAJOR_VER	PX_HSVC_MAJOR_VER_1
120fc256490SJason Beloro #define	PX_SDIO_MINOR_VER	PX_HSVC_MINOR_VER_0
121fc256490SJason Beloro 
122fc256490SJason Beloro /*
123fc256490SJason Beloro  * SDIO ERR API versioning.
124fc256490SJason Beloro  * Currently PX nexus driver supports SDIO ERR API version 1.0
125fc256490SJason Beloro  */
126fc256490SJason Beloro #define	PX_SDIO_ERR_MAJOR_VER	PX_HSVC_MAJOR_VER_1
127fc256490SJason Beloro #define	PX_SDIO_ERR_MINOR_VER	PX_HSVC_MINOR_VER_0
12844bb982bSgovinda 
1297c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_map(devhandle_t dev_hdl, tsbid_t tsbid,
13044bb982bSgovinda     pages_t pages, io_attributes_t attr, io_page_list_t *io_page_list_p,
13144bb982bSgovinda     pages_t *pages_mapped);
1327c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_demap(devhandle_t dev_hdl, tsbid_t tsbid,
1337c478bd9Sstevel@tonic-gate     pages_t pages, pages_t *pages_demapped);
1347c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getmap(devhandle_t dev_hdl, tsbid_t tsbid,
13544bb982bSgovinda     io_attributes_t *attr_p, r_addr_t *r_addr_p);
1367c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra,
13744bb982bSgovinda     io_attributes_t attr, io_addr_t *io_addr_p);
1387c478bd9Sstevel@tonic-gate extern uint64_t hvio_dma_sync(devhandle_t dev_hdl, r_addr_t ra,
1397c478bd9Sstevel@tonic-gate     size_t num_bytes, io_sync_direction_t io_sync_direction,
1407c478bd9Sstevel@tonic-gate     size_t *bytes_synched);
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate /*
1437c478bd9Sstevel@tonic-gate  * MSIQ Functions:
1447c478bd9Sstevel@tonic-gate  */
1457c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_conf(devhandle_t dev_hdl, msiqid_t msiq_id,
1467c478bd9Sstevel@tonic-gate     r_addr_t ra, uint_t msiq_rec_cnt);
1477c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_info(devhandle_t dev_hdl, msiqid_t msiq_id,
1487c478bd9Sstevel@tonic-gate     r_addr_t *ra_p, uint_t *msiq_rec_cnt_p);
1497c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
1507c478bd9Sstevel@tonic-gate     pci_msiq_valid_state_t *msiq_valid_state);
1517c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
1527c478bd9Sstevel@tonic-gate     pci_msiq_valid_state_t msiq_valid_state);
1537c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getstate(devhandle_t dev_hdl, msiqid_t msiq_id,
1547c478bd9Sstevel@tonic-gate     pci_msiq_state_t *msiq_state);
1557c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setstate(devhandle_t dev_hdl, msiqid_t msiq_id,
1567c478bd9Sstevel@tonic-gate     pci_msiq_state_t msiq_state);
1577c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gethead(devhandle_t dev_hdl, msiqid_t msiq_id,
1587c478bd9Sstevel@tonic-gate     msiqhead_t *msiq_head);
1597c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_sethead(devhandle_t dev_hdl, msiqid_t msiq_id,
1607c478bd9Sstevel@tonic-gate     msiqhead_t msiq_head);
1617c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gettail(devhandle_t dev_hdl, msiqid_t msiq_id,
1627c478bd9Sstevel@tonic-gate     msiqtail_t *msiq_tail);
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate /*
1657c478bd9Sstevel@tonic-gate  * MSI Functions:
1667c478bd9Sstevel@tonic-gate  */
1677c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getmsiq(devhandle_t dev_hdl, msinum_t msi_num,
1687c478bd9Sstevel@tonic-gate     msiqid_t *msiq_id);
1697c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setmsiq(devhandle_t dev_hdl, msinum_t msi_num,
1707c478bd9Sstevel@tonic-gate     msiqid_t msiq_id, msi_type_t msitype);
1717c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getvalid(devhandle_t dev_hdl, msinum_t msi_num,
1727c478bd9Sstevel@tonic-gate     pci_msi_valid_state_t *msi_valid_state);
1737c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setvalid(devhandle_t dev_hdl, msinum_t msi_num,
1747c478bd9Sstevel@tonic-gate     pci_msi_valid_state_t msi_valid_state);
1757c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getstate(devhandle_t dev_hdl, msinum_t msi_num,
1767c478bd9Sstevel@tonic-gate     pci_msi_state_t *msi_state);
1777c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setstate(devhandle_t dev_hdl, msinum_t msi_num,
1787c478bd9Sstevel@tonic-gate     pci_msi_state_t msi_state);
1797c478bd9Sstevel@tonic-gate 
180fc256490SJason Beloro 
181fc256490SJason Beloro extern uint64_t pci_error_send(devhandle_t dev_hdl, devino_t devino,
182fc256490SJason Beloro     pci_device_t bdf);
183fc256490SJason Beloro 
1847c478bd9Sstevel@tonic-gate /*
1857c478bd9Sstevel@tonic-gate  * MSG Functions:
1867c478bd9Sstevel@tonic-gate  */
1877c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1887c478bd9Sstevel@tonic-gate     msiqid_t *msiq_id);
1897c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1907c478bd9Sstevel@tonic-gate     msiqid_t msiq_id);
1917c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1927c478bd9Sstevel@tonic-gate     pcie_msg_valid_state_t *msg_valid_state);
1937c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1947c478bd9Sstevel@tonic-gate     pcie_msg_valid_state_t msg_valid_state);
1957c478bd9Sstevel@tonic-gate 
1967c478bd9Sstevel@tonic-gate typedef struct px_config_acc_pvt {
1977c478bd9Sstevel@tonic-gate 	dev_info_t *dip;
1987c478bd9Sstevel@tonic-gate 	uint32_t raddr;
1997c478bd9Sstevel@tonic-gate 	uint32_t vaddr;
2007c478bd9Sstevel@tonic-gate } px_config_acc_pvt_t;
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * Peek/poke functionality:
2047c478bd9Sstevel@tonic-gate  */
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate extern uint64_t hvio_peek(devhandle_t dev_hdl, r_addr_t ra, size_t size,
2077c478bd9Sstevel@tonic-gate     uint32_t *status, uint64_t *data_p);
2087c478bd9Sstevel@tonic-gate extern uint64_t hvio_poke(devhandle_t dev_hdl, r_addr_t ra, size_t size,
2097c478bd9Sstevel@tonic-gate     uint64_t data, pci_device_t bdf, uint32_t *wrt_stat);
2100114761dSAlan Adamson, SD OSSD extern uint64_t hvio_get_rp_mps_cap(devhandle_t dev_hdl, pci_device_t bdf,
2110114761dSAlan Adamson, SD OSSD     int32_t *mps_cap);
2120114761dSAlan Adamson, SD OSSD extern uint64_t hvio_set_rp_mps(devhandle_t dev_hdl, pci_device_t bdf,
2130114761dSAlan Adamson, SD OSSD     int32_t mps);
2147c478bd9Sstevel@tonic-gate 
21569cd775fSschwartz /*
21669cd775fSschwartz  * Priviledged physical access:
21769cd775fSschwartz  */
21869cd775fSschwartz extern uint64_t hv_ra2pa(uint64_t ra);
21969cd775fSschwartz extern uint64_t hv_hpriv(void *func, uint64_t arg1, uint64_t arg2,
22069cd775fSschwartz     uint64_t arg3);
22144bb982bSgovinda extern int px_phys_acc_4v(uint64_t dummy, uint64_t from_addr, uint64_t to_addr);
22269cd775fSschwartz 
223fc256490SJason Beloro /*
224fc256490SJason Beloro  * PCI IOV SDIO Funcitons:
225fc256490SJason Beloro  */
226fc256490SJason Beloro extern uint64_t pci_iov_root_configured(devhandle_t dev_hdl);
227fc256490SJason Beloro 
2280ad689d6Sschwartz #endif /* _ASM */
2290ad689d6Sschwartz 
2307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
2317c478bd9Sstevel@tonic-gate }
2327c478bd9Sstevel@tonic-gate #endif
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate #endif	/* _SYS_PX_LIB4V_H */
235