[v5,09/14] bus/vmbus: open subchannels
Checks
Commit Message
In FreeBSD, unlike Linux there is no sub-channel open callback that
could be called by HV_UIO driver upon their grant by the hypervisor.
Thus the PMD makes an IOCTL to the HV_UIO to open the sub-channels
On Linux, the vmbus_uio_subchan_open() will always return success
as the Linux HV_UIO opens them implicitly.
Signed-off-by: Srikanth Kaka <srikanth.k@oneconvergence.com>
Signed-off-by: Vag Singh <vag.singh@oneconvergence.com>
Signed-off-by: Anand Thulasiram <avelu@juniper.net>
---
drivers/bus/vmbus/freebsd/vmbus_uio.c | 30 ++++++++++++++++++++++++++++++
drivers/bus/vmbus/linux/vmbus_uio.c | 12 ++++++++++++
drivers/bus/vmbus/private.h | 1 +
drivers/bus/vmbus/rte_bus_vmbus.h | 11 +++++++++++
drivers/bus/vmbus/version.map | 6 ++++++
drivers/bus/vmbus/vmbus_channel.c | 5 +++++
6 files changed, 65 insertions(+)
Comments
On Sat, 23 Apr 2022 09:58:44 +0530
Srikanth Kaka <srikanth.k@oneconvergence.com> wrote:
> +/**
> + * Perform IOCTL to VMBUS device
> + *
> + * @param device
> + * A pointer to a rte_vmbus_device structure
> + * @param subchan
> + * Count of subchannels to open
> + */
> +__rte_experimental
> +int rte_vmbus_ioctl(struct rte_vmbus_device *device, uint32_t subchan);
The functionality is good, but have problem with naming.
The word 'ioctl' implies that this is a kernel system call but it is not.
Suggest rte_vmbus_add_channels() as function name instead.
@@ -25,6 +25,9 @@
*/
#define UH_SUBCHAN_MASK_SHIFT 8
+/* ioctl */
+#define HVIOOPENSUBCHAN _IOW('h', 14, uint32_t)
+
const char *driver_name = "hv_uio";
/* Check map names with kernel names */
@@ -151,3 +154,30 @@ const char *get_devname_os(void)
{
return "/dev/hv_uio";
}
+
+int vmbus_uio_subchan_open(struct rte_vmbus_device *dev, uint32_t subchan)
+{
+ struct mapped_vmbus_resource *uio_res;
+ int fd, err = 0;
+
+ uio_res = vmbus_uio_find_resource(dev);
+ if (!uio_res) {
+ VMBUS_LOG(ERR, "cannot find uio resource");
+ return -EINVAL;
+ }
+
+ fd = open(uio_res->path, O_RDWR);
+ if (fd < 0) {
+ VMBUS_LOG(ERR, "Cannot open %s: %s",
+ uio_res->path, strerror(errno));
+ return -1;
+ }
+
+ if (ioctl(fd, HVIOOPENSUBCHAN, &subchan)) {
+ VMBUS_LOG(ERR, "open subchan ioctl failed %s: %s",
+ uio_res->path, strerror(errno));
+ err = -1;
+ }
+ close(fd);
+ return err;
+}
@@ -215,3 +215,15 @@ const char *get_devname_os(void)
{
return "/dev/uio";
}
+
+/*
+ * This is a stub function and it should always succeed.
+ * The Linux UIO kernel driver opens the subchannels implicitly.
+ */
+int vmbus_uio_subchan_open(struct rte_vmbus_device *dev,
+ uint32_t subchan)
+{
+ RTE_SET_USED(dev);
+ RTE_SET_USED(subchan);
+ return 0;
+}
@@ -116,6 +116,7 @@ bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev,
int vmbus_uio_get_subchan(struct vmbus_channel *primary,
struct vmbus_channel **subchan);
int vmbus_uio_map_rings(struct vmbus_channel *chan);
+int vmbus_uio_subchan_open(struct rte_vmbus_device *device, uint32_t subchan);
void vmbus_br_setup(struct vmbus_br *br, void *buf, unsigned int blen);
@@ -404,6 +404,17 @@ void rte_vmbus_set_latency(const struct rte_vmbus_device *dev,
*/
void rte_vmbus_unregister(struct rte_vmbus_driver *driver);
+/**
+ * Perform IOCTL to VMBUS device
+ *
+ * @param device
+ * A pointer to a rte_vmbus_device structure
+ * @param subchan
+ * Count of subchannels to open
+ */
+__rte_experimental
+int rte_vmbus_ioctl(struct rte_vmbus_device *device, uint32_t subchan);
+
/** Helper for VMBUS device registration from driver instance */
#define RTE_PMD_REGISTER_VMBUS(nm, vmbus_drv) \
RTE_INIT(vmbusinitfn_ ##nm) \
@@ -26,3 +26,9 @@ DPDK_22 {
local: *;
};
+
+EXPERIMENTAL {
+ global:
+
+ rte_vmbus_ioctl;
+};
@@ -365,6 +365,11 @@ int rte_vmbus_max_channels(const struct rte_vmbus_device *device)
return 1;
}
+int rte_vmbus_ioctl(struct rte_vmbus_device *device, uint32_t subchan)
+{
+ return vmbus_uio_subchan_open(device, subchan);
+}
+
/* Setup secondary channel */
int rte_vmbus_subchan_open(struct vmbus_channel *primary,
struct vmbus_channel **new_chan)