iommulib.h revision 256141046d195629e2d487169658f509aec955cd
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * CDDL HEADER START
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * The contents of this file are subject to the terms of the
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Common Development and Distribution License (the "License").
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * You may not use this file except in compliance with the License.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * See the License for the specific language governing permissions
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * and limitations under the License.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * When distributing Covered Code, include this CDDL HEADER in each
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * If applicable, add the following below this CDDL HEADER, with the
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * fields enclosed by brackets "[]" replaced with your own identifying
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * information: Portions Copyright [yyyy] [name of copyright owner]
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * CDDL HEADER END
e085f1530a2b52c62d916408e99d66a557855d42Vikram Hegde * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Use is subject to license terms.
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#pragma ident "@(#)iommulib.h 1.3 08/08/31 SMI"
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef enum {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef enum {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef struct iommulib_ops {
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*ilops_probe)(iommulib_handle_t handle, dev_info_t *rdip);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_allochdl)(iommulib_handle_t handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *dip, dev_info_t *rdip, ddi_dma_attr_t *attr,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*waitfp)(caddr_t), caddr_t arg, ddi_dma_handle_t *dma_handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_freehdl)(iommulib_handle_t handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_bindhdl)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_cookie_t *cookiep,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_unbindhdl)(iommulib_handle_t handle,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *dip, dev_info_t *rdip, ddi_dma_handle_t dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_sync)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *rdip, ddi_dma_handle_t dma_handle, off_t off,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_win)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde dev_info_t *rdip, ddi_dma_handle_t dma_handle, uint_t win,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde off_t *offp, size_t *lenp, ddi_dma_cookie_t *cookiep,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde /* Obsolete DMA routines */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_map)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*ilops_dma_mctl)(iommulib_handle_t handle, dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde enum ddi_dma_ctlops request, off_t *offp, size_t *lenp,
b51bbbf59a7a1941f5e9531370c2f87d8cd7f621Vikram Hegde * IOMMU_USED() checks if there is an IOMMU controlling the dip's DMA
b51bbbf59a7a1941f5e9531370c2f87d8cd7f621Vikram Hegde#define IOMMU_USED(dip) (DEVI(dip)->devi_iommulib_handle)
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef enum {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#define IOMMU_NEXOPS_VERSION IOMMU_NEXOPS_VERSION_1
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef struct iommulib_nexops {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_allochdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_freehdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_bindhdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_unbindhdl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde void (*nops_dma_reset_cookies)(dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_get_cookies)(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*nops_dma_set_cookies)(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*nops_dma_clear_cookies)(dev_info_t *dip, ddi_dma_handle_t handle);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde int (*nops_dma_get_sleep_flags)(ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_sync)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_win)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_map)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde int (*nops_dma_mctl)(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde size_t *lenp, caddr_t *objpp, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdetypedef struct iommulib_nex *iommulib_nexhandle_t;
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde * struct iommu_dip_private
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde * private iommu structure hook on dev_info
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdetypedef struct iommu_private {
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* pci seg, bus, dev, func */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* ppb information */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* identifier for special devices */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde /* domain ptr */
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegde#define INTEL_IOMMU_PRIVATE(i) (dmar_domain_state_t *)(i)
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdetypedef struct gfx_entry {
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Interfaces for nexus drivers - typically rootnex
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexus_register(dev_info_t *dip, iommulib_nexops_t *nexops,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexus_unregister(iommulib_nexhandle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nex_open(dev_info_t *rdip, uint_t *errorp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_allochdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_freehdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, struct ddi_dma_req *dmareq,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_sync(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, off_t off, size_t len,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_win(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, uint_t win, off_t *offp, size_t *lenp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_map(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_handle_t *dma_handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_nexdma_mctl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t dma_handle, enum ddi_dma_ctlops request,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde off_t *offp, size_t *lenp, caddr_t *objpp, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde * Interfaces for IOMMU drivers provided by IOMMULIB
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_register(dev_info_t *dip, iommulib_ops_t *ops,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_unregister(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_getunitid(iommulib_handle_t handle, uint64_t *unitidp);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdedev_info_t *iommulib_iommu_getdip(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeiommulib_ops_t *iommulib_iommu_getops(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdevoid *iommulib_iommu_getdata(iommulib_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde/* Interfaces for IOMMU drivers provided by NEXUS drivers (typically rootnex) */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_allochdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_attr_t *attr, int (*waitfp)(caddr_t), caddr_t arg,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_freehdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_bindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, struct ddi_dma_req *dmareq,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_unbindhdl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdevoid iommulib_iommu_dma_reset_cookies(dev_info_t *dip, ddi_dma_handle_t handle);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_get_cookies(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdeint iommulib_iommu_dma_set_cookies(dev_info_t *dip, ddi_dma_handle_t handle,
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdeint iommulib_iommu_dma_clear_cookies(dev_info_t *dip, ddi_dma_handle_t handle);
94f1124e84b3daba182b39a5df7b044074cb1c71Vikram Hegdeint iommulib_iommu_dma_get_sleep_flags(dev_info_t *dip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_sync(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, off_t off, size_t len, uint_t cache_flags);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_win(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, uint_t win, off_t *offp, size_t *lenp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_map(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde struct ddi_dma_req *dmareq, ddi_dma_handle_t *handlep);
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegdeint iommulib_iommu_dma_mctl(dev_info_t *dip, dev_info_t *rdip,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde ddi_dma_handle_t handle, enum ddi_dma_ctlops request, off_t *offp,
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde size_t *lenp, caddr_t *objpp, uint_t cache_flags);
65cf7c958eb9457cf2c83a853d128e4ecfc187a6Vikram Hegde * For SMBIOS access from IOMMU drivers
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#endif /* _KERNEL */
20906b23a341979b80c2e40ac68778cd082f5458Vikram Hegde#endif /* _SYS_IOMMULIB_H */