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 E9118A00BE; Tue, 19 Apr 2022 11:34:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4ED0742810; Tue, 19 Apr 2022 11:33:47 +0200 (CEST) Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mails.dpdk.org (Postfix) with ESMTP id 017DF4014F for ; Mon, 18 Apr 2022 06:29:56 +0200 (CEST) Received: by mail-pl1-f173.google.com with SMTP id v12so11455016plv.4 for ; Sun, 17 Apr 2022 21:29:55 -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=R5x7k2zpwCRK8GxBeIbSg5hlSPpjjXyiEqXpYYnZTj0=; b=GGjqX8EtE2H5l/BIODto9NH9VDfhC93ReheMOl6krf4J8mvI+yyCmTxZvQ5w6RYRPZ hFjoAmTlonJRB0eWuurB/DOth7GmfTk/S2RP4EDh7QdBj+TOfja96RNmDnuA079x2i2S AOuDJopCr0vhkcJA58O0L6yYdX++D6O2CuXHo= 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=R5x7k2zpwCRK8GxBeIbSg5hlSPpjjXyiEqXpYYnZTj0=; b=zZSXRwnNeWLe3+BsKZpO3wJNEmhXWD4XBcEHwnVRDVFS4hV4cFp+hP0+QhtNKo990A hEevT+rJ6rVeLAeIzJBHatRQ0WwfR4OPn8xeBqIXcz/vwwNB3tEd2PciVWOfZIK058Im DPPsQjHeU48M1476oGLYLJOU0Qqp0rqA4N51jkY3lrc3FOKIUM4Wg6Z6ItP5K6ndnnHi b7J0RZL+CangCgxsGEPad/W0dDQvgZ/JU9LSyLk74Y4668iqo2jMai1MtX4ol9RdWkk1 wmPkROvEvsbd/3IZDScyF6vaqYwJUKNLEkxbTA/8uyzWbiXHs+mMz8o2CH0gYMWRQlL5 g2Wg== X-Gm-Message-State: AOAM531s84r7ukIGB2KQXNf6Ofnq/vYqYKEe89mtmpZWce8+CQ6j2tTw B6Cqfc1mttQaT5Adma/nMENCfA== X-Google-Smtp-Source: ABdhPJytiGf12QXYIVqLwjUVy2xpeVMOCyYbobhCNjxtUuULBMsP8AjX/c/wwEheSxCdnZ9Sj7rHRg== X-Received: by 2002:a17:902:7789:b0:156:8b5c:606f with SMTP id o9-20020a170902778900b001568b5c606fmr9066267pll.100.1650256195230; Sun, 17 Apr 2022 21:29:55 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:54 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 08/14] bus/vmbus: add sub-channel mapping support Date: Mon, 18 Apr 2022 09:59:09 +0530 Message-Id: <20220418042915.5765-9-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 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 b622388ce9..6b43b4349f 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_osi.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"; -- 2.30.2