src/dpdk/drivers/bus/pci/pci_common_uio.c
int
pci_uio_map_resource(struct rte_pci_device *dev)
{
	int i, map_idx = 0, ret;
	uint64_t phaddr;
	struct mapped_pci_resource *uio_res = NULL;
	struct mapped_pci_res_list *uio_res_list =
		RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);

	dev->intr_handle.fd = -1;
	dev->intr_handle.uio_cfg_fd = -1;

	/* secondary processes - use already recorded details */
	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
		return pci_uio_map_secondary(dev);

	/* allocate uio resource */
	ret = pci_uio_alloc_resource(dev, &uio_res);
	if (ret)
		return ret;

	/* Map all BARs */
	for (i = 0; i != PCI_MAX_RESOURCE; i++) {
		/* skip empty BAR */
		phaddr = dev->mem_resource[i].phys_addr;
		if (phaddr == 0)
			continue;

		ret = pci_uio_map_resource_by_index(dev, i,
				uio_res, map_idx);
		if (ret)
			goto error;

		map_idx++;
	}

	uio_res->nb_maps = map_idx;

	TAILQ_INSERT_TAIL(uio_res_list, uio_res, next);

	return 0;
error:
	for (i = 0; i < map_idx; i++) {
		pci_unmap_resource(uio_res->maps[i].addr,
				(size_t)uio_res->maps[i].size);
		rte_free(uio_res->maps[i].path);
	}
	pci_uio_free_resource(dev, uio_res);
	return -1;
}
/* map the PCI resource of a PCI device in virtual memory */
map the PCI resource of a PCI device in virtual memory
map the PCI resource of a PCI device in virtual memory
int
pci_uio_map_resource(struct rte_pci_device *dev)
{
	int i, map_idx = 0, ret;
	uint64_t phaddr;
	struct mapped_pci_resource *uio_res = NULL;
	struct mapped_pci_res_list *uio_res_list =
		RTE_TAILQ_CAST(rte_uio_tailq.head, mapped_pci_res_list);
	dev->intr_handle.fd = -1;
	dev->intr_handle.uio_cfg_fd = -1;
	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
		return pci_uio_map_secondary(dev);
	ret = pci_uio_alloc_resource(dev, &uio_res);
	if (ret)
		return ret;
	for (i = 0; i != PCI_MAX_RESOURCE; i++) {
		phaddr = dev->mem_resource[i].phys_addr;
		if (phaddr == 0)
			continue;
		ret = pci_uio_map_resource_by_index(dev, i,
				uio_res, map_idx);
		if (ret)
			goto error;
		map_idx++;
	}
	uio_res->nb_maps = map_idx;
	TAILQ_INSERT_TAIL(uio_res_list, uio_res, next);
	return 0;
error:
	for (i = 0; i < map_idx; i++) {
		pci_unmap_resource(uio_res->maps[i].addr,
				(size_t)uio_res->maps[i].size);
		rte_free(uio_res->maps[i].path);
	}
	pci_uio_free_resource(dev, uio_res);
	return -1;
}
int pci_uio_map_resource ( struct rte_pci_device * dev ) { int i , map_idx = 0 , ret ; uint64_t phaddr ; struct mapped_pci_resource * uio_res = NULL ; struct mapped_pci_res_list * uio_res_list = RTE_TAILQ_CAST ( rte_uio_tailq . head , mapped_pci_res_list ) ; dev -> intr_handle . fd = -1 ; dev -> intr_handle . uio_cfg_fd = -1 ; if ( rte_eal_process_type ( ) != RTE_PROC_PRIMARY ) return pci_uio_map_secondary ( dev ) ; ret = pci_uio_alloc_resource ( dev , & uio_res ) ; if ( ret ) return ret ; for ( i = 0 ; i != PCI_MAX_RESOURCE ; i ++ ) { phaddr = dev -> mem_resource [ i ] . phys_addr ; if ( phaddr == 0 ) continue ; ret = pci_uio_map_resource_by_index ( dev , i , uio_res , map_idx ) ; if ( ret ) goto error ; map_idx ++ ; } uio_res -> nb_maps = map_idx ; TAILQ_INSERT_TAIL ( uio_res_list , uio_res , next ) ; return 0 ; error : for ( i = 0 ; i < map_idx ; i ++ ) { pci_unmap_resource ( uio_res -> maps [ i ] . addr , ( size_t ) uio_res -> maps [ i ] . size ) ; rte_free ( uio_res -> maps [ i ] . path ) ; } pci_uio_free_resource ( dev , uio_res ) ; return -1 ; }
map the PCI resource of a PCI device in virtual memory
map the PCI resource of a PCI device in virtual memory
/* secondary processes - use already recorded details */ /* allocate uio resource */ /* Map all BARs */ /* skip empty BAR */