#include <rte_log.h>
#include <rte_bus.h>
#include <rte_memory.h>
-#include <rte_eal_memconfig.h>
#include <rte_common.h>
#include <rte_malloc.h>
#include <rte_bus_vmbus.h>
dev->resource[idx].addr = mapaddr;
vmbus_map_addr = RTE_PTR_ADD(mapaddr, size);
- /* Record result of sucessful mapping for use by secondary */
+ /* Record result of successful mapping for use by secondary */
maps[idx].addr = mapaddr;
maps[idx].size = size;
*ring_size = file_size / 2;
*ring_buf = mapaddr;
- vmbus_map_addr = RTE_PTR_ADD(ring_buf, file_size);
+ vmbus_map_addr = RTE_PTR_ADD(mapaddr, file_size);
return 0;
}
+int
+vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev,
+ const struct vmbus_channel *chan)
+{
+ const struct vmbus_br *br = &chan->txbr;
+ char ring_path[PATH_MAX];
+ void *mapaddr, *ring_buf;
+ uint32_t ring_size;
+ int fd;
+
+ snprintf(ring_path, sizeof(ring_path),
+ "%s/%s/channels/%u/ring",
+ SYSFS_VMBUS_DEVICES, dev->device.name,
+ chan->relid);
+
+ ring_buf = br->vbr;
+ ring_size = br->dsize + sizeof(struct vmbus_bufring);
+ VMBUS_LOG(INFO, "secondary ring_buf %p size %u",
+ ring_buf, ring_size);
+
+ fd = open(ring_path, O_RDWR);
+ if (fd < 0) {
+ VMBUS_LOG(ERR, "Cannot open %s: %s",
+ ring_path, strerror(errno));
+ return -errno;
+ }
+
+ mapaddr = vmbus_map_resource(ring_buf, fd, 0, 2 * ring_size, 0);
+ close(fd);
+
+ if (mapaddr == ring_buf)
+ return 0;
+
+ if (mapaddr == MAP_FAILED)
+ VMBUS_LOG(ERR,
+ "mmap subchan %u in secondary failed", chan->relid);
+ else {
+ VMBUS_LOG(ERR,
+ "mmap subchan %u in secondary address mismatch",
+ chan->relid);
+ vmbus_unmap_resource(mapaddr, 2 * ring_size);
+ }
+ return -1;
+}
+
int vmbus_uio_map_rings(struct vmbus_channel *chan)
{
const struct rte_vmbus_device *dev = chan->device;