static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev) { const unsigned char *dma_window; struct iommu_table *tbl; unsigned long offset, size; if (firmware_has_feature(FW_FEATURE_ISERIES)) return vio_build_iommu_table_iseries(dev); dma_window = of_get_property(dev->dev.archdata.of_node, "ibm,my-dma-window", NULL); if (!dma_window) return NULL; tbl = kmalloc(sizeof(*tbl), GFP_KERNEL); of_parse_dma_window(dev->dev.archdata.of_node, dma_window, &tbl->it_index, &offset, &size); /* TCE table size - measured in tce entries */ tbl->it_size = size >> IOMMU_PAGE_SHIFT; /* offset for VIO should always be 0 */ tbl->it_offset = offset >> IOMMU_PAGE_SHIFT; tbl->it_busno = 0; tbl->it_type = TCE_VB; return iommu_init_table(tbl, -1); }
static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev) { #ifdef CONFIG_PPC_ISERIES if (firmware_has_feature(FW_FEATURE_ISERIES)) { if (strcmp(dev->type, "network") == 0) return &veth_iommu_table; return &vio_iommu_table; } else #endif { const unsigned char *dma_window; struct iommu_table *tbl; unsigned long offset, size; dma_window = get_property(dev->dev.platform_data, "ibm,my-dma-window", NULL); if (!dma_window) return NULL; tbl = kmalloc(sizeof(*tbl), GFP_KERNEL); of_parse_dma_window(dev->dev.platform_data, dma_window, &tbl->it_index, &offset, &size); /* TCE table size - measured in tce entries */ tbl->it_size = size >> IOMMU_PAGE_SHIFT; /* offset for VIO should always be 0 */ tbl->it_offset = offset >> IOMMU_PAGE_SHIFT; tbl->it_busno = 0; tbl->it_type = TCE_VB; return iommu_init_table(tbl, -1); } }
/* * iommu_table_setparms_lpar * * Function: On pSeries LPAR systems, return TCE table info, given a pci bus. */ static void iommu_table_setparms_lpar(struct pci_controller *phb, struct device_node *dn, struct iommu_table *tbl, const void *dma_window) { unsigned long offset, size; of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size); tbl->it_busno = phb->bus->number; tbl->it_base = 0; tbl->it_blocksize = 16; tbl->it_type = TCE_PCI; tbl->it_offset = offset >> IOMMU_PAGE_SHIFT; tbl->it_size = size >> IOMMU_PAGE_SHIFT; }
/* * iommu_table_setparms_lpar * * Function: On pSeries LPAR systems, return TCE table info, given a pci bus. */ static void iommu_table_setparms_lpar(struct pci_controller *phb, struct device_node *dn, struct iommu_table *tbl, unsigned char *dma_window) { unsigned long offset, size; tbl->it_busno = PCI_DN(dn)->bussubno; of_parse_dma_window(dn, dma_window, &tbl->it_index, &offset, &size); tbl->it_base = 0; tbl->it_blocksize = 16; tbl->it_type = TCE_PCI; tbl->it_offset = offset >> PAGE_SHIFT; tbl->it_size = size >> PAGE_SHIFT; }