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 42FF9A00C4; Tue, 26 Apr 2022 10:33:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E9F9A42827; Tue, 26 Apr 2022 10:32:51 +0200 (CEST) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by mails.dpdk.org (Postfix) with ESMTP id 8795240E09 for ; Sat, 23 Apr 2022 06:30:11 +0200 (CEST) Received: by mail-pl1-f170.google.com with SMTP id h12so11384405plf.12 for ; Fri, 22 Apr 2022 21:30:11 -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=cTyYosyEDZ3ddumbgTfsxZBjypUcxxLo4wkhsxdGx30=; b=X5fXLKmfaOBYbmem1rnRja/PsdK0Au8jZAqsTzQ9vciMDleIAZyGoDfhLmo2V7a7o0 f9g4vIkOmJm+NoePP5n0W9i81qdNjmWul/XnKsTaaRd3KU86mpvKfXkT69ujSOfVl7wX nAfcRXL8etise0fQwMcSoKbGaAnFQmgF5c35o= 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=cTyYosyEDZ3ddumbgTfsxZBjypUcxxLo4wkhsxdGx30=; b=jRxt5mBaXnBDWXTu6NTYlbO3DK4BlsvzF4T6+C9yx9Qbbo2eQVrGTGYPy1qkeYoo4a FwAfXtooTXa7U2Nc10pRnHuQ83QpdFHS/+yaW1vzN3j49NTNPVpSy3MIoX7UzBslLVbP zu1lvCWDSMydQ4Yq0vC9qJcLL+YzoyXRI0jKUndmcdlqi31xQkgvOkRKZizhbYTo4DKM KfkqI9JmuHU96knN692g+8HslQucfoSG+6gJClvwyceBiGMf82wC+IWoEMHxeN8tcAp6 63YhhuQBzYcam2okAzgiPXnx/s1/KHB1C4rLc10TRy7aJifk8n72Be5hhqopsb5N7Gou ee5w== X-Gm-Message-State: AOAM532ZfH93QwwlgV2lKA1TUFWL2X42je413zCuHqG+ECHZGhEb1OVy cYbJHrrI/qN3pVwgPVHxtaFI8Q== X-Google-Smtp-Source: ABdhPJx+fXWN7J+jjk/iwGDIdcVqU3knkMZMWqi2dmHAOoPBBFYEaiavKDfwA9UyIqsu0P2h1aggtw== X-Received: by 2002:a17:90a:4a95:b0:1d8:2918:7065 with SMTP id f21-20020a17090a4a9500b001d829187065mr6876286pjh.117.1650688210746; Fri, 22 Apr 2022 21:30:10 -0700 (PDT) Received: from home-desktop.localdomain ([49.37.158.191]) by smtp.gmail.com with ESMTPSA id g6-20020a17090a714600b001d7f3bb11d7sm4056438pjs.53.2022.04.22.21.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 21:30:10 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v5 08/14] bus/vmbus: add sub-channel mapping support Date: Sat, 23 Apr 2022 09:58:43 +0530 Message-Id: <20220423042849.7718-9-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220423042849.7718-1-srikanth.k@oneconvergence.com> References: <20220418042915.5765-1-srikanth.k@oneconvergence.com> <20220423042849.7718-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 26 Apr 2022 10:32:34 +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 To map the subchannels, an mmap request is directly made after determining the subchan memory offset Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- 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