xref: /illumos-gate/usr/src/uts/sun4v/io/px/px_lib4v.h (revision 44bb982b)
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
5*44bb982bSgovinda  * Common Development and Distribution License (the "License").
6*44bb982bSgovinda  * 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*44bb982bSgovinda  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef _SYS_PX_LIB4V_H
277c478bd9Sstevel@tonic-gate #define	_SYS_PX_LIB4V_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * SUN4V IO API - Version 1.11
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * The device handle uniquely identifies a SUN4V device.
417c478bd9Sstevel@tonic-gate  * It consists of the lower 28-bits of the hi-cell of the
427c478bd9Sstevel@tonic-gate  * first entry of the SUN4V device's "reg" property as
437c478bd9Sstevel@tonic-gate  * defined by the SUN4V Bus Binding to Open Firmware.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate #define	DEVHDLE_MASK	0xFFFFFFF
467c478bd9Sstevel@tonic-gate 
478bc7d88aSet /* PX BDF Shift in a Phyiscal Address - used FMA Fabric only */
488bc7d88aSet #define	PX_RA_BDF_SHIFT			8
498bc7d88aSet 
50*44bb982bSgovinda #define	PX_ADDR2PFN(addr, index, flags, i) \
51*44bb982bSgovinda 	((flags & MMU_MAP_PFN) ? \
525bc7e870Sgovinda 	PX_GET_MP_PFN((ddi_dma_impl_t *)(addr), (index + i)) : \
535bc7e870Sgovinda 	hat_getpfnum(kas.a_hat, ((caddr_t)addr + (MMU_PAGE_SIZE * i))))
545bc7e870Sgovinda 
55*44bb982bSgovinda /*
56*44bb982bSgovinda  * VPCI API versioning.
57*44bb982bSgovinda  *
58*44bb982bSgovinda  * Currently PX nexus driver supports VPCI API version 1.0.
59*44bb982bSgovinda  */
60*44bb982bSgovinda #define	PX_VPCI_MAJOR_VER_1	0x1ull
61*44bb982bSgovinda #define	PX_VPCI_MAJOR_VER	PX_VPCI_MAJOR_VER_1
62*44bb982bSgovinda 
63*44bb982bSgovinda #define	PX_VPCI_MINOR_VER_0	0x0ull
64*44bb982bSgovinda #define	PX_VPCI_MINOR_VER	PX_VPCI_MINOR_VER_0
65*44bb982bSgovinda 
667c478bd9Sstevel@tonic-gate extern uint64_t hvio_config_get(devhandle_t dev_hdl, pci_device_t bdf,
677c478bd9Sstevel@tonic-gate     pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t *data_p);
687c478bd9Sstevel@tonic-gate extern uint64_t hvio_config_put(devhandle_t dev_hdl, pci_device_t bdf,
697c478bd9Sstevel@tonic-gate     pci_config_offset_t off, pci_config_size_t size, pci_cfg_data_t data);
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_map(devhandle_t dev_hdl, tsbid_t tsbid,
72*44bb982bSgovinda     pages_t pages, io_attributes_t attr, io_page_list_t *io_page_list_p,
73*44bb982bSgovinda     pages_t *pages_mapped);
747c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_demap(devhandle_t dev_hdl, tsbid_t tsbid,
757c478bd9Sstevel@tonic-gate     pages_t pages, pages_t *pages_demapped);
767c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getmap(devhandle_t dev_hdl, tsbid_t tsbid,
77*44bb982bSgovinda     io_attributes_t *attr_p, r_addr_t *r_addr_p);
787c478bd9Sstevel@tonic-gate extern uint64_t hvio_iommu_getbypass(devhandle_t dev_hdl, r_addr_t ra,
79*44bb982bSgovinda     io_attributes_t attr, io_addr_t *io_addr_p);
807c478bd9Sstevel@tonic-gate extern uint64_t hvio_dma_sync(devhandle_t dev_hdl, r_addr_t ra,
817c478bd9Sstevel@tonic-gate     size_t num_bytes, io_sync_direction_t io_sync_direction,
827c478bd9Sstevel@tonic-gate     size_t *bytes_synched);
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate /*
857c478bd9Sstevel@tonic-gate  * MSIQ Functions:
867c478bd9Sstevel@tonic-gate  */
877c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_conf(devhandle_t dev_hdl, msiqid_t msiq_id,
887c478bd9Sstevel@tonic-gate     r_addr_t ra, uint_t msiq_rec_cnt);
897c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_info(devhandle_t dev_hdl, msiqid_t msiq_id,
907c478bd9Sstevel@tonic-gate     r_addr_t *ra_p, uint_t *msiq_rec_cnt_p);
917c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
927c478bd9Sstevel@tonic-gate     pci_msiq_valid_state_t *msiq_valid_state);
937c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setvalid(devhandle_t dev_hdl, msiqid_t msiq_id,
947c478bd9Sstevel@tonic-gate     pci_msiq_valid_state_t msiq_valid_state);
957c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_getstate(devhandle_t dev_hdl, msiqid_t msiq_id,
967c478bd9Sstevel@tonic-gate     pci_msiq_state_t *msiq_state);
977c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_setstate(devhandle_t dev_hdl, msiqid_t msiq_id,
987c478bd9Sstevel@tonic-gate     pci_msiq_state_t msiq_state);
997c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gethead(devhandle_t dev_hdl, msiqid_t msiq_id,
1007c478bd9Sstevel@tonic-gate     msiqhead_t *msiq_head);
1017c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_sethead(devhandle_t dev_hdl, msiqid_t msiq_id,
1027c478bd9Sstevel@tonic-gate     msiqhead_t msiq_head);
1037c478bd9Sstevel@tonic-gate extern uint64_t hvio_msiq_gettail(devhandle_t dev_hdl, msiqid_t msiq_id,
1047c478bd9Sstevel@tonic-gate     msiqtail_t *msiq_tail);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  * MSI Functions:
1087c478bd9Sstevel@tonic-gate  */
1097c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getmsiq(devhandle_t dev_hdl, msinum_t msi_num,
1107c478bd9Sstevel@tonic-gate     msiqid_t *msiq_id);
1117c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setmsiq(devhandle_t dev_hdl, msinum_t msi_num,
1127c478bd9Sstevel@tonic-gate     msiqid_t msiq_id, msi_type_t msitype);
1137c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getvalid(devhandle_t dev_hdl, msinum_t msi_num,
1147c478bd9Sstevel@tonic-gate     pci_msi_valid_state_t *msi_valid_state);
1157c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setvalid(devhandle_t dev_hdl, msinum_t msi_num,
1167c478bd9Sstevel@tonic-gate     pci_msi_valid_state_t msi_valid_state);
1177c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_getstate(devhandle_t dev_hdl, msinum_t msi_num,
1187c478bd9Sstevel@tonic-gate     pci_msi_state_t *msi_state);
1197c478bd9Sstevel@tonic-gate extern uint64_t hvio_msi_setstate(devhandle_t dev_hdl, msinum_t msi_num,
1207c478bd9Sstevel@tonic-gate     pci_msi_state_t msi_state);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate /*
1237c478bd9Sstevel@tonic-gate  * MSG Functions:
1247c478bd9Sstevel@tonic-gate  */
1257c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1267c478bd9Sstevel@tonic-gate     msiqid_t *msiq_id);
1277c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setmsiq(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1287c478bd9Sstevel@tonic-gate     msiqid_t msiq_id);
1297c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_getvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1307c478bd9Sstevel@tonic-gate     pcie_msg_valid_state_t *msg_valid_state);
1317c478bd9Sstevel@tonic-gate extern uint64_t hvio_msg_setvalid(devhandle_t dev_hdl, pcie_msg_type_t msg_type,
1327c478bd9Sstevel@tonic-gate     pcie_msg_valid_state_t msg_valid_state);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate typedef struct px_config_acc_pvt {
1357c478bd9Sstevel@tonic-gate 	dev_info_t *dip;
1367c478bd9Sstevel@tonic-gate 	uint32_t raddr;
1377c478bd9Sstevel@tonic-gate 	uint32_t vaddr;
1387c478bd9Sstevel@tonic-gate } px_config_acc_pvt_t;
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate /*
1417c478bd9Sstevel@tonic-gate  * Peek/poke functionality:
1427c478bd9Sstevel@tonic-gate  */
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate extern uint64_t hvio_peek(devhandle_t dev_hdl, r_addr_t ra, size_t size,
1457c478bd9Sstevel@tonic-gate     uint32_t *status, uint64_t *data_p);
1467c478bd9Sstevel@tonic-gate extern uint64_t hvio_poke(devhandle_t dev_hdl, r_addr_t ra, size_t size,
1477c478bd9Sstevel@tonic-gate     uint64_t data, pci_device_t bdf, uint32_t *wrt_stat);
1487c478bd9Sstevel@tonic-gate 
14969cd775fSschwartz /*
15069cd775fSschwartz  * Priviledged physical access:
15169cd775fSschwartz  */
15269cd775fSschwartz extern uint64_t hv_ra2pa(uint64_t ra);
15369cd775fSschwartz extern uint64_t hv_hpriv(void *func, uint64_t arg1, uint64_t arg2,
15469cd775fSschwartz     uint64_t arg3);
155*44bb982bSgovinda extern int px_phys_acc_4v(uint64_t dummy, uint64_t from_addr, uint64_t to_addr);
15669cd775fSschwartz 
1577c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate #endif
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #endif	/* _SYS_PX_LIB4V_H */
162