X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fbus%2Ffslmc%2Ffslmc_vfio.c;h=45e592770259f9699bf42f18a3d8c501bb00da06;hb=b4d75d98f5696d6b4aab01c368a558f1e24e5c1f;hp=a8002c92de2fe291a1e5c9ede7da25f3727d2c49;hpb=6e1f055d79e0629745699fa7a049a1eefe5cc752;p=dpdk.git diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c index a8002c92de..45e5927702 100644 --- a/drivers/bus/fslmc/fslmc_vfio.c +++ b/drivers/bus/fslmc/fslmc_vfio.c @@ -2,7 +2,7 @@ * BSD LICENSE * * Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved. - * Copyright (c) 2016 NXP. All rights reserved. + * Copyright 2016 NXP. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -55,7 +54,6 @@ #include #include #include -#include #include #include "rte_fslmc.h" @@ -188,29 +186,6 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group) return -errno; } -int vfio_dmamap_mem_region(uint64_t vaddr, - uint64_t iova, - uint64_t size) -{ - struct fslmc_vfio_group *group; - struct vfio_iommu_type1_dma_map dma_map = { - .argsz = sizeof(dma_map), - .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE, - }; - - dma_map.vaddr = vaddr; - dma_map.size = size; - dma_map.iova = iova; - - /* SET DMA MAP for IOMMU */ - group = &vfio_groups[0]; - if (ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &dma_map)) { - FSLMC_VFIO_LOG(ERR, "VFIO_IOMMU_MAP_DMA (errno = %d)", errno); - return -1; - } - return 0; -} - int rte_fslmc_vfio_dmamap(void) { int ret; @@ -368,6 +343,40 @@ fslmc_bus_add_device(struct rte_dpaa2_device *dev) } } +#define IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + sizeof(int)) + +int rte_dpaa2_intr_enable(struct rte_intr_handle *intr_handle, + uint32_t index) +{ + struct vfio_irq_set *irq_set; + char irq_set_buf[IRQ_SET_BUF_LEN]; + int *fd_ptr, fd, ret; + + /* Prepare vfio_irq_set structure and SET the IRQ in VFIO */ + /* Give the eventfd to VFIO */ + fd = eventfd(0, 0); + irq_set = (struct vfio_irq_set *)irq_set_buf; + irq_set->argsz = sizeof(irq_set_buf); + irq_set->count = 1; + irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | + VFIO_IRQ_SET_ACTION_TRIGGER; + irq_set->index = index; + irq_set->start = 0; + fd_ptr = (int *)&irq_set->data; + *fd_ptr = fd; + + ret = ioctl(intr_handle->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set); + if (ret < 0) { + FSLMC_VFIO_LOG(ERR, "Unable to set IRQ in VFIO, ret: %d\n", + ret); + return -1; + } + + /* Set the FD and update the flags */ + intr_handle->fd = fd; + return 0; +} + /* Following function shall fetch total available list of MC devices * from VFIO container & populate private list of devices and other * data structures @@ -517,10 +526,11 @@ int fslmc_vfio_process_group(void) dev->dev_type = (strcmp(object_type, "dpseci")) ? DPAA2_MC_DPNI_DEVID : DPAA2_MC_DPSECI_DEVID; - FSLMC_VFIO_LOG(DEBUG, "DPAA2: Added [%s-%d]", - object_type, object_id); + sprintf(dev->name, "%s.%d", object_type, object_id); + dev->device.name = dev->name; fslmc_bus_add_device(dev); + FSLMC_VFIO_LOG(DEBUG, "DPAA2: Added %s", dev->name); } else { /* Parse all other objects */ struct rte_dpaa2_object *object;