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 F12A5A00C4; Tue, 26 Apr 2022 10:34:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FC2142835; Tue, 26 Apr 2022 10:32:54 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by mails.dpdk.org (Postfix) with ESMTP id 26A9B40E09 for ; Sat, 23 Apr 2022 06:30:20 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id s17so15055338plg.9 for ; Fri, 22 Apr 2022 21:30:20 -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=I0Wk461oRId+aoyqibk9l8b64+5KVFa7/vN5pNJXBeA=; b=eY3SY/SncXTt9ucBt0PGp2REwREh7R6MFyLmKgehDrGkiCI7/34GM3HmmMKyoP3wmZ EWwHRVlipQyD2jBZchKl3PAR6AzeQDL5Xweoiz6Oix6tAz8BAq8ir1AQp2g/seN1vovF i2lJqTUYPtPDd6+xf8V10+Srot1NY9dfG1bMo= 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=I0Wk461oRId+aoyqibk9l8b64+5KVFa7/vN5pNJXBeA=; b=AjC2LKLuLuxmqwPLhv6Z+HMAcAzlySTzU+TrRh1POCwh5qF+PT4Q2FGDFJcULzF6ts vSzJOLS66+sK9xv0lqY134JjH1ED7MGt/1DGOeZKanA0pZyEQLzmChl2YChWE/xPBZqW 5JSbuksQmXJTJuhPWuiNaQOpTVhfmLvIA0YL0QdWJJOahhsh1UyCCZyW5iDYj7HLrMgd vXo45HVYV8ntChbC5FNuLgFv7kN4s0IMJN4UnDCGJ5vat527fiugISnWG7I1qSBst60L jYHIWeBCrpIe9EiEbDygYbWtlrBLuXauQwEg2LIYXPxVYQyR7fXl8Zm5g9xPLVez9ShE F36g== X-Gm-Message-State: AOAM533zc5RHInHKQBXEvX2nvkigW6hy8xnILjSDn0eIeSWaNTMSxuen Xo5levFwUyJNQsupcS/w7BVFnpcUj4lPcgOH X-Google-Smtp-Source: ABdhPJzmO90TJoein+lJkY7nNz3d7xukhH5bJ5xMlQlHL36bGrXtR7evVqRUSkyLWX7GoXMZIOzw8A== X-Received: by 2002:a17:90b:4b05:b0:1d2:3d1e:fbfb with SMTP id lx5-20020a17090b4b0500b001d23d1efbfbmr20068038pjb.33.1650688219368; Fri, 22 Apr 2022 21:30:19 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 21:30:18 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v5 11/14] bus/vmbus: get subchannel info Date: Sat, 23 Apr 2022 09:58:46 +0530 Message-Id: <20220423042849.7718-12-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 Using sysctl, all the subchannel's attributes are fetched Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 73 +++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index 438db41..6a9a196 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -155,6 +155,79 @@ const char *get_devname_os(void) return "/dev/hv_uio"; } +int vmbus_uio_get_subchan(struct vmbus_channel *primary, + struct vmbus_channel **subchan) +{ + const struct rte_vmbus_device *dev = primary->device; + char sysctl_buf[PATH_MAX], sysctl_var[PATH_MAX]; + size_t len = PATH_MAX, sysctl_len; + /* nr_schan, relid, subid & monid datatype must match kernel's for sysctl */ + uint32_t relid, subid, nr_schan, i; + uint8_t monid; + int err; + + /* get no. of sub-channels opened by hv_uio + * dev.hv_uio.0.subchan_cnt + */ + snprintf(sysctl_var, len, "dev.%s.%d.subchan_cnt", driver_name, + dev->uio_num); + sysctl_len = sizeof(nr_schan); + if (sysctlbyname(sysctl_var, &nr_schan, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctl_var, + strerror(errno)); + return -1; + } + + /* dev.hv_uio.0.channel.14.sub */ + snprintf(sysctl_buf, len, "dev.%s.%d.channel.%u.sub", driver_name, + dev->uio_num, primary->relid); + for (i = 1; i <= nr_schan; i++) { + /* get relid */ + snprintf(sysctl_var, len, "%s.%u.chanid", sysctl_buf, i); + sysctl_len = sizeof(relid); + if (sysctlbyname(sysctl_var, &relid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctl_var, + strerror(errno)); + goto error; + } + + if (!vmbus_isnew_subchannel(primary, (uint16_t)relid)) { + VMBUS_LOG(DEBUG, "skip already found channel: %u", + relid); + continue; + } + + /* get sub-channel id */ + snprintf(sysctl_var, len, "%s.%u.ch_subidx", sysctl_buf, i); + sysctl_len = sizeof(subid); + if (sysctlbyname(sysctl_var, &subid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctl_var, + strerror(errno)); + goto error; + } + + /* get monitor id */ + snprintf(sysctl_var, len, "%s.%u.monitor_id", sysctl_buf, i); + sysctl_len = sizeof(monid); + if (sysctlbyname(sysctl_var, &monid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctl_var, + strerror(errno)); + goto error; + } + + err = vmbus_chan_create(dev, (uint16_t)relid, (uint16_t)subid, + monid, subchan); + if (err) { + VMBUS_LOG(ERR, "subchannel setup failed"); + return err; + } + break; + } + return 0; +error: + return -1; +} + int vmbus_uio_subchan_open(struct rte_vmbus_device *dev, uint32_t subchan) { struct mapped_vmbus_resource *uio_res; -- 1.8.3.1