To map the subchannels, an mmap request is directly made after determining the subchan memory offset
Signed-off-by: Srikanth Kaka <srikant...@oneconvergence.com> Signed-off-by: Vag Singh <vag.si...@oneconvergence.com> Signed-off-by: Anand Thulasiram <av...@juniper.net> --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index 0544371..55b8f18 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -18,6 +18,13 @@ #include "private.h" #include "vmbus_unix.h" +/* + * Macros to distinguish mmap request + * [7-0] - Device memory region + * [15-8]- Sub-channel id + */ +#define UH_SUBCHAN_MASK_SHIFT 8 + const char *driver_name = "hv_uio"; /* Check map names with kernel names */ @@ -99,6 +106,47 @@ int vmbus_get_device_info_os(struct rte_vmbus_device *dev) return sysctl_get_vmbus_device_info(dev); } +int vmbus_uio_map_subchan_os(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan, + void **mapaddr, size_t *size) +{ + char ring_path[PATH_MAX]; + off_t offset; + int fd; + + snprintf(ring_path, sizeof(ring_path), + "/dev/hv_uio%d", dev->uio_num); + + fd = open(ring_path, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + ring_path, strerror(errno)); + return -errno; + } + + /* subchannel rings are of the same size as primary */ + *size = dev->resource[HV_TXRX_RING_MAP].len; + offset = (chan->relid << UH_SUBCHAN_MASK_SHIFT) * PAGE_SIZE; + + *mapaddr = vmbus_map_resource(vmbus_map_addr, fd, + offset, *size, 0); + close(fd); + + if (*mapaddr == MAP_FAILED) + return -EIO; + + return 0; +} + +/* This function should always succeed */ +bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan) +{ + RTE_SET_USED(dev); + RTE_SET_USED(chan); + return true; +} + const char *get_devname_os(void) { return "/dev/hv_uio"; -- 1.8.3.1