host-drivers/base-driver/vca/plx87xx/plx_hw.c
static int
plx_program_rid_lut_dma(struct plx_device *xdev, struct pci_dev *pdev)
{
	u32 rid_lut;
	u32 virtual_rid_offset, link_rid_offset;
	u8 dma_bus_number;

	if (xdev->port_id == 0) {
		// NT0
		virtual_rid_offset = PLX_NT0_RID_LUT_VIRTUAL_OFFSET_1;
		link_rid_offset = PLX_NT0_RID_LUT_LINK_OFFSET_1;
	} else {
		// NT1
		virtual_rid_offset = PLX_NT1_RID_LUT_VIRTUAL_OFFSET_1;
		link_rid_offset = PLX_NT1_RID_LUT_LINK_OFFSET_1;
	}

	/*
	 * DMA bus and device numbers are hard coded topology
	 * as they are not expected to change.
	 */
	if (xdev->link_side) {
		dma_bus_number = xdev->pdev->bus->number;
	} else {
		/*
		 * DMA host devices are at the same bus, as an upstream port.
		 * Due to hardware topology, the bus is two levels above NT port
		 */
		dma_bus_number = xdev->pdev->bus->parent->parent->number;
	}

	rid_lut = plx_rid_lut_dma(dma_bus_number, VCA_DMA_DEVICE);
	dev_info(&xdev->pdev->dev, "NT port bus: 0x%x, parent's bus: 0x%x, rid_lut:"
			   " 0x%x\n", xdev->pdev->bus->number, dma_bus_number, rid_lut);

	if (xdev->link_side) {
		plx_mmio_write(&xdev->mmio, rid_lut, link_rid_offset);
	} else {
		plx_mmio_write(&xdev->mmio, rid_lut, virtual_rid_offset);
	}

	return 0;
}
/*
 * plx_program_rid_lut_dma - program RID LUT for PLX DMA
 *
 * @xdev: pointer to plx_device instance
 * @pdev: The PCIe device
 *
 * RETURNS: 0 on success and errno on failure
 */


0 on success and errno on failure
0 on success and errno on failure
static int
plx_program_rid_lut_dma(struct plx_device *xdev, struct pci_dev *pdev)
{
	u32 rid_lut;
	u32 virtual_rid_offset, link_rid_offset;
	u8 dma_bus_number;
	if (xdev->port_id == 0) {
		virtual_rid_offset = PLX_NT0_RID_LUT_VIRTUAL_OFFSET_1;
		link_rid_offset = PLX_NT0_RID_LUT_LINK_OFFSET_1;
	} else {
		virtual_rid_offset = PLX_NT1_RID_LUT_VIRTUAL_OFFSET_1;
		link_rid_offset = PLX_NT1_RID_LUT_LINK_OFFSET_1;
	}
	if (xdev->link_side) {
		dma_bus_number = xdev->pdev->bus->number;
	} else {
		dma_bus_number = xdev->pdev->bus->parent->parent->number;
	}
	rid_lut = plx_rid_lut_dma(dma_bus_number, VCA_DMA_DEVICE);
	dev_info(&xdev->pdev->dev, "NT port bus: 0x%x, parent's bus: 0x%x, rid_lut:"
			   " 0x%x\n", xdev->pdev->bus->number, dma_bus_number, rid_lut);
	if (xdev->link_side) {
		plx_mmio_write(&xdev->mmio, rid_lut, link_rid_offset);
	} else {
		plx_mmio_write(&xdev->mmio, rid_lut, virtual_rid_offset);
	}
	return 0;
}
static int plx_program_rid_lut_dma ( struct plx_device * xdev , struct pci_dev * pdev ) { u32 rid_lut ; u32 virtual_rid_offset , link_rid_offset ; u8 dma_bus_number ; if ( xdev -> port_id == 0 ) { virtual_rid_offset = PLX_NT0_RID_LUT_VIRTUAL_OFFSET_1 ; link_rid_offset = PLX_NT0_RID_LUT_LINK_OFFSET_1 ; } else { virtual_rid_offset = PLX_NT1_RID_LUT_VIRTUAL_OFFSET_1 ; link_rid_offset = PLX_NT1_RID_LUT_LINK_OFFSET_1 ; } if ( xdev -> link_side ) { dma_bus_number = xdev -> pdev -> bus -> number ; } else { dma_bus_number = xdev -> pdev -> bus -> parent -> parent -> number ; } rid_lut = plx_rid_lut_dma ( dma_bus_number , VCA_DMA_DEVICE ) ; dev_info ( & xdev -> pdev -> dev , " " " \n " , xdev -> pdev -> bus -> number , dma_bus_number , rid_lut ) ; if ( xdev -> link_side ) { plx_mmio_write ( & xdev -> mmio , rid_lut , link_rid_offset ) ; } else { plx_mmio_write ( & xdev -> mmio , rid_lut , virtual_rid_offset ) ; } return 0 ; }
plx_program_rid_lut_dma - program RID LUT for PLX DMA
 @xdev: pointer to plx_device instance
 @pdev: The PCIe device
plx_program_rid_lut_dma - program RID LUT for PLX DMA @xdev : pointer to plx_device instance @pdev : The PCIe device
// NT0 // NT1 /*
	 * DMA bus and device numbers are hard coded topology
	 * as they are not expected to change.
	 */ /*
		 * DMA host devices are at the same bus, as an upstream port.
		 * Due to hardware topology, the bus is two levels above NT port
		 */