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 6DBC9A034E; Thu, 17 Feb 2022 17:12:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 97C4F411A7; Thu, 17 Feb 2022 17:11:01 +0100 (CET) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by mails.dpdk.org (Postfix) with ESMTP id 0EFCD40150 for ; Thu, 17 Feb 2022 17:06:57 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id c4so58347pfl.7 for ; Thu, 17 Feb 2022 08:06:56 -0800 (PST) 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=8ktAUWvC1nGJ8OThP8ChjknVgYreQzPuyUwqEmrgZJg=; b=eOdga3X9C0mMk/lce/kyonIX70D1fhWXwuW65te2bbzAKM5j6Mc4K6ssg6FfO/64dH Z6s4QqaqCdvyfa+fYDWspAbF2P7A3xXiKxrl551oKrB0nCVhv2bkZTm/Zt/NgAIl5l06 Eqcfh2XDsUZNu9QjR5cCiOtKUMA5uKaOhPviY= 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=8ktAUWvC1nGJ8OThP8ChjknVgYreQzPuyUwqEmrgZJg=; b=JBvQu+eykdF75ZKDXziafsEVxmoSpiwIlRe722tu+iN1lFciuwKqIszJWNI+At10Rh irk93R3ZtiUUQQ4EKJIrbtxLmddaIHXw39PNEDtQ+jzfXj537i8z8I4rFNyn85NQ9ppc ytuo0PWfxiaJ4bTuxQWug1ewSQd3z19Tqn6BU/6/lA25eeGJ/pY2p2KzVBBlvf5zGpm7 EKpCPcCZlw6Tkj7KAXPBa9xSZXZheLmplAy2lOXWo37zqeiZ3Yh54LI598VwTfVGmAS6 avSLocasAGBshU4H2OuxoHgaS35Q57Mi20dE8aWKXMSBUeF3qujq0Oyw88Bd4FrHlUXx 7Kow== X-Gm-Message-State: AOAM5336f/WIl32LqYIJMgwfjeD3cSP5R37pbPve3ft6dr90cqAiYls2 3kO23mNgfS4jyUTFfbY7TYXdmQ== X-Google-Smtp-Source: ABdhPJyUAzFKmbe4ez8IwiuaDWNtjUvPSVmsNF+LYDlSzCW2i2aiKm958KFPLmDusjJvVqaszwTNxQ== X-Received: by 2002:a63:fe0f:0:b0:342:748e:996f with SMTP id p15-20020a63fe0f000000b00342748e996fmr2987280pgh.164.1645114016237; Thu, 17 Feb 2022 08:06:56 -0800 (PST) Received: from srikanth-ThinkPad-T450.. ([49.37.144.122]) by smtp.gmail.com with ESMTPSA id z14sm47807pfh.173.2022.02.17.08.06.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 08:06:55 -0800 (PST) From: Srikanth Kaka To: sthemmin@microsoft.com, longli@microsoft.com Cc: dev@dpdk.org, vag.singh@oneconvergence.com, avelu@juniper.net, Srikanth Kaka Subject: [PATCH v3 10/15] bus/vmbus: get subchannel info Date: Thu, 17 Feb 2022 21:36:08 +0530 Message-Id: <20220217160613.70161-11-srikanth.k@oneconvergence.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220217160613.70161-1-srikanth.k@oneconvergence.com> References: <20210927134231.11177-1-srikanth.k@oneconvergence.com> <20220217160613.70161-1-srikanth.k@oneconvergence.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Thu, 17 Feb 2022 17:10:51 +0100 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 information is fetched Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 85 +++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index affc0a3f4f..ca6f5fac59 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -308,6 +308,91 @@ bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, return true; } +static bool vmbus_isnew_subchannel(struct vmbus_channel *primary, + uint16_t id) +{ + const struct vmbus_channel *c; + + STAILQ_FOREACH(c, &primary->subchannel_list, next) { + if (c->relid == id) + return false; + } + return true; +} + +int vmbus_uio_get_subchan(struct vmbus_channel *primary, + struct vmbus_channel **subchan) +{ + const struct rte_vmbus_device *dev = primary->device; + char sysctlBuffer[PATH_MAX], sysctlVar[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(sysctlVar, len, "dev.%s.%d.subchan_cnt", driver_name, + dev->uio_num); + sysctl_len = sizeof(nr_schan); + if (sysctlbyname(sysctlVar, &nr_schan, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + strerror(errno)); + return -1; + } + + /* dev.hv_uio.0.channel.14.sub */ + snprintf(sysctlBuffer, len, "dev.%s.%d.channel.%u.sub", driver_name, + dev->uio_num, primary->relid); + for (i = 1; i <= nr_schan; i++) { + /* get relid */ + snprintf(sysctlVar, len, "%s.%u.chanid", sysctlBuffer, i); + sysctl_len = sizeof(relid); + if (sysctlbyname(sysctlVar, &relid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + 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(sysctlVar, len, "%s.%u.ch_subidx", sysctlBuffer, i); + sysctl_len = sizeof(subid); + if (sysctlbyname(sysctlVar, &subid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + strerror(errno)); + goto error; + } + + /* get monitor id */ + snprintf(sysctlVar, len, "%s.%u.monitor_id", sysctlBuffer, i); + sysctl_len = sizeof(monid); + if (sysctlbyname(sysctlVar, &monid, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s : %s", sysctlVar, + 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; -- 2.30.2