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 68964A034F; Fri, 8 Oct 2021 12:59:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EAB5241223; Fri, 8 Oct 2021 12:56:44 +0200 (CEST) Received: from mail-pj1-f52.google.com (mail-pj1-f52.google.com [209.85.216.52]) by mails.dpdk.org (Postfix) with ESMTP id E0DBE4067B for ; Fri, 8 Oct 2021 11:17:44 +0200 (CEST) Received: by mail-pj1-f52.google.com with SMTP id ls18-20020a17090b351200b001a00250584aso8507315pjb.4 for ; Fri, 08 Oct 2021 02:17:44 -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:mime-version :content-transfer-encoding; bh=RmSLGUR5kLe35pO5ZkaS/65oexYYSvRxJlRPGswVJXc=; b=V0ZsdFS/v8Hz0nmP+icaUmN6uOJpMOqhcQKHFXdBFhqMvuqilNxBxARBcVDGusQk/k 6+/TJOhqfWSUyivyEi2xcGF/m1SjJjpXdLGDumzgTe/ExsYvYFiZW4lmBuLiZVvzpihj 744QatE0tdr5BT9pJytQgYs1BdS9jG53OFtOU= 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:mime-version :content-transfer-encoding; bh=RmSLGUR5kLe35pO5ZkaS/65oexYYSvRxJlRPGswVJXc=; b=oLrwyqHjsv9rmbE+agbDmesBfUR8ZeByHxK3Cr3ZmaAPpm080VClpWGqHzH0VKl45u xK7PAsJMzsIOP93kF3GM1gr+9IaUVTw1eTqErEct3PyVIS5BI4y4iXUwaIwu+d+c3/Bh cVWc013/tHYdiqVNj/flOXoeDvA5HLkaoPaFc8hSjz/BFrBZ6OKo3EU0aaji5AijzWoK uU6KX9zazi1btJbQWN4jPDioK5+7a5iL4T4dFMsPnw32rIRXt9Z8TgFMOtkeKqfTPbFt TsvlZ2EVEXFGuQJthnXMpz4x0fh/OcIaY3TAeI1ac1WFlK/qa0ZsXcdc6e8QKe8aSOU4 RJbQ== X-Gm-Message-State: AOAM5312PCdnuT891j2qUU9WceEA7zEfLrq9PmKWk9nZwE0T6/5yZYn2 Kx52RsmLvo5SeBfuHjX2bWQTpA== X-Google-Smtp-Source: ABdhPJxefP9UwS1NL6jH01q5XO5lpPlwHz1WDTdxwje0q6MrRISkdvW/BvspnGsahDuOfXJuRMvdTw== X-Received: by 2002:a17:902:e848:b0:13e:f908:155a with SMTP id t8-20020a170902e84800b0013ef908155amr8506394plg.13.1633684663965; Fri, 08 Oct 2021 02:17:43 -0700 (PDT) Received: from srikanth-ThinkPad-T450.domain.name ([122.162.27.38]) by smtp.gmail.com with ESMTPSA id s17sm1943302pge.50.2021.10.08.02.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 02:17:43 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , srikanth-oc Date: Fri, 8 Oct 2021 14:47:32 +0530 Message-Id: <20211008091732.96415-1-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 08 Oct 2021 12:55:54 +0200 Subject: [dpdk-dev] [PATCH v2 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" From: srikanth-oc 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 v2 - Added comment in linux/vmbus_uio.c 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 | 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, 60 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..29e889347a 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -451,3 +451,15 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, closedir(chan_dir); return err; } + +/* + * 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 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 6bcff66468..60c5812706 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 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.1