From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D0F1A00BE; Tue, 19 Apr 2022 11:34:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20FC942815; Tue, 19 Apr 2022 11:33:48 +0200 (CEST) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id 4976240141 for ; Mon, 18 Apr 2022 06:29:59 +0200 (CEST) Received: by mail-pg1-f177.google.com with SMTP id q19so16755475pgm.6 for ; Sun, 17 Apr 2022 21:29:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2bahx64LuEbChOf1Axjl42rqx1Wa1GVGQEcGvPASvoI=; b=UFRwJLIq2vAZ4L6PP2o0h5gFT9TEcW8stP98xN8spuIytVztyw9TF2vUklRmB740Bu mlzRGslezDj2vTSL8S5VhlTb7ga0ebr9A/PO7JkQBYjxX39obiE+dXK+l7qazeTFmw8T ZlWcwbG48+zF9G86uyQ+gTzpPNd7YE3hyMlFg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2bahx64LuEbChOf1Axjl42rqx1Wa1GVGQEcGvPASvoI=; b=HaxFgrxjXwZwDgduTm0uFeOWUgwsojFy2DQwpKMMUrssfM0vRZLipl0ypTFHFsSnM8 hqg4y0beZ3ONidVG90yJGAL/QJkEYkzlqyAnk969CFX7d2I06xRD7XVGFJzfMhw/Bnzt L0uTuTTMPeuGDshQeMy3g4LGdK0OzqnbgxFL+By6Lc4JteXn3MuTicxY9773H30UOqSs pRuDraHzRRMMMOfutSmBcQgwoeRiylr106MECyufvNWQ8FZgLOmaYqMB/Vif5kE5pQ1y cjrk0YK6YoVLvwWMrPrXWYqDEFQbiOyn8Y3+BFj1gtJLJrhGUSgjypltcClW/S5T1AUg u2fA== X-Gm-Message-State: AOAM53099wIOxYWKn+vO8SahR4A80l64WCMTAIz0Nkt2Re/Bxg0c8cFS FJX/1cGwmplMBbIkzZzkqZl31A== X-Google-Smtp-Source: ABdhPJztMOmEpgYAj+lZiIdx2oo3jxHLoIVo81mkcYGm7P1faPbHiUCYAvyLWswYvJ7yOQ4NuAZzsQ== X-Received: by 2002:a63:f546:0:b0:3aa:878:e29f with SMTP id e6-20020a63f546000000b003aa0878e29fmr1456072pgk.439.1650256198522; Sun, 17 Apr 2022 21:29:58 -0700 (PDT) Received: from srikanth-ThinkPad-T450.. ([49.37.158.191]) by smtp.gmail.com with ESMTPSA id e14-20020aa78c4e000000b00506475da4cesm10377577pfd.49.2022.04.17.21.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:57 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 09/14] bus/vmbus: open subchannels Date: Mon, 18 Apr 2022 09:59:10 +0530 Message-Id: <20220418042915.5765-10-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220418042915.5765-1-srikanth.k@oneconvergence.com> References: <20220217160613.70161-16-srikanth.k@oneconvergence.com> <20220418042915.5765-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 19 Apr 2022 11:33:36 +0200 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- 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 | 10 +++++++++ drivers/bus/vmbus/version.map | 1 + drivers/bus/vmbus/vmbus_channel.c | 5 +++++ 6 files changed, 59 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index 6b43b4349f..7e4e9723cb 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -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; +} diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index 669551a4d4..d88cc97b5b 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -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; +} diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index 1bca147e12..ea0276a6c6 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -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); diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index a24bad831d..c8cb4bc98c 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -404,6 +404,16 @@ void rte_vmbus_chan_dump(FILE *f, const struct vmbus_channel *chan); */ 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 + */ +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) \ diff --git a/drivers/bus/vmbus/version.map b/drivers/bus/vmbus/version.map index 3cadec7fae..3509d4fc14 100644 --- a/drivers/bus/vmbus/version.map +++ b/drivers/bus/vmbus/version.map @@ -23,6 +23,7 @@ DPDK_22 { rte_vmbus_subchan_open; rte_vmbus_unmap_device; rte_vmbus_unregister; + rte_vmbus_ioctl; local: *; }; diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c index 119b9b367e..9a8f6e3eef 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -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) -- 2.30.2