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 9A785A00BE; Tue, 19 Apr 2022 11:34:53 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 190994281E; Tue, 19 Apr 2022 11:33:50 +0200 (CEST) Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by mails.dpdk.org (Postfix) with ESMTP id DD95040141 for ; Mon, 18 Apr 2022 06:30:05 +0200 (CEST) Received: by mail-pj1-f67.google.com with SMTP id z6-20020a17090a398600b001cb9fca3210so13070185pjb.1 for ; Sun, 17 Apr 2022 21:30:05 -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=iCcF/h9AMnQ7Lr8jDg1w/+Dd6spdWiWbu4iI2I1T2zg=; b=c/yvts2mzq6YhUU9/BXG9RZ7fjX6GB3tY8CSQh1lI+uIiWnZL16FxgWtxHhLDTNShE A4Qy8lZOyf1SFPHvUpSiyRfj15wTFpKu/ucEKVELVH27yqUnshOFTvpvqo2Yx91MlZIJ Ys5N+Rfs941ReIlPOmK52+QwZpyA3EG5mgOvc= 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=iCcF/h9AMnQ7Lr8jDg1w/+Dd6spdWiWbu4iI2I1T2zg=; b=4IDMzQ/rURXpx6NKe/rCzM2qpx8faVa9SM6/w7j4OBdrDiA6TZiuOCe6dQyfv20X7W s1hvhaUhHohipZs+//cdJehirHwkBikqeZlHfS7Gd+SB95WYGMDc9OBINpZvbLlIUif1 LJvaKp2SDIXRpfikT3zF1bfmR1hAUiLbeHDRK5GMkR/VuT4+ZYTpRI72jXyKHGdYLWjf 5A5nvWW6Hg02hoX3HWjXor4Y4PdnOx2aLMs82IjfVtvfRmSFRNQGoAR2FsZg4n/IAXpl STJb/kZJa/oTQyrfQQ1IIaR7MAx0a/3xoo3zuCx80Qvx3Zs1E9Yrz8un3xIvEVeKm5FL PkxQ== X-Gm-Message-State: AOAM531F6oiLnPitw4gSr2zyi1yeyBxKdgC+cBUETk7UV5AzkrgE4dq+ 0rOkS6OfhGR+q/ra83xX1E1bbQ== X-Google-Smtp-Source: ABdhPJxV/4/uXI4/yxdvA4aC6yv498Dzyy73rEwaJ2n55SeW55nzukO8J/3lP8P+UiB+MqVVduPSWA== X-Received: by 2002:a17:902:7ec1:b0:156:17a4:a2f8 with SMTP id p1-20020a1709027ec100b0015617a4a2f8mr9691867plb.155.1650256205140; Sun, 17 Apr 2022 21:30:05 -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.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:30:04 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 11/14] bus/vmbus: get subchannel info Date: Mon, 18 Apr 2022 09:59:12 +0530 Message-Id: <20220418042915.5765-12-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 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 7e4e9723cb..ecd62b31ca 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 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