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 6FDE8A0C46; Mon, 27 Sep 2021 17:01:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9AA94119B; Mon, 27 Sep 2021 16:58:35 +0200 (CEST) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 71711410DA for ; Mon, 27 Sep 2021 15:43:12 +0200 (CEST) Received: by mail-pl1-f179.google.com with SMTP id j14so11824600plx.4 for ; Mon, 27 Sep 2021 06:43:12 -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=mBf5CDb9YpfOGy+b2QPFCF6Q+KfuH//kPmg7Wt/oTc8=; b=gKrM1GVokz+jZMirKMBpHTS7qJkzI0vLwGBB9B4h0IwRdFdX2vJgCOvGV6TBV2Y9on QLRjytq+5K/uaz2jmsQuNXSk3+ALEXCNlaK79N/mtoA3L8Bi2I9i2NV1ES7P0QXR4j43 Fdw4iLO/sYIcxBbH4at34Nt5ikcxB3ewrQA4U= 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=mBf5CDb9YpfOGy+b2QPFCF6Q+KfuH//kPmg7Wt/oTc8=; b=xDwMqdNthJD9OD5sV4Q2SIBhdgXQcUoExQc/GeCAPGUrWvJVHBWw2CgwoX7OAEutv0 lUjIw0m1l2zeCAs1LmiHPCe98TDhpqy1yINhin3vDZn7tkLnffS10SxuSEE4f/L19P55 HEPrJm8+a44GsMJ0W/DHJArp073iPvHbRe2yhlnUyMVklcLMb6Y0jtCsHL6y9E43QIVs oU0EBW/p3y1WUyMZYJDS7A4qIolpUTjGRMfBIl/4Oe39u1Hllg/F2/1gySBDevgqUlLA 6BqMk5ufXsi5uAMRZrGM+Y1AK5yusWsfitI/TxJSL1Hz0uO+7dhhsou+CnYULLDP8DzU xRvQ== X-Gm-Message-State: AOAM532SsmnkJ3bgdO4Hk7kiSEQFXP3wtUF80BazKnEfgLJUUOXjLkdI Uj1mk/KnOYSRE9fkrc5qPtNh3w== X-Google-Smtp-Source: ABdhPJxPidIUWJaNy+sf/V6un9kLkWzEeSqNuyzwtwlIbc0aZlwEW2LdOC2LfxeVjuOx/cSY7xHLVQ== X-Received: by 2002:a17:902:a70e:b0:13e:1274:c352 with SMTP id w14-20020a170902a70e00b0013e1274c352mr9494plq.58.1632750191664; Mon, 27 Sep 2021 06:43:11 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([223.178.22.200]) by smtp.gmail.com with ESMTPSA id b3sm16960665pfo.23.2021.09.27.06.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 06:43:11 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Date: Mon, 27 Sep 2021 19:12:25 +0530 Message-Id: <20210927134231.11177-6-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210927134231.11177-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Mon, 27 Sep 2021 16:58:07 +0200 Subject: [dpdk-dev] [PATCH 05/11] bus/vmbus: open subchannels 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 Sender: "dev" 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 granted sub-channels Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 31 +++++++++++++++++++++++++++ drivers/bus/vmbus/linux/vmbus_uio.c | 8 +++++++ 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, 56 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index fdd37dac3a..022ac85302 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,9 @@ /** Pathname of VMBUS devices directory. */ #define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" +/* ioctl */ +#define HVIOOPENSUBCHAN _IOW('h', 14, uint32_t) + const char *driver_name = "hv_uio"; static void *vmbus_map_addr; @@ -515,3 +519,30 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, closedir(chan_dir); return err; } + +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 b52ca5bf1d..9e91ed9907 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -451,3 +451,11 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, closedir(chan_dir); return err; } + +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 528d60a42f..968f0b6f23 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -107,6 +107,7 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, int vmbus_uio_map_rings(struct vmbus_channel *chan); int vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev, const 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 4cf73ce815..42d13c5705 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -405,6 +405,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 f67f1c438a..f53a1b6511 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -367,6 +367,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