From patchwork Mon Apr 18 04:29:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109871 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 40938A00BE; Tue, 19 Apr 2022 11:33:54 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 56624427EF; Tue, 19 Apr 2022 11:33:40 +0200 (CEST) Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by mails.dpdk.org (Postfix) with ESMTP id C738A40141 for ; Mon, 18 Apr 2022 06:29:32 +0200 (CEST) Received: by mail-pg1-f180.google.com with SMTP id q12so16712600pgj.13 for ; Sun, 17 Apr 2022 21:29:32 -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=DQFUKDNTgMLhOQYHYb+JTYczCqQGnkzvszIWgmBk/t8=; b=D9hhLm3UGkydvYFrInPe8CSbUll4KwJJEUIcTVEkETPPOuScQpR9EPy3dUFGDiPLdO dudRLt99KG5HFI1K45mfVyWzFnswU1a7+FBOKDnuGOTsk86E90FKBrNjh83rqho05IEQ YJUbkSNE7cultk857BXimX/d8FXw681RbIqR0= 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=DQFUKDNTgMLhOQYHYb+JTYczCqQGnkzvszIWgmBk/t8=; b=5aCrIiVvYOJ2CPKBMM3awuqoVcqMzxY3NnwYNAuWu588fv5ACEmKTHTDtS2FfMrXkq F5SbKIeGtlneIwuZycL9WWNocMXbKuJz3EgyAIgoF38WGRUdWr8WB5+ymv5qftQxbBf4 8uBg0vwF+v89Z+QlgEM68ceGBB6GX7a2MQchn/+mnUyDlwDtwknT6IRmSIgARKJGJNsl +IqhDXz0XtqVf191yGaq2w8FjJPHvHxb7s0I6HtxbPm4eOmBuNccGivhW7Qp5Ek4tgyZ 8gjSmP8z5m2xKtsDNuqlK3nbBtfmrwCPd+ce0M8qz6vJ+WF5grx8xNnFaCdf6LmH8XYC 4fzA== X-Gm-Message-State: AOAM532JjDFyyiWD4oqgo58D2JH9KVo/I1B5Ny68qIAZXt/Z6XYw8z4E 1nLLP0MyIUKSVkFGQCrLRzi2sA== X-Google-Smtp-Source: ABdhPJxhwtPNgHd8rdvAHrcAdsQscMFRbaN8B+4/KsMx3vMUlHvaeoIYe2ckxVMPSXfPXcF+TPWvhg== X-Received: by 2002:a63:ef06:0:b0:39d:7613:7d38 with SMTP id u6-20020a63ef06000000b0039d76137d38mr8491760pgh.284.1650256172079; Sun, 17 Apr 2022 21:29:32 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:31 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 01/14] bus/vmbus: move independent code from Linux Date: Mon, 18 Apr 2022 09:59:02 +0530 Message-Id: <20220418042915.5765-2-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 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 Move the OS independent code from Linux dir in-order to be used by FreeBSD Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/linux/vmbus_bus.c | 13 +------------ drivers/bus/vmbus/meson.build | 5 +++++ drivers/bus/vmbus/osi/vmbus_osi.h | 11 +++++++++++ drivers/bus/vmbus/osi/vmbus_osi_bus.c | 20 ++++++++++++++++++++ 4 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 drivers/bus/vmbus/osi/vmbus_osi.h create mode 100644 drivers/bus/vmbus/osi/vmbus_osi_bus.c diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c index f502783f7a..c9a07041a7 100644 --- a/drivers/bus/vmbus/linux/vmbus_bus.c +++ b/drivers/bus/vmbus/linux/vmbus_bus.c @@ -21,22 +21,11 @@ #include "eal_filesystem.h" #include "private.h" +#include "vmbus_osi.h" /** Pathname of VMBUS devices directory. */ #define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" -/* - * GUID associated with network devices - * {f8615163-df3e-46c5-913f-f2d2f965ed0e} - */ -static const rte_uuid_t vmbus_nic_uuid = { - 0xf8, 0x61, 0x51, 0x63, - 0xdf, 0x3e, - 0x46, 0xc5, - 0x91, 0x3f, - 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0xe -}; - extern struct rte_vmbus_bus rte_vmbus_bus; /* Read sysfs file to get UUID */ diff --git a/drivers/bus/vmbus/meson.build b/drivers/bus/vmbus/meson.build index 3892cbf67f..cbcba44e16 100644 --- a/drivers/bus/vmbus/meson.build +++ b/drivers/bus/vmbus/meson.build @@ -16,6 +16,11 @@ sources = files( 'vmbus_common_uio.c', ) +includes += include_directories('osi') +sources += files( + 'osi/vmbus_osi_bus.c' +) + if is_linux sources += files('linux/vmbus_bus.c', 'linux/vmbus_uio.c') diff --git a/drivers/bus/vmbus/osi/vmbus_osi.h b/drivers/bus/vmbus/osi/vmbus_osi.h new file mode 100644 index 0000000000..2db9399181 --- /dev/null +++ b/drivers/bus/vmbus/osi/vmbus_osi.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2018, Microsoft Corporation. + * All Rights Reserved. + */ + +#ifndef _VMBUS_BUS_OSI_H_ +#define _VMBUS_BUS_OSI_H_ + +extern const rte_uuid_t vmbus_nic_uuid; + +#endif /* _VMBUS_BUS_OSI_H_ */ diff --git a/drivers/bus/vmbus/osi/vmbus_osi_bus.c b/drivers/bus/vmbus/osi/vmbus_osi_bus.c new file mode 100644 index 0000000000..8437109717 --- /dev/null +++ b/drivers/bus/vmbus/osi/vmbus_osi_bus.c @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2018, Microsoft Corporation. + * All Rights Reserved. + */ + +#include + +#include "vmbus_osi.h" + +/* + * GUID associated with network devices + * {f8615163-df3e-46c5-913f-f2d2f965ed0e} + */ +const rte_uuid_t vmbus_nic_uuid = { + 0xf8, 0x61, 0x51, 0x63, + 0xdf, 0x3e, + 0x46, 0xc5, + 0x91, 0x3f, + 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0xe +}; From patchwork Mon Apr 18 04:29:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109872 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AB803A00BE; Tue, 19 Apr 2022 11:33:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43139427F4; Tue, 19 Apr 2022 11:33:41 +0200 (CEST) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by mails.dpdk.org (Postfix) with ESMTP id 1888B4014F for ; Mon, 18 Apr 2022 06:29:36 +0200 (CEST) Received: by mail-pg1-f170.google.com with SMTP id r66so16763309pgr.3 for ; Sun, 17 Apr 2022 21:29:36 -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=r8nQ7ld2dbhKum0HvJbDZVZP0JIBHlA/R6YrvZw2SzM=; b=LR+tQwhC4JmCV2avGoJ6IZEz8twN4NGVv2ViLllO2rDoMEeOSEd7uCjKnTls75gj21 NhQEZz5FFBnLGSXT6dnqLVWmoHztwTFnT00jPdQSku4mf4Z5z8ESmFsOammsN5fL/pGn 8FxPfK5iw8j5vgIX2lTwKllb+aLAcydT9FWF0= 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=r8nQ7ld2dbhKum0HvJbDZVZP0JIBHlA/R6YrvZw2SzM=; b=vBO17vnEJOJf0w+u97Pw03Osds3vMVJyUmxLKdpavTgG5qqCh74LIWyMRL0qTEOa8Y 09nYFxPxUSY5AYUuKeuDyxBmlYX45ITNs6jTqlLFkEUUHTAa3wnVBKIxEVKU+TL92+M7 wgVdYhYqVHzyZm/l0FRdUyuWp6KhYRQdsYO1pQJg/sD4O4cD1Z4FGkVV2/zl2gUZiFZn QCPQ+m8BCLP6OTRPdZkr0A2iCXaupNGfmAeMPjUdgq+VBtEFyP3Zcyo/74mkWPPpsg+k 8A2kOH9J0bWzopVQGe+805ouPqx2/0b9S8y3hzGHZXVKvf+aXZd6To/1iPlZACh7WEl/ 9kQQ== X-Gm-Message-State: AOAM531D7FRq1H3yZW5Z9c0vxpa15B+zPT/LgbNPEQUdrK3bYzVWTPNH Ca2QOzL0zNYoVimBMI0yGxP5QJOaErcm0I4E X-Google-Smtp-Source: ABdhPJwKZjLpX1Zz2WVwGCXRhrPhSzX529JnGGxyDZSnV3GyVFX5yDn7ZHsdiouBMmBcWifIL2v+Wg== X-Received: by 2002:aa7:9041:0:b0:4fe:3d6c:1739 with SMTP id n1-20020aa79041000000b004fe3d6c1739mr10301735pfo.13.1650256175337; Sun, 17 Apr 2022 21:29:35 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:34 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 02/14] bus/vmbus: move independent bus functions Date: Mon, 18 Apr 2022 09:59:03 +0530 Message-Id: <20220418042915.5765-3-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 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 move independent Linux bus functions to OSI file Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/linux/vmbus_bus.c | 15 --------------- drivers/bus/vmbus/osi/vmbus_osi_bus.c | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c index c9a07041a7..030f18020e 100644 --- a/drivers/bus/vmbus/linux/vmbus_bus.c +++ b/drivers/bus/vmbus/linux/vmbus_bus.c @@ -358,18 +358,3 @@ rte_vmbus_scan(void) closedir(dir); return -1; } - -void rte_vmbus_irq_mask(struct rte_vmbus_device *device) -{ - vmbus_uio_irq_control(device, 1); -} - -void rte_vmbus_irq_unmask(struct rte_vmbus_device *device) -{ - vmbus_uio_irq_control(device, 0); -} - -int rte_vmbus_irq_read(struct rte_vmbus_device *device) -{ - return vmbus_uio_irq_read(device); -} diff --git a/drivers/bus/vmbus/osi/vmbus_osi_bus.c b/drivers/bus/vmbus/osi/vmbus_osi_bus.c index 8437109717..4aaa5459a8 100644 --- a/drivers/bus/vmbus/osi/vmbus_osi_bus.c +++ b/drivers/bus/vmbus/osi/vmbus_osi_bus.c @@ -3,8 +3,10 @@ * All Rights Reserved. */ +#include #include +#include "private.h" #include "vmbus_osi.h" /* @@ -18,3 +20,18 @@ const rte_uuid_t vmbus_nic_uuid = { 0x91, 0x3f, 0xf2, 0xd2, 0xf9, 0x65, 0xed, 0xe }; + +void rte_vmbus_irq_mask(struct rte_vmbus_device *device) +{ + vmbus_uio_irq_control(device, 1); +} + +void rte_vmbus_irq_unmask(struct rte_vmbus_device *device) +{ + vmbus_uio_irq_control(device, 0); +} + +int rte_vmbus_irq_read(struct rte_vmbus_device *device) +{ + return vmbus_uio_irq_read(device); +} From patchwork Mon Apr 18 04:29:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109873 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 47817A00BE; Tue, 19 Apr 2022 11:34:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 328CC427F9; Tue, 19 Apr 2022 11:33:42 +0200 (CEST) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by mails.dpdk.org (Postfix) with ESMTP id 2752B40141 for ; Mon, 18 Apr 2022 06:29:40 +0200 (CEST) Received: by mail-pj1-f68.google.com with SMTP id h15-20020a17090a054f00b001cb7cd2b11dso13031482pjf.5 for ; Sun, 17 Apr 2022 21:29:40 -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=8+RWzaA3MUIkhoYz6xAcNAUxsbBzPp7jA3/JMxvjClk=; b=Pw7/e8ffMB4oRkrQ3dflK6ics39hoRwBSpgT02b2wMOhntpoU9maSTvldocI5j6W8K LnMrTwy99DBKfIXYhzxuO3NRlLwnXtP7OFI7AWUpRjF2dMC51sZiD8OdUNox9tD+uaox EWAEqU9/PUTlTK63+1HYMGF2iOoYYWGDYgxXo= 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=8+RWzaA3MUIkhoYz6xAcNAUxsbBzPp7jA3/JMxvjClk=; b=SorM1wDkjGuVHxeEcRs8mH+ArEWO3ICWtcW3+Choe9ei+t12rQZrBI4uS76Xx50NH4 l8mdoJ+e3GUYNCwQ04KDk5sh8y7qs1Fvfqfd01u1YnlNQ5MHHCHJA6peLplDpo/IV/RJ R3NotHC4OPkSxk5jqjGvGoBj47BAefB0ubxOf9gREEpvfkRnULfNpKcQTjKi2xi97+dO h27Ckw/eino4EmxXYu53zm5acJIxTV6kXBmqd+SIkDnDmE2LDxithzZ+DQRI1mub1Npr MDeHyyJ8EP2clAUweWjlaEVL2IrvwaqdS4U8gmxGfDy6fJt1YjxeSy95vvwLkzDTYniI Q+dA== X-Gm-Message-State: AOAM53321UYJkajCZCs9fWBnFavgw/QhnF8qTdeybbw7gy1Hwn6v5n3p x7Esrb2OO8somXm5hhH6E8aMkA== X-Google-Smtp-Source: ABdhPJxiPkhkl1KDWTNJNUMgdwACMmAOuyRKMgqWhKBCypxBmHoAdETckGWLknmtEs6tGurPZU5awQ== X-Received: by 2002:a17:902:b941:b0:14d:af72:3f23 with SMTP id h1-20020a170902b94100b0014daf723f23mr9495513pls.6.1650256179324; Sun, 17 Apr 2022 21:29:39 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:38 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 03/14] bus/vmbus: move OS independent UIO functions Date: Mon, 18 Apr 2022 09:59:04 +0530 Message-Id: <20220418042915.5765-4-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 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 Moved all Linux independent UIO functions to OSI dir. Split the vmbus_uio_map_subchan() by keeping OS dependent code in vmbus_uio_map_subchan_os() function Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/linux/vmbus_uio.c | 292 +----------------------- drivers/bus/vmbus/meson.build | 3 +- drivers/bus/vmbus/osi/vmbus_osi.h | 12 + drivers/bus/vmbus/osi/vmbus_osi_uio.c | 306 ++++++++++++++++++++++++++ 4 files changed, 330 insertions(+), 283 deletions(-) create mode 100644 drivers/bus/vmbus/osi/vmbus_osi_uio.c diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index 5db70f8e0d..ea6df21409 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -21,233 +21,18 @@ #include #include "private.h" +#include "vmbus_osi.h" /** Pathname of VMBUS devices directory. */ #define SYSFS_VMBUS_DEVICES "/sys/bus/vmbus/devices" -static void *vmbus_map_addr; - -/* Control interrupts */ -void vmbus_uio_irq_control(struct rte_vmbus_device *dev, int32_t onoff) -{ - if ((rte_intr_fd_get(dev->intr_handle) < 0) || - write(rte_intr_fd_get(dev->intr_handle), &onoff, - sizeof(onoff)) < 0) { - VMBUS_LOG(ERR, "cannot write to %d:%s", - rte_intr_fd_get(dev->intr_handle), - strerror(errno)); - } -} - -int vmbus_uio_irq_read(struct rte_vmbus_device *dev) -{ - int32_t count; - int cc; - - if (rte_intr_fd_get(dev->intr_handle) < 0) - return -1; - - cc = read(rte_intr_fd_get(dev->intr_handle), &count, - sizeof(count)); - if (cc < (int)sizeof(count)) { - if (cc < 0) { - VMBUS_LOG(ERR, "IRQ read failed %s", - strerror(errno)); - return -errno; - } - VMBUS_LOG(ERR, "can't read IRQ count"); - return -EINVAL; - } - - return count; -} - -void -vmbus_uio_free_resource(struct rte_vmbus_device *dev, - struct mapped_vmbus_resource *uio_res) -{ - rte_free(uio_res); - - if (rte_intr_dev_fd_get(dev->intr_handle) >= 0) { - close(rte_intr_dev_fd_get(dev->intr_handle)); - rte_intr_dev_fd_set(dev->intr_handle, -1); - } - - if (rte_intr_fd_get(dev->intr_handle) >= 0) { - close(rte_intr_fd_get(dev->intr_handle)); - rte_intr_fd_set(dev->intr_handle, -1); - rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UNKNOWN); - } -} - -int -vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, - struct mapped_vmbus_resource **uio_res) -{ - char devname[PATH_MAX]; /* contains the /dev/uioX */ - int fd; - - /* save fd if in primary process */ - snprintf(devname, sizeof(devname), "/dev/uio%u", dev->uio_num); - fd = open(devname, O_RDWR); - if (fd < 0) { - VMBUS_LOG(ERR, "Cannot open %s: %s", - devname, strerror(errno)); - goto error; - } - - if (rte_intr_fd_set(dev->intr_handle, fd)) - goto error; - - if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UIO_INTX)) - goto error; - - /* allocate the mapping details for secondary processes*/ - *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0); - if (*uio_res == NULL) { - VMBUS_LOG(ERR, "cannot store uio mmap details"); - goto error; - } - - strlcpy((*uio_res)->path, devname, PATH_MAX); - rte_uuid_copy((*uio_res)->id, dev->device_id); - - return 0; - -error: - vmbus_uio_free_resource(dev, *uio_res); - return -1; -} - -static int -find_max_end_va(const struct rte_memseg_list *msl, void *arg) -{ - size_t sz = msl->memseg_arr.len * msl->page_sz; - void *end_va = RTE_PTR_ADD(msl->base_va, sz); - void **max_va = arg; - - if (*max_va < end_va) - *max_va = end_va; - return 0; -} - -/* - * TODO: this should be part of memseg api. - * code is duplicated from PCI. - */ -static void * -vmbus_find_max_end_va(void) -{ - void *va = NULL; - - rte_memseg_list_walk(find_max_end_va, &va); - return va; -} - -int -vmbus_uio_map_resource_by_index(struct rte_vmbus_device *dev, int idx, - struct mapped_vmbus_resource *uio_res, - int flags) -{ - size_t size = dev->resource[idx].len; - struct vmbus_map *maps = uio_res->maps; - void *mapaddr; - off_t offset; - int fd; - - /* devname for mmap */ - fd = open(uio_res->path, O_RDWR); - if (fd < 0) { - VMBUS_LOG(ERR, "Cannot open %s: %s", - uio_res->path, strerror(errno)); - return -1; - } - - /* try mapping somewhere close to the end of hugepages */ - if (vmbus_map_addr == NULL) - vmbus_map_addr = vmbus_find_max_end_va(); - - /* offset is special in uio it indicates which resource */ - offset = idx * rte_mem_page_size(); - - mapaddr = vmbus_map_resource(vmbus_map_addr, fd, offset, size, flags); - close(fd); - - if (mapaddr == MAP_FAILED) - return -1; - - dev->resource[idx].addr = mapaddr; - vmbus_map_addr = RTE_PTR_ADD(mapaddr, size); - - /* Record result of successful mapping for use by secondary */ - maps[idx].addr = mapaddr; - maps[idx].size = size; - - return 0; -} - -static int vmbus_uio_map_primary(struct vmbus_channel *chan, - void **ring_buf, uint32_t *ring_size) -{ - struct mapped_vmbus_resource *uio_res; - - uio_res = vmbus_uio_find_resource(chan->device); - if (!uio_res) { - VMBUS_LOG(ERR, "can not find resources!"); - return -ENOMEM; - } - - if (uio_res->nb_maps < VMBUS_MAX_RESOURCE) { - VMBUS_LOG(ERR, "VMBUS: only %u resources found!", - uio_res->nb_maps); - return -EINVAL; - } - - *ring_size = uio_res->maps[HV_TXRX_RING_MAP].size / 2; - *ring_buf = uio_res->maps[HV_TXRX_RING_MAP].addr; - return 0; -} - -static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, - const struct vmbus_channel *chan, - void **ring_buf, uint32_t *ring_size) +int vmbus_uio_map_subchan_os(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan, + void **mapaddr, size_t *file_size) { char ring_path[PATH_MAX]; - size_t file_size; struct stat sb; - void *mapaddr; int fd; - struct mapped_vmbus_resource *uio_res; - int channel_idx; - - uio_res = vmbus_uio_find_resource(dev); - if (!uio_res) { - VMBUS_LOG(ERR, "can not find resources for mapping subchan"); - return -ENOMEM; - } - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - if (uio_res->nb_subchannels >= UIO_MAX_SUBCHANNEL) { - VMBUS_LOG(ERR, - "exceeding max subchannels UIO_MAX_SUBCHANNEL(%d)", - UIO_MAX_SUBCHANNEL); - VMBUS_LOG(ERR, "Change UIO_MAX_SUBCHANNEL and recompile"); - return -ENOMEM; - } - } else { - for (channel_idx = 0; channel_idx < uio_res->nb_subchannels; - channel_idx++) - if (uio_res->subchannel_maps[channel_idx].relid == - chan->relid) - break; - if (channel_idx == uio_res->nb_subchannels) { - VMBUS_LOG(ERR, - "couldn't find sub channel %d from shared mapping in primary", - chan->relid); - return -ENOMEM; - } - vmbus_map_addr = uio_res->subchannel_maps[channel_idx].addr; - } snprintf(ring_path, sizeof(ring_path), "%s/%s/channels/%u/ring", @@ -267,68 +52,23 @@ static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, close(fd); return -errno; } - file_size = sb.st_size; + *file_size = sb.st_size; - if (file_size == 0 || (file_size & (rte_mem_page_size() - 1))) { + if (*file_size == 0 || (*file_size & (rte_mem_page_size() - 1))) { VMBUS_LOG(ERR, "incorrect size %s: %zu", - ring_path, file_size); + ring_path, *file_size); close(fd); return -EINVAL; } - mapaddr = vmbus_map_resource(vmbus_map_addr, fd, - 0, file_size, 0); + *mapaddr = vmbus_map_resource(vmbus_map_addr, fd, + 0, *file_size, 0); close(fd); - if (mapaddr == MAP_FAILED) + if (*mapaddr == MAP_FAILED) return -EIO; - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - - /* Add this mapping to uio_res for use by secondary */ - uio_res->subchannel_maps[uio_res->nb_subchannels].relid = - chan->relid; - uio_res->subchannel_maps[uio_res->nb_subchannels].addr = - mapaddr; - uio_res->subchannel_maps[uio_res->nb_subchannels].size = - file_size; - uio_res->nb_subchannels++; - - vmbus_map_addr = RTE_PTR_ADD(mapaddr, file_size); - } else { - if (mapaddr != vmbus_map_addr) { - VMBUS_LOG(ERR, "failed to map channel %d to addr %p", - chan->relid, mapaddr); - vmbus_unmap_resource(mapaddr, file_size); - return -EIO; - } - } - - *ring_size = file_size / 2; - *ring_buf = mapaddr; - - return 0; -} - -int vmbus_uio_map_rings(struct vmbus_channel *chan) -{ - const struct rte_vmbus_device *dev = chan->device; - uint32_t ring_size; - void *ring_buf; - int ret; - - /* Primary channel */ - if (chan->subchannel_id == 0) - ret = vmbus_uio_map_primary(chan, &ring_buf, &ring_size); - else - ret = vmbus_uio_map_subchan(dev, chan, &ring_buf, &ring_size); - - if (ret) - return ret; - - vmbus_br_setup(&chan->txbr, ring_buf, ring_size); - vmbus_br_setup(&chan->rxbr, (char *)ring_buf + ring_size, ring_size); return 0; } @@ -377,18 +117,6 @@ bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, return vmbus_uio_ring_present(dev, chan->relid); } -static bool vmbus_isnew_subchannel(struct vmbus_channel *primary, - unsigned long 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) { diff --git a/drivers/bus/vmbus/meson.build b/drivers/bus/vmbus/meson.build index cbcba44e16..fe9c72bce1 100644 --- a/drivers/bus/vmbus/meson.build +++ b/drivers/bus/vmbus/meson.build @@ -18,7 +18,8 @@ sources = files( includes += include_directories('osi') sources += files( - 'osi/vmbus_osi_bus.c' + 'osi/vmbus_osi_bus.c', + 'osi/vmbus_osi_uio.c' ) if is_linux diff --git a/drivers/bus/vmbus/osi/vmbus_osi.h b/drivers/bus/vmbus/osi/vmbus_osi.h index 2db9399181..579c4bb99c 100644 --- a/drivers/bus/vmbus/osi/vmbus_osi.h +++ b/drivers/bus/vmbus/osi/vmbus_osi.h @@ -6,6 +6,18 @@ #ifndef _VMBUS_BUS_OSI_H_ #define _VMBUS_BUS_OSI_H_ +#include + +#include "private.h" + extern const rte_uuid_t vmbus_nic_uuid; +extern void *vmbus_map_addr; + +int vmbus_uio_map_subchan_os(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan, + void **mapaddr, size_t *file_size); + +bool vmbus_isnew_subchannel(struct vmbus_channel *primary, + unsigned long id); #endif /* _VMBUS_BUS_OSI_H_ */ diff --git a/drivers/bus/vmbus/osi/vmbus_osi_uio.c b/drivers/bus/vmbus/osi/vmbus_osi_uio.c new file mode 100644 index 0000000000..35106e247e --- /dev/null +++ b/drivers/bus/vmbus/osi/vmbus_osi_uio.c @@ -0,0 +1,306 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2018, Microsoft Corporation. + * All Rights Reserved. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "private.h" +#include "vmbus_osi.h" + +void *vmbus_map_addr; + +/* Control interrupts */ +void vmbus_uio_irq_control(struct rte_vmbus_device *dev, int32_t onoff) +{ + if ((rte_intr_fd_get(dev->intr_handle) < 0) || + write(rte_intr_fd_get(dev->intr_handle), &onoff, + sizeof(onoff)) < 0) { + VMBUS_LOG(ERR, "cannot write to %d:%s", + rte_intr_fd_get(dev->intr_handle), + strerror(errno)); + } +} + +int vmbus_uio_irq_read(struct rte_vmbus_device *dev) +{ + int32_t count; + int cc; + + if (rte_intr_fd_get(dev->intr_handle) < 0) + return -1; + + cc = read(rte_intr_fd_get(dev->intr_handle), &count, + sizeof(count)); + if (cc < (int)sizeof(count)) { + if (cc < 0) { + VMBUS_LOG(ERR, "IRQ read failed %s", + strerror(errno)); + return -errno; + } + VMBUS_LOG(ERR, "can't read IRQ count"); + return -EINVAL; + } + + return count; +} + +void +vmbus_uio_free_resource(struct rte_vmbus_device *dev, + struct mapped_vmbus_resource *uio_res) +{ + rte_free(uio_res); + + if (rte_intr_dev_fd_get(dev->intr_handle) >= 0) { + close(rte_intr_dev_fd_get(dev->intr_handle)); + rte_intr_dev_fd_set(dev->intr_handle, -1); + } + + if (rte_intr_fd_get(dev->intr_handle) >= 0) { + close(rte_intr_fd_get(dev->intr_handle)); + rte_intr_fd_set(dev->intr_handle, -1); + rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UNKNOWN); + } +} + +int +vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, + struct mapped_vmbus_resource **uio_res) +{ + char devname[PATH_MAX]; /* contains the /dev/uioX */ + int fd; + + /* save fd if in primary process */ + snprintf(devname, sizeof(devname), "/dev/uio%u", dev->uio_num); + fd = open(devname, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + devname, strerror(errno)); + goto error; + } + + if (rte_intr_fd_set(dev->intr_handle, fd)) + goto error; + + if (rte_intr_type_set(dev->intr_handle, RTE_INTR_HANDLE_UIO_INTX)) + goto error; + + /* allocate the mapping details for secondary processes*/ + *uio_res = rte_zmalloc("UIO_RES", sizeof(**uio_res), 0); + if (*uio_res == NULL) { + VMBUS_LOG(ERR, "cannot store uio mmap details"); + goto error; + } + + strlcpy((*uio_res)->path, devname, PATH_MAX); + rte_uuid_copy((*uio_res)->id, dev->device_id); + + return 0; + +error: + vmbus_uio_free_resource(dev, *uio_res); + return -1; +} + +static int +find_max_end_va(const struct rte_memseg_list *msl, void *arg) +{ + size_t sz = msl->memseg_arr.len * msl->page_sz; + void *end_va = RTE_PTR_ADD(msl->base_va, sz); + void **max_va = arg; + + if (*max_va < end_va) + *max_va = end_va; + return 0; +} + +/* + * TODO: this should be part of memseg api. + * code is duplicated from PCI. + */ +static void * +vmbus_find_max_end_va(void) +{ + void *va = NULL; + + rte_memseg_list_walk(find_max_end_va, &va); + return va; +} + +int +vmbus_uio_map_resource_by_index(struct rte_vmbus_device *dev, int idx, + struct mapped_vmbus_resource *uio_res, + int flags) +{ + size_t size = dev->resource[idx].len; + struct vmbus_map *maps = uio_res->maps; + void *mapaddr; + off_t offset; + int fd; + + /* devname for mmap */ + fd = open(uio_res->path, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + uio_res->path, strerror(errno)); + return -1; + } + + /* try mapping somewhere close to the end of hugepages */ + if (vmbus_map_addr == NULL) + vmbus_map_addr = vmbus_find_max_end_va(); + + /* offset is special in uio it indicates which resource */ + offset = idx * rte_mem_page_size(); + + mapaddr = vmbus_map_resource(vmbus_map_addr, fd, offset, size, flags); + close(fd); + + if (mapaddr == MAP_FAILED) + return -1; + + dev->resource[idx].addr = mapaddr; + vmbus_map_addr = RTE_PTR_ADD(mapaddr, size); + + /* Record result of successful mapping for use by secondary */ + maps[idx].addr = mapaddr; + maps[idx].size = size; + + return 0; +} + +static int vmbus_uio_map_primary(struct vmbus_channel *chan, + void **ring_buf, uint32_t *ring_size) +{ + struct mapped_vmbus_resource *uio_res; + + uio_res = vmbus_uio_find_resource(chan->device); + if (!uio_res) { + VMBUS_LOG(ERR, "can not find resources!"); + return -ENOMEM; + } + + if (uio_res->nb_maps < VMBUS_MAX_RESOURCE) { + VMBUS_LOG(ERR, "VMBUS: only %u resources found!", + uio_res->nb_maps); + return -EINVAL; + } + + *ring_size = uio_res->maps[HV_TXRX_RING_MAP].size / 2; + *ring_buf = uio_res->maps[HV_TXRX_RING_MAP].addr; + return 0; +} + +static int vmbus_uio_map_subchan(const struct rte_vmbus_device *dev, + const struct vmbus_channel *chan, + void **ring_buf, uint32_t *ring_size) +{ + size_t file_size = 0; + void *mapaddr = NULL; + struct mapped_vmbus_resource *uio_res; + int channel_idx; + int ret; + + uio_res = vmbus_uio_find_resource(dev); + if (!uio_res) { + VMBUS_LOG(ERR, "can not find resources for mapping subchan"); + return -ENOMEM; + } + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + if (uio_res->nb_subchannels >= UIO_MAX_SUBCHANNEL) { + VMBUS_LOG(ERR, + "exceeding max subchannels UIO_MAX_SUBCHANNEL(%d)", + UIO_MAX_SUBCHANNEL); + VMBUS_LOG(ERR, "Change UIO_MAX_SUBCHANNEL and recompile"); + return -ENOMEM; + } + } else { + for (channel_idx = 0; channel_idx < uio_res->nb_subchannels; + channel_idx++) + if (uio_res->subchannel_maps[channel_idx].relid == + chan->relid) + break; + if (channel_idx == uio_res->nb_subchannels) { + VMBUS_LOG(ERR, + "couldn't find sub channel %d from shared mapping in primary", + chan->relid); + return -ENOMEM; + } + vmbus_map_addr = uio_res->subchannel_maps[channel_idx].addr; + } + + ret = vmbus_uio_map_subchan_os(dev, chan, &mapaddr, &file_size); + if (ret) + return ret; + + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + + /* Add this mapping to uio_res for use by secondary */ + uio_res->subchannel_maps[uio_res->nb_subchannels].relid = + chan->relid; + uio_res->subchannel_maps[uio_res->nb_subchannels].addr = + mapaddr; + uio_res->subchannel_maps[uio_res->nb_subchannels].size = + file_size; + uio_res->nb_subchannels++; + + vmbus_map_addr = RTE_PTR_ADD(mapaddr, file_size); + } else { + if (mapaddr != vmbus_map_addr) { + VMBUS_LOG(ERR, "failed to map channel %d to addr %p", + chan->relid, mapaddr); + vmbus_unmap_resource(mapaddr, file_size); + return -EIO; + } + } + + *ring_size = file_size / 2; + *ring_buf = mapaddr; + + return 0; +} + +int vmbus_uio_map_rings(struct vmbus_channel *chan) +{ + const struct rte_vmbus_device *dev = chan->device; + uint32_t ring_size = 0; + void *ring_buf = NULL; + int ret; + + /* Primary channel */ + if (chan->subchannel_id == 0) + ret = vmbus_uio_map_primary(chan, &ring_buf, &ring_size); + else + ret = vmbus_uio_map_subchan(dev, chan, &ring_buf, &ring_size); + + if (ret) + return ret; + + vmbus_br_setup(&chan->txbr, ring_buf, ring_size); + vmbus_br_setup(&chan->rxbr, (char *)ring_buf + ring_size, ring_size); + return 0; +} + +bool vmbus_isnew_subchannel(struct vmbus_channel *primary, + unsigned long id) +{ + const struct vmbus_channel *c; + + STAILQ_FOREACH(c, &primary->subchannel_list, next) { + if (c->relid == id) + return false; + } + return true; +} From patchwork Mon Apr 18 04:29:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109874 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B6155A00BE; Tue, 19 Apr 2022 11:34:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 24F83427FF; Tue, 19 Apr 2022 11:33:43 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by mails.dpdk.org (Postfix) with ESMTP id 8E9C240141 for ; Mon, 18 Apr 2022 06:29:43 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id q12so16713233pgj.13 for ; Sun, 17 Apr 2022 21:29:43 -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=xS6VZIa3z4/BbPEz3tVcaGwmkSoCiE6gUuwWRZ0icOI=; b=WyNkQz+/AvJRg5jJ9x1wBgX0o+nWlo3FLByAp0YFkLXc4zSgbSChyMNcLSc7hhN8UM F6vRwKHd97CQ81d8r8YI35qxbtqn6bBJsdbLXNlUwn2EgjW4owTIJaJbHSrxJxNg1i5q /uUU1f+YSav42Q1q46YcxxPaOL9J4RZaA41jc= 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=xS6VZIa3z4/BbPEz3tVcaGwmkSoCiE6gUuwWRZ0icOI=; b=tj3lgVykPP/5vMnEEj0XjeyCcQHMjbANdveZYQgmDXvcDk/C1AkOL6eDY7Jr9ZqTt0 a1hsVuus16VURAeZox7oPD/ZRuOszqnfX2e640DeRnvqkbfrTnFUV4Lc+A103KPp3nmZ W0EPWyQiHjA7UdC4rhy3r2Y4DFN+FdmSep7iiSlU0vPvur7RwDdiUhvY66Ermo4164w+ ibqQqqDWktL3YxNozvMgYTemPFdjCsrRk/MZxUQImZmEJL0C3+w6VFxzUAh1KhFMXORT HOAXnCmMhhr9vL8mE+/4V/FxHlvBgjiSHJy3qVYKwnG3m2KIzf0LS2EmIPP7y2rDx7ig WoFg== X-Gm-Message-State: AOAM5311JrBcb2ZoWeTgLIqI4EMXbZn9r0XHxnkJNWPfKBK1jhwIcwQh E6uqAPVVyZpJh5KRWozt97ByXA== X-Google-Smtp-Source: ABdhPJyKq+SlP+0Zi/JL8mp7jwlIt+KA3VkTcOqlR20tEEgeKM1ZmB7eBrMniul4V/Wd3OciR/CGYA== X-Received: by 2002:a63:492:0:b0:39d:adac:638b with SMTP id 140-20020a630492000000b0039dadac638bmr8423010pge.314.1650256182750; Sun, 17 Apr 2022 21:29:42 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:41 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 04/14] bus/vmbus: scan and get the network device on FreeBSD Date: Mon, 18 Apr 2022 09:59:05 +0530 Message-Id: <20220418042915.5765-5-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 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 devices on the VMBUS are identified by the PMD. On finding the Network device's device id, it is added to VMBUS dev list. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_bus.c | 268 ++++++++++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 drivers/bus/vmbus/freebsd/vmbus_bus.c diff --git a/drivers/bus/vmbus/freebsd/vmbus_bus.c b/drivers/bus/vmbus/freebsd/vmbus_bus.c new file mode 100644 index 0000000000..8cf3bc5a6a --- /dev/null +++ b/drivers/bus/vmbus/freebsd/vmbus_bus.c @@ -0,0 +1,268 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2018, Microsoft Corporation. + * All Rights Reserved. + */ + +#include +#include + +#include "private.h" +#include "vmbus_osi.h" + +#include +#include +#include + +/* Parse UUID. Caller must pass NULL terminated string */ +static int +parse_sysfs_uuid(const char *filename, rte_uuid_t uu) +{ + char in[BUFSIZ]; + + memcpy(in, filename, BUFSIZ); + if (rte_uuid_parse(in, uu) < 0) { + VMBUS_LOG(ERR, "%s not a valid UUID", in); + return -1; + } + + return 0; +} + +/* Scan one vmbus entry, and fill the devices list from it. */ +static int +vmbus_scan_one(const char *name, unsigned int unit_num) +{ + struct rte_vmbus_device *dev, *dev2; + char sysctlBuffer[PATH_MAX], sysctlVar[PATH_MAX]; + size_t guid_len = 36, len = PATH_MAX; + char classid[guid_len + 1], deviceid[guid_len + 1]; + + dev = calloc(1, sizeof(*dev)); + if (dev == NULL) + return -1; + + /* get class id and device id */ + snprintf(sysctlVar, len, "dev.%s.%u.%%pnpinfo", name, unit_num); + if (sysctlbyname(sysctlVar, &sysctlBuffer, &len, NULL, 0) < 0) + goto error; + + /* pnpinfo: classid=f912ad6d-2b17-48ea-bd65-f927a61c7684 + * deviceid=d34b2567-b9b6-42b9-8778-0a4ec0b955bf + */ + if (sysctlBuffer[0] == 'c' && sysctlBuffer[1] == 'l' && + sysctlBuffer[7] == '=') { + memcpy(classid, &sysctlBuffer[8], guid_len); + classid[guid_len] = '\0'; + } + if (parse_sysfs_uuid(classid, dev->class_id) < 0) + goto error; + + /* skip non-network devices */ + if (rte_uuid_compare(dev->class_id, vmbus_nic_uuid) != 0) { + free(dev); + return 0; + } + + if (sysctlBuffer[45] == 'd' && sysctlBuffer[46] == 'e' && + sysctlBuffer[47] == 'v' && sysctlBuffer[53] == '=') { + memcpy(deviceid, &sysctlBuffer[54], guid_len); + deviceid[guid_len] = '\0'; + } + if (parse_sysfs_uuid(deviceid, dev->device_id) < 0) + goto error; + + if (!strcmp(name, "hv_uio")) + dev->uio_num = unit_num; + else + dev->uio_num = -1; + dev->device.bus = &rte_vmbus_bus.bus; + dev->device.numa_node = 0; + dev->device.name = strdup(deviceid); + if (!dev->device.name) + goto error; + + dev->device.devargs = vmbus_devargs_lookup(dev); + + dev->intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE); + if (dev->intr_handle == NULL) + goto error; + + /* device is valid, add in list (sorted) */ + VMBUS_LOG(DEBUG, "Adding vmbus device %s", name); + + TAILQ_FOREACH(dev2, &rte_vmbus_bus.device_list, next) { + int ret; + + ret = rte_uuid_compare(dev->device_id, dev2->device_id); + if (ret > 0) + continue; + + if (ret < 0) { + vmbus_insert_device(dev2, dev); + } else { /* already registered */ + VMBUS_LOG(NOTICE, + "%s already registered", name); + free(dev); + } + return 0; + } + + vmbus_add_device(dev); + return 0; +error: + VMBUS_LOG(DEBUG, "failed"); + + free(dev); + return -1; +} + +static int +vmbus_unpack(char *walker, char *ep, char **str) +{ + int ret = 0; + + *str = strdup(walker); + if (*str == NULL) { + ret = -ENOMEM; + goto exit; + } + + if (walker + strnlen(walker, ep - walker) >= ep) { + ret = -EINVAL; + goto exit; + } +exit: + return ret; +} + +/* + * Scan the content of the vmbus, and the devices in the devices list + */ +int +rte_vmbus_scan(void) +{ + struct u_device udev; + struct u_businfo ubus; + int dev_idx, dev_ptr, name2oid[2], oid[CTL_MAXNAME + 12], error; + size_t oidlen, rlen, ub_size; + uintptr_t vmbus_handle = 0; + char *walker, *ep; + char name[16] = "hw.bus.devices"; + char *dd_name, *dd_desc, *dd_drivername, *dd_pnpinfo, *dd_location; + + /* + * devinfo FreeBSD APP logic to fetch all the VMBus devices + * using SYSCTLs + */ + name2oid[0] = 0; + name2oid[1] = 3; + oidlen = sizeof(oid); + error = sysctl(name2oid, 2, oid, &oidlen, name, strlen(name)); + if (error < 0) { + VMBUS_LOG(DEBUG, "can't find hw.bus.devices sysctl node"); + return -ENOENT; + } + oidlen /= sizeof(int); + if (oidlen > CTL_MAXNAME) { + VMBUS_LOG(DEBUG, "hw.bus.devices oid is too large"); + return -EINVAL; + } + + ub_size = sizeof(ubus); + if (sysctlbyname("hw.bus.info", &ubus, &ub_size, NULL, 0) != 0) { + VMBUS_LOG(DEBUG, "sysctlbyname(\"hw.bus.info\", ...) failed"); + return -EINVAL; + } + if ((ub_size != sizeof(ubus)) || + (ubus.ub_version != BUS_USER_VERSION)) { + VMBUS_LOG(DEBUG, + "kernel bus interface version mismatch: kernel %d expected %d", + ubus.ub_version, BUS_USER_VERSION); + return -EINVAL; + } + + oid[oidlen++] = ubus.ub_generation; + dev_ptr = oidlen++; + + /* + * Scan devices. + * + * Stop after a fairly insane number to avoid death in the case + * of kernel corruption. + */ + + for (dev_idx = 0; dev_idx < 10000; dev_idx++) { + /* + * Get the device information. + */ + oid[dev_ptr] = dev_idx; + rlen = sizeof(udev); + error = sysctl(oid, oidlen, &udev, &rlen, NULL, 0); + if (error < 0) { + if (errno == ENOENT) /* end of list */ + break; + if (errno != EINVAL) /* gen count skip, restart */ + VMBUS_LOG(DEBUG, "sysctl hw.bus.devices.%d", + dev_idx); + return errno; + } + if (rlen != sizeof(udev)) { + VMBUS_LOG(DEBUG, + "sysctl returned wrong data %zd bytes instead of %zd", + rlen, sizeof(udev)); + return -EINVAL; + } + + walker = udev.dv_fields; + ep = walker + sizeof(udev.dv_fields); + dd_name = NULL; + dd_desc = NULL; + dd_drivername = NULL; + dd_pnpinfo = NULL; + dd_location = NULL; + + error = vmbus_unpack(walker, ep, &dd_name); + if (error < 0) + return error; + walker += strlen(walker) + 1; + + error = vmbus_unpack(walker, ep, &dd_desc); + if (error < 0) + return error; + walker += strlen(walker) + 1; + + error = vmbus_unpack(walker, ep, &dd_drivername); + if (error < 0) + return error; + walker += strlen(walker) + 1; + + error = vmbus_unpack(walker, ep, &dd_pnpinfo); + if (error < 0) + return error; + walker += strlen(walker) + 1; + + error = vmbus_unpack(walker, ep, &dd_location); + if (error < 0) + return error; + + if (*dd_drivername && !(strcmp(dd_drivername, "vmbus"))) + vmbus_handle = udev.dv_handle; + + if (vmbus_handle && (vmbus_handle == udev.dv_parent) + && *dd_pnpinfo && *dd_name) { + unsigned int driver_len = 0, unit_num = 0; + char *endptr; + + driver_len = strlen(dd_drivername); + unit_num = strtoull(&dd_name[driver_len], &endptr, 10); + VMBUS_LOG(DEBUG, "Device name:%s, pnpinfo:%s", + dd_name, dd_pnpinfo); + + if (vmbus_scan_one(dd_drivername, unit_num) < 0) + goto error; + } + } + return 0; +error: + return -1; +} From patchwork Mon Apr 18 04:29:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109875 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F420AA00BE; Tue, 19 Apr 2022 11:34:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 311C642804; Tue, 19 Apr 2022 11:33:44 +0200 (CEST) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 6B1984014F for ; Mon, 18 Apr 2022 06:29:46 +0200 (CEST) Received: by mail-pj1-f44.google.com with SMTP id g12-20020a17090a640c00b001cb59d7a57cso11161293pjj.1 for ; Sun, 17 Apr 2022 21:29:46 -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=z1qtB1g0KQc0UonmbpNPp5xwc1yvf8OZS+J+DYWpJ0Q=; b=Mrg66hIo2TBvvNs93MuUYJ39JNRA45bgj8MkrQ3kzg3TSCB2ibYvJV0hUC7o6ZJP2S mkHCfeXqwa9Iwq5YZ7hYntdITIQ+ge8CRdOnvM24zIOVqkq4TouUX3Jq3/mgSv8la52H HM5POdSFw//RG9JVXqHueJsqIjhi8N3IO/7do= 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=z1qtB1g0KQc0UonmbpNPp5xwc1yvf8OZS+J+DYWpJ0Q=; b=kmks1eUkksAX/LLyLPq+QHeVVld31dXaV/zI0rzNcSFoJ+hP5jVKqDmZ3JyZrAgfpR rmAOoG3oIymzoGmkhzFTk9woF8Y9L0oEzsoUgP50XvyULVQupHSSv1ornV8sRAeOTSgY yprHWMC9V6LApKIkFNLHCEqTGA3ICKGPZNFrK0vYryxF5NQsUGflCMe5SXHOjmTQsWVf yR6/G0PJL7rXO8oqrosM/g2TPJIED3gPdxx8FhMdzMDL5kwZnRBnZU/W+CzmNN79gPNU D6xG5t406+uEbNoNnn4DpAaF1Um5rS6ECOBDUYQimReSHOLclfpjzRS/AtmlNvcWvPXR GrVg== X-Gm-Message-State: AOAM533zrs9VeZvxTZLip32Ba9JYl1tm/2t4X+PBlI03T2D0HzZhuNcA 4WyMlHBKF0yjQvLmclv4qVZZYQ== X-Google-Smtp-Source: ABdhPJw52ugIWlvAIDUvcrUe11lfkCietsTQc9DQunJcL8r+PE3ob7eljPfAnWjSox4v+X/jzjzxWw== X-Received: by 2002:a17:90b:3ece:b0:1d2:aee9:23c8 with SMTP id rm14-20020a17090b3ece00b001d2aee923c8mr493249pjb.112.1650256185719; Sun, 17 Apr 2022 21:29:45 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:45 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 05/14] bus/vmbus: handle mapping of device resources Date: Mon, 18 Apr 2022 09:59:06 +0530 Message-Id: <20220418042915.5765-6-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 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 All resource values are published by HV_UIO driver as sysctl key value pairs and they are read at a later point of the code flow Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_bus.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_bus.c b/drivers/bus/vmbus/freebsd/vmbus_bus.c index 8cf3bc5a6a..afa1e74976 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_bus.c +++ b/drivers/bus/vmbus/freebsd/vmbus_bus.c @@ -28,6 +28,24 @@ parse_sysfs_uuid(const char *filename, rte_uuid_t uu) return 0; } +/* map the resources of a vmbus device in virtual memory */ +int +rte_vmbus_map_device(struct rte_vmbus_device *dev) +{ + if (dev->uio_num < 0) { + VMBUS_LOG(DEBUG, "Not managed by UIO driver, skipped"); + return 1; + } + + return vmbus_uio_map_resource(dev); +} + +void +rte_vmbus_unmap_device(struct rte_vmbus_device *dev) +{ + vmbus_uio_unmap_resource(dev); +} + /* Scan one vmbus entry, and fill the devices list from it. */ static int vmbus_scan_one(const char *name, unsigned int unit_num) From patchwork Mon Apr 18 04:29:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109876 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1514EA00BE; Tue, 19 Apr 2022 11:34:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2BB6A42808; Tue, 19 Apr 2022 11:33:45 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by mails.dpdk.org (Postfix) with ESMTP id 7CF7840141 for ; Mon, 18 Apr 2022 06:29:49 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id v12so11454875plv.4 for ; Sun, 17 Apr 2022 21:29:49 -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=zbQbLGhsdzBDsPmbXRPavrFyOygm+JFXla1z5NxcE3A=; b=i2Uy/M7lYacB05IuJcsFVWXXk6dUj1nQ4oN5dlKqQEaUxET+n2nSseH0wbi5Va1xnQ /iHiW8Dvhh1gFLQFI8b0w80RuYVJedH5SGmU8DzeCbQBLptrk9xyni86/wBqG4j7kNdR 3nf5DZn5yclOd2yGXPAemkceHQcCMKM+RZZSE= 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=zbQbLGhsdzBDsPmbXRPavrFyOygm+JFXla1z5NxcE3A=; b=OkMhhtaWZptOJS3B83As2LlihSDTDO6WNiSraJbfqSdG6qsjDQ4PP3TjeEhLWgt0gd GNoni7F/vSGKbd42djnwfU/Tlz/tICgjZWOk+YKmHBTwimO/f6hjbHwLMZuObOPF60dk 1EtDLrU7p28Qch3cWRqIsnppB26Z/Ekkyqxqyy/4NCQ5ndto2wB39fV2HtR+L0PIigzH ZodwT5mKkLubRKzofOha2jmcu3s9yo9o5v7OqhxIE1960oYg2QMQdQEgJ/Z/vqFQEBFn RlzQ5PQg1c4Mhr3z3oueupDRUhONV6XfMZzg/LWzqTTbuocNuqgP5KVWq1QyHZj47jsO sgjw== X-Gm-Message-State: AOAM532G/QBNZ3ULknTXppgFGMfAvAkqKai5ucu1alyE41DCsaDhVCNn jrOAux1QSgzkW1bCpX/NNgtwbw== X-Google-Smtp-Source: ABdhPJyl/dY+RWxoD2361L193vVSOunraxJU0/7aPVvNV+aoqa4fKBaNFDjk36MmScLZL/gEH6A3uQ== X-Received: by 2002:a17:90a:fa8d:b0:1d2:8126:ce15 with SMTP id cu13-20020a17090afa8d00b001d28126ce15mr6213895pjb.162.1650256188645; Sun, 17 Apr 2022 21:29:48 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:48 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 06/14] bus/vmbus: get device resource values using sysctl Date: Mon, 18 Apr 2022 09:59:07 +0530 Message-Id: <20220418042915.5765-7-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 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 The UIO device's attribute (relid, monitor id, etc) values are retrieved using following sysctl variables: $ sysctl dev.hv_uio.0 dev.hv_uio.0.send_buf.gpadl: 925241 dev.hv_uio.0.send_buf.size: 16777216 dev.hv_uio.0.recv_buf.gpadl: 925240 dev.hv_uio.0.recv_buf.size: 32505856 dev.hv_uio.0.monitor_page.size: 4096 dev.hv_uio.0.int_page.size: 4096 Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 105 ++++++++++++++++++++++++++ drivers/bus/vmbus/linux/vmbus_uio.c | 16 ++++ drivers/bus/vmbus/osi/vmbus_osi.h | 4 + drivers/bus/vmbus/osi/vmbus_osi_uio.c | 6 +- 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/vmbus/freebsd/vmbus_uio.c diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c new file mode 100644 index 0000000000..b622388ce9 --- /dev/null +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -0,0 +1,105 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2018, Microsoft Corporation. + * All Rights Reserved. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "private.h" +#include "vmbus_osi.h" + +const char *driver_name = "hv_uio"; + +/* Check map names with kernel names */ +static const char *map_names[VMBUS_MAX_RESOURCE] = { + [HV_TXRX_RING_MAP] = "txrx_rings", + [HV_INT_PAGE_MAP] = "int_page", + [HV_MON_PAGE_MAP] = "monitor_page", + [HV_RECV_BUF_MAP] = "recv_buf", + [HV_SEND_BUF_MAP] = "send_buf", +}; + +static int +sysctl_get_vmbus_device_info(struct rte_vmbus_device *dev) +{ + char sysctlBuffer[PATH_MAX]; + char sysctlVar[PATH_MAX]; + size_t len = PATH_MAX, sysctl_len; + unsigned long tmp; + int i; + + snprintf(sysctlBuffer, len, "dev.%s.%d", driver_name, dev->uio_num); + + sysctl_len = sizeof(unsigned long); + /* get relid */ + snprintf(sysctlVar, len, "%s.channel.ch_id", sysctlBuffer); + if (sysctlbyname(sysctlVar, &tmp, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s", sysctlVar); + goto error; + } + dev->relid = tmp; + + /* get monitor id */ + snprintf(sysctlVar, len, "%s.channel.%u.monitor_id", sysctlBuffer, + dev->relid); + if (sysctlbyname(sysctlVar, &tmp, &sysctl_len, NULL, 0) < 0) { + VMBUS_LOG(ERR, "could not read %s", sysctlVar); + goto error; + } + dev->monitor_id = tmp; + + /* Extract resource value */ + for (i = 0; i < VMBUS_MAX_RESOURCE; i++) { + struct rte_mem_resource *res = &dev->resource[i]; + unsigned long size, gpad = 0; + size_t sizelen = sizeof(len); + + snprintf(sysctlVar, sizeof(sysctlVar), "%s.%s.size", + sysctlBuffer, map_names[i]); + if (sysctlbyname(sysctlVar, &size, &sizelen, NULL, 0) < 0) { + VMBUS_LOG(ERR, + "could not read %s", sysctlVar); + goto error; + } + res->len = size; + + if (i == HV_RECV_BUF_MAP || i == HV_SEND_BUF_MAP) { + snprintf(sysctlVar, sizeof(sysctlVar), "%s.%s.gpadl", + sysctlBuffer, map_names[i]); + if (sysctlbyname(sysctlVar, &gpad, &sizelen, NULL, 0) < 0) { + VMBUS_LOG(ERR, + "could not read %s", sysctlVar); + goto error; + } + /* put the GPAD value in physical address */ + res->phys_addr = gpad; + } + } + return 0; +error: + return -1; +} + +/* + * On FreeBSD, the device is opened first to ensure kernel UIO driver + * is properly initialized before reading device attributes + */ +int vmbus_get_device_info_os(struct rte_vmbus_device *dev) +{ + return sysctl_get_vmbus_device_info(dev); +} + +const char *get_devname_os(void) +{ + return "/dev/hv_uio"; +} diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index ea6df21409..669551a4d4 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -199,3 +199,19 @@ int vmbus_uio_get_subchan(struct vmbus_channel *primary, closedir(chan_dir); return err; } + +/* + * In Linux the device info is fetched from SYSFS and doesn't need + * opening of the device before reading its attributes + * This is a stub function and it should always succeed. + */ +int vmbus_get_device_info_os(struct rte_vmbus_device *dev) +{ + RTE_SET_USED(dev); + return 0; +} + +const char *get_devname_os(void) +{ + return "/dev/uio"; +} diff --git a/drivers/bus/vmbus/osi/vmbus_osi.h b/drivers/bus/vmbus/osi/vmbus_osi.h index 579c4bb99c..59afc102f1 100644 --- a/drivers/bus/vmbus/osi/vmbus_osi.h +++ b/drivers/bus/vmbus/osi/vmbus_osi.h @@ -20,4 +20,8 @@ int vmbus_uio_map_subchan_os(const struct rte_vmbus_device *dev, bool vmbus_isnew_subchannel(struct vmbus_channel *primary, unsigned long id); +int vmbus_get_device_info_os(struct rte_vmbus_device *dev); + +const char *get_devname_os(void); + #endif /* _VMBUS_BUS_OSI_H_ */ diff --git a/drivers/bus/vmbus/osi/vmbus_osi_uio.c b/drivers/bus/vmbus/osi/vmbus_osi_uio.c index 35106e247e..3374813cc8 100644 --- a/drivers/bus/vmbus/osi/vmbus_osi_uio.c +++ b/drivers/bus/vmbus/osi/vmbus_osi_uio.c @@ -82,7 +82,8 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, int fd; /* save fd if in primary process */ - snprintf(devname, sizeof(devname), "/dev/uio%u", dev->uio_num); + snprintf(devname, sizeof(devname), "%s%u", get_devname_os(), + dev->uio_num); fd = open(devname, O_RDWR); if (fd < 0) { VMBUS_LOG(ERR, "Cannot open %s: %s", @@ -106,6 +107,9 @@ vmbus_uio_alloc_resource(struct rte_vmbus_device *dev, strlcpy((*uio_res)->path, devname, PATH_MAX); rte_uuid_copy((*uio_res)->id, dev->device_id); + if (vmbus_get_device_info_os(dev) < 0) + goto error; + return 0; error: From patchwork Mon Apr 18 04:29:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109877 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1746DA00BE; Tue, 19 Apr 2022 11:34:30 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4EBFF4280C; Tue, 19 Apr 2022 11:33:46 +0200 (CEST) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by mails.dpdk.org (Postfix) with ESMTP id 9C01140141 for ; Mon, 18 Apr 2022 06:29:52 +0200 (CEST) Received: by mail-pg1-f171.google.com with SMTP id q12so16713831pgj.13 for ; Sun, 17 Apr 2022 21:29:52 -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=HNp+9krAUZCTlinhvwcmE1tsnrPILb+jRRSaMZ1qovo=; b=FrKCVK6pI3stkWVgXIf3IwBcWDy8KYyukf9ds5QqxcQhy3SfgRuykJkTL1mdaifJNe wkwT68DKLF7k6wkbVeoHW6YeYgLcAxo+EgVKoxkCB8KQ8VeUH8224I0EXXk1DWrhlyI7 dNl5DdvsNUhqRZd3++wCjtxMCAew01Kpg8gPE= 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=HNp+9krAUZCTlinhvwcmE1tsnrPILb+jRRSaMZ1qovo=; b=xOa8oEreZyp7G+yMsqhPrs+OHCB1MZCLOf2g8Ky+2M1qnJY/FWKh+zua+C93g2YBVs nQG4BYiX0MhRG6j5sup1WKatPkW0CuOTFdFNWo0vi3ng3gg/0Lfv7zjTL1Olxt7Q/BhK oDtuPA0WttaWWm7RK4GKBQexEbqiKE3N67/ANeBD9o13Zg3SPs8rCXZsHAzjbD3TcRbN 15MVr1hOmTG4uOlySEvYE2R90BpaBROHthbz0T5+8vsaeqHeeSqtufdpznGnOIIGSVnd DTiKe172dMuZK7vUhgKX/iffv8wm4d3eSWUyAPx9U7PPOsLnEb+wxEwh+BrpAJF6azm2 B3rA== X-Gm-Message-State: AOAM5324iZFlrMNlMpkIkINojnVe9r1FFTL8qtgNi2ggyiGYfwF4IhZa xLbN0rWLlesGVIACE0c7/P7iog== X-Google-Smtp-Source: ABdhPJzQgEG1NFvM/65fk2/LL/wQKNcjjjLRt0VrMM94qG1sDHelndcV5E6Tc8F+aRzIFd/lcwYADg== X-Received: by 2002:aa7:8893:0:b0:4fb:10e1:8976 with SMTP id z19-20020aa78893000000b004fb10e18976mr10213216pfe.36.1650256191876; Sun, 17 Apr 2022 21:29:51 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:51 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 07/14] net/netvsc: make event monitor OS dependent Date: Mon, 18 Apr 2022 09:59:08 +0530 Message-Id: <20220418042915.5765-8-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 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 - Event monitoring is not yet supported on FreeBSD, hence moving it to the OS specific files - Add meson support to OS environment Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/netvsc/freebsd/hn_os.c | 16 ++++++++++++++++ drivers/net/netvsc/freebsd/meson.build | 6 ++++++ drivers/net/netvsc/hn_ethdev.c | 7 +++---- drivers/net/netvsc/hn_os.h | 6 ++++++ drivers/net/netvsc/linux/hn_os.c | 21 +++++++++++++++++++++ drivers/net/netvsc/linux/meson.build | 6 ++++++ drivers/net/netvsc/meson.build | 3 +++ 7 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 drivers/net/netvsc/freebsd/hn_os.c create mode 100644 drivers/net/netvsc/freebsd/meson.build create mode 100644 drivers/net/netvsc/hn_os.h create mode 100644 drivers/net/netvsc/linux/hn_os.c create mode 100644 drivers/net/netvsc/linux/meson.build diff --git a/drivers/net/netvsc/freebsd/hn_os.c b/drivers/net/netvsc/freebsd/hn_os.c new file mode 100644 index 0000000000..4c6a79872d --- /dev/null +++ b/drivers/net/netvsc/freebsd/hn_os.c @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2016-2021 Microsoft Corporation + */ + +#include + +#include + +#include "hn_logs.h" +#include "hn_os.h" + +int eth_hn_os_dev_event(void) +{ + PMD_DRV_LOG(DEBUG, "rte_dev_event_monitor_start not supported on FreeBSD"); + return 0; +} diff --git a/drivers/net/netvsc/freebsd/meson.build b/drivers/net/netvsc/freebsd/meson.build new file mode 100644 index 0000000000..78f824f701 --- /dev/null +++ b/drivers/net/netvsc/freebsd/meson.build @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Microsoft Corporation + +sources += files( + 'hn_os.c', +) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 8a950403ac..8b1e07b775 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -39,6 +39,7 @@ #include "hn_rndis.h" #include "hn_nvs.h" #include "ndis.h" +#include "hn_os.h" #define HN_TX_OFFLOAD_CAPS (RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \ @@ -1240,11 +1241,9 @@ static int eth_hn_probe(struct rte_vmbus_driver *drv __rte_unused, PMD_INIT_FUNC_TRACE(); - ret = rte_dev_event_monitor_start(); - if (ret) { - PMD_DRV_LOG(ERR, "Failed to start device event monitoring"); + ret = eth_hn_os_dev_event(); + if (ret) return ret; - } eth_dev = eth_dev_vmbus_allocate(dev, sizeof(struct hn_data)); if (!eth_dev) diff --git a/drivers/net/netvsc/hn_os.h b/drivers/net/netvsc/hn_os.h new file mode 100644 index 0000000000..618c53cdcd --- /dev/null +++ b/drivers/net/netvsc/hn_os.h @@ -0,0 +1,6 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2009-2021 Microsoft Corp. + * All rights reserved. + */ + +int eth_hn_os_dev_event(void); diff --git a/drivers/net/netvsc/linux/hn_os.c b/drivers/net/netvsc/linux/hn_os.c new file mode 100644 index 0000000000..1ea12ce928 --- /dev/null +++ b/drivers/net/netvsc/linux/hn_os.c @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2016-2021 Microsoft Corporation + */ + +#include + +#include + +#include "hn_logs.h" +#include "hn_os.h" + +int eth_hn_os_dev_event(void) +{ + int ret; + + ret = rte_dev_event_monitor_start(); + if (ret) + PMD_DRV_LOG(ERR, "Failed to start device event monitoring"); + + return ret; +} diff --git a/drivers/net/netvsc/linux/meson.build b/drivers/net/netvsc/linux/meson.build new file mode 100644 index 0000000000..78f824f701 --- /dev/null +++ b/drivers/net/netvsc/linux/meson.build @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Microsoft Corporation + +sources += files( + 'hn_os.c', +) diff --git a/drivers/net/netvsc/meson.build b/drivers/net/netvsc/meson.build index bb6225d05a..c50414de07 100644 --- a/drivers/net/netvsc/meson.build +++ b/drivers/net/netvsc/meson.build @@ -8,6 +8,7 @@ if is_windows endif deps += 'bus_vmbus' +includes += include_directories(exec_env) sources = files( 'hn_ethdev.c', 'hn_nvs.c', @@ -15,3 +16,5 @@ sources = files( 'hn_rxtx.c', 'hn_vf.c', ) + +subdir(exec_env) From patchwork Mon Apr 18 04:29:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109878 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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"; From patchwork Mon Apr 18 04:29:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109879 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D0F1A00BE; Tue, 19 Apr 2022 11:34:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 20FC942815; Tue, 19 Apr 2022 11:33:48 +0200 (CEST) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) by mails.dpdk.org (Postfix) with ESMTP id 4976240141 for ; Mon, 18 Apr 2022 06:29:59 +0200 (CEST) Received: by mail-pg1-f177.google.com with SMTP id q19so16755475pgm.6 for ; Sun, 17 Apr 2022 21:29:59 -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=2bahx64LuEbChOf1Axjl42rqx1Wa1GVGQEcGvPASvoI=; b=UFRwJLIq2vAZ4L6PP2o0h5gFT9TEcW8stP98xN8spuIytVztyw9TF2vUklRmB740Bu mlzRGslezDj2vTSL8S5VhlTb7ga0ebr9A/PO7JkQBYjxX39obiE+dXK+l7qazeTFmw8T ZlWcwbG48+zF9G86uyQ+gTzpPNd7YE3hyMlFg= 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=2bahx64LuEbChOf1Axjl42rqx1Wa1GVGQEcGvPASvoI=; b=HaxFgrxjXwZwDgduTm0uFeOWUgwsojFy2DQwpKMMUrssfM0vRZLipl0ypTFHFsSnM8 hqg4y0beZ3ONidVG90yJGAL/QJkEYkzlqyAnk969CFX7d2I06xRD7XVGFJzfMhw/Bnzt L0uTuTTMPeuGDshQeMy3g4LGdK0OzqnbgxFL+By6Lc4JteXn3MuTicxY9773H30UOqSs pRuDraHzRRMMMOfutSmBcQgwoeRiylr106MECyufvNWQ8FZgLOmaYqMB/Vif5kE5pQ1y cjrk0YK6YoVLvwWMrPrXWYqDEFQbiOyn8Y3+BFj1gtJLJrhGUSgjypltcClW/S5T1AUg u2fA== X-Gm-Message-State: AOAM53099wIOxYWKn+vO8SahR4A80l64WCMTAIz0Nkt2Re/Bxg0c8cFS FJX/1cGwmplMBbIkzZzkqZl31A== X-Google-Smtp-Source: ABdhPJztMOmEpgYAj+lZiIdx2oo3jxHLoIVo81mkcYGm7P1faPbHiUCYAvyLWswYvJ7yOQ4NuAZzsQ== X-Received: by 2002:a63:f546:0:b0:3aa:878:e29f with SMTP id e6-20020a63f546000000b003aa0878e29fmr1456072pgk.439.1650256198522; Sun, 17 Apr 2022 21:29:58 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:29:57 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 09/14] bus/vmbus: open subchannels Date: Mon, 18 Apr 2022 09:59:10 +0530 Message-Id: <20220418042915.5765-10-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 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 In FreeBSD, unlike Linux there is no sub-channel open callback that could be called by HV_UIO driver upon their grant by the hypervisor. Thus the PMD makes an IOCTL to the HV_UIO to open the sub-channels On Linux, the vmbus_uio_subchan_open() will always return success as the Linux HV_UIO opens them implicitly. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/freebsd/vmbus_uio.c | 30 +++++++++++++++++++++++++++ drivers/bus/vmbus/linux/vmbus_uio.c | 12 +++++++++++ drivers/bus/vmbus/private.h | 1 + drivers/bus/vmbus/rte_bus_vmbus.h | 10 +++++++++ drivers/bus/vmbus/version.map | 1 + drivers/bus/vmbus/vmbus_channel.c | 5 +++++ 6 files changed, 59 insertions(+) diff --git a/drivers/bus/vmbus/freebsd/vmbus_uio.c b/drivers/bus/vmbus/freebsd/vmbus_uio.c index 6b43b4349f..7e4e9723cb 100644 --- a/drivers/bus/vmbus/freebsd/vmbus_uio.c +++ b/drivers/bus/vmbus/freebsd/vmbus_uio.c @@ -25,6 +25,9 @@ */ #define UH_SUBCHAN_MASK_SHIFT 8 +/* ioctl */ +#define HVIOOPENSUBCHAN _IOW('h', 14, uint32_t) + const char *driver_name = "hv_uio"; /* Check map names with kernel names */ @@ -151,3 +154,30 @@ const char *get_devname_os(void) { return "/dev/hv_uio"; } + +int vmbus_uio_subchan_open(struct rte_vmbus_device *dev, uint32_t subchan) +{ + struct mapped_vmbus_resource *uio_res; + int fd, err = 0; + + uio_res = vmbus_uio_find_resource(dev); + if (!uio_res) { + VMBUS_LOG(ERR, "cannot find uio resource"); + return -EINVAL; + } + + fd = open(uio_res->path, O_RDWR); + if (fd < 0) { + VMBUS_LOG(ERR, "Cannot open %s: %s", + uio_res->path, strerror(errno)); + return -1; + } + + if (ioctl(fd, HVIOOPENSUBCHAN, &subchan)) { + VMBUS_LOG(ERR, "open subchan ioctl failed %s: %s", + uio_res->path, strerror(errno)); + err = -1; + } + close(fd); + return err; +} diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c index 669551a4d4..d88cc97b5b 100644 --- a/drivers/bus/vmbus/linux/vmbus_uio.c +++ b/drivers/bus/vmbus/linux/vmbus_uio.c @@ -215,3 +215,15 @@ const char *get_devname_os(void) { return "/dev/uio"; } + +/* + * This is a stub function and it should always succeed. + * The Linux UIO kernel driver opens the subchannels implicitly. + */ +int vmbus_uio_subchan_open(struct rte_vmbus_device *dev, + uint32_t subchan) +{ + RTE_SET_USED(dev); + RTE_SET_USED(subchan); + return 0; +} diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index 1bca147e12..ea0276a6c6 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -116,6 +116,7 @@ bool vmbus_uio_subchannels_supported(const struct rte_vmbus_device *dev, int vmbus_uio_get_subchan(struct vmbus_channel *primary, struct vmbus_channel **subchan); int vmbus_uio_map_rings(struct vmbus_channel *chan); +int vmbus_uio_subchan_open(struct rte_vmbus_device *device, uint32_t subchan); void vmbus_br_setup(struct vmbus_br *br, void *buf, unsigned int blen); diff --git a/drivers/bus/vmbus/rte_bus_vmbus.h b/drivers/bus/vmbus/rte_bus_vmbus.h index a24bad831d..c8cb4bc98c 100644 --- a/drivers/bus/vmbus/rte_bus_vmbus.h +++ b/drivers/bus/vmbus/rte_bus_vmbus.h @@ -404,6 +404,16 @@ void rte_vmbus_chan_dump(FILE *f, const struct vmbus_channel *chan); */ void rte_vmbus_unregister(struct rte_vmbus_driver *driver); +/** + * Perform IOCTL to VMBUS device + * + * @param device + * A pointer to a rte_vmbus_device structure + * @param subchan + * Count of subchannels to open + */ +int rte_vmbus_ioctl(struct rte_vmbus_device *device, uint32_t subchan); + /** Helper for VMBUS device registration from driver instance */ #define RTE_PMD_REGISTER_VMBUS(nm, vmbus_drv) \ RTE_INIT(vmbusinitfn_ ##nm) \ diff --git a/drivers/bus/vmbus/version.map b/drivers/bus/vmbus/version.map index 3cadec7fae..3509d4fc14 100644 --- a/drivers/bus/vmbus/version.map +++ b/drivers/bus/vmbus/version.map @@ -23,6 +23,7 @@ DPDK_22 { rte_vmbus_subchan_open; rte_vmbus_unmap_device; rte_vmbus_unregister; + rte_vmbus_ioctl; local: *; }; diff --git a/drivers/bus/vmbus/vmbus_channel.c b/drivers/bus/vmbus/vmbus_channel.c index 119b9b367e..9a8f6e3eef 100644 --- a/drivers/bus/vmbus/vmbus_channel.c +++ b/drivers/bus/vmbus/vmbus_channel.c @@ -365,6 +365,11 @@ int rte_vmbus_max_channels(const struct rte_vmbus_device *device) return 1; } +int rte_vmbus_ioctl(struct rte_vmbus_device *device, uint32_t subchan) +{ + return vmbus_uio_subchan_open(device, subchan); +} + /* Setup secondary channel */ int rte_vmbus_subchan_open(struct vmbus_channel *primary, struct vmbus_channel **new_chan) From patchwork Mon Apr 18 04:29:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109880 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CC7ECA00BE; Tue, 19 Apr 2022 11:34:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0AF244281A; Tue, 19 Apr 2022 11:33:49 +0200 (CEST) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id 5006240141 for ; Mon, 18 Apr 2022 06:30:02 +0200 (CEST) Received: by mail-pg1-f169.google.com with SMTP id t184so3754199pgd.4 for ; Sun, 17 Apr 2022 21:30:02 -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=22ld7iGtLypbWNKcrTv7ZEI6V4+hiA0tI66k2StuwMc=; b=WtnbKxfXqUkq4RKkj0XPOeAbWYMYsGefQ7DjVBwZ3B/OKqG1O2M6yxraa4Dq5LGQiU 71wSlBh/hc5KghUQCQ2PT8b9ITmQGJfFfYtPJYQk85UgC0/WTlxYO6H/5e6GQKpa8GMR xJk0DLKjrEVhQfHGtR+hWQ2myYy9yqjYJhLXk= 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=22ld7iGtLypbWNKcrTv7ZEI6V4+hiA0tI66k2StuwMc=; b=gm+fRQeXNJeQNOGys8ECxd1lWvKKDjUQ2iPJMpnZpgX/uCwxzhxu6s4x03fkuNzP9g TtHCQP6iBiK1FIUEVkLC3XbJ4/R0tAEtFVMY45swYtV/qSdKsUjz/tdsSzRKaXwdljJH A1vAVegLrEQPDNC8VVqF2AsPKEpgZnLO4Lfmx+w/esZNO3Q8DujAxlF0KP39t7owli66 cLQv57rqQMuNFRkMg9Cb1JQdiAvsp7jlmFuRpHUn+qpIf4dCskB1yhyeUQVtXsCjCdre DGz4tDemlCJYdcrTuyoRwBylysRddy11GTXPiYyRJoPHs442YBh1iYtWv3fMI20hFcut U3QQ== X-Gm-Message-State: AOAM533i1Ppa12gWh0So1f8/PbLqa6XGNRShlQHaYjZLHXh9TZUk0Yhg 8j3CpdvKQjihEaMFJBN4Zcy3Yw== X-Google-Smtp-Source: ABdhPJwHXb3d/TkVzNRM2C9qe6c3h1geOLDoT+AiP6OBOjTYIt1vqHJDDjsLWKo9SsPIZlOb1gQewA== X-Received: by 2002:a05:6a00:148a:b0:50a:40f7:5a80 with SMTP id v10-20020a056a00148a00b0050a40f75a80mr10490697pfu.58.1650256201544; Sun, 17 Apr 2022 21:30:01 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:30:01 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 10/14] net/netvsc: make IOCTL call to open subchannels Date: Mon, 18 Apr 2022 09:59:11 +0530 Message-Id: <20220418042915.5765-11-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 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 make IOCTL call to open subchannels Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/netvsc/hn_ethdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 8b1e07b775..104c7aebc5 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -516,6 +516,10 @@ static int hn_subchan_configure(struct hn_data *hv, if (err) return err; + err = rte_vmbus_ioctl(hv->vmbus, subchan); + if (err) + return err; + while (subchan > 0) { struct vmbus_channel *new_sc; uint16_t chn_index; From patchwork Mon Apr 18 04:29:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109881 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org 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 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; From patchwork Mon Apr 18 04:29:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109882 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FDB2A00BE; Tue, 19 Apr 2022 11:34:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ED06A42823; Tue, 19 Apr 2022 11:33:50 +0200 (CEST) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by mails.dpdk.org (Postfix) with ESMTP id E03FF4014F for ; Mon, 18 Apr 2022 06:30:09 +0200 (CEST) Received: by mail-pj1-f66.google.com with SMTP id o5-20020a17090ad20500b001ca8a1dc47aso16317048pju.1 for ; Sun, 17 Apr 2022 21:30:09 -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=585kogWx30/frBohhk50tHeOMNFZjrIThBgzsmaFBCE=; b=a4i6mywaHri2zEYyxnmmzkviYgy3jig0a0OwzOP4xmWQY/6/DELZk0UH0yQWB1r46c 5XjOavPL8GxFEsbkqXLIenxNA7gvaj74cHGFtSb5cyJx4ib7SazGT7LeihLUfBXzAUUa jde2tKv2NvuCd/JFqR7aWxDZVpxQoILyu5q3Q= 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=585kogWx30/frBohhk50tHeOMNFZjrIThBgzsmaFBCE=; b=2HDb2aLJ2ZLpscbj7+bfVHHjx5D8cya6GwmFJilya7Swr/JkR6lpxf8lqurvGkJIWG I3YhpICmulQs03TIwmGLVf989Jvb241DJu3qpXa76cWYf4aE/5QVukwcx+jP0b/gxB0y AKKIBDvT5/f23UEO3Lg4maCu1zukY/Qfu1mUbESFajuJfD9zQSgw4i1Kkg30b0quzVSU WuiqqwFJ3v+MBs076lKAVtIJCtDNtiWvkCrGxsxvCLEX89fGxiTKAfXmz6Q0dJq6c1eC k56tROiuQYz2uv4yoCRgwsC1n5G6EPkF6324ZG78sDayscEVdTrJ1SYfHxp4Ik6JMNUW jbcg== X-Gm-Message-State: AOAM531caYXlRJX6W73ru9g+hUxiqGEPxNAL1ZVCIu8l596zEgHe7O2e /F9tep73EHzV7eXTXfOGlcnnsA== X-Google-Smtp-Source: ABdhPJy35zkPXg0TWEG6AOnnWmKmkeAEwJkcD2raBB3ZWQH+1FfjHDEkCPrzwjN2YAjXEOZD8VP53A== X-Received: by 2002:a17:902:768a:b0:159:71e:971e with SMTP id m10-20020a170902768a00b00159071e971emr540394pll.163.1650256208274; Sun, 17 Apr 2022 21:30:08 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:30:07 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 12/14] net/netvsc: moving hotplug retry to OS dir Date: Mon, 18 Apr 2022 09:59:13 +0530 Message-Id: <20220418042915.5765-13-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 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 Moved netvsc_hotplug_retry to respective OS dir as it contains OS dependent code. For Linux, it is copied as is and for FreeBSD it is not supported yet. Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/net/netvsc/freebsd/hn_os.c | 5 ++ drivers/net/netvsc/hn_ethdev.c | 84 ---------------------------- drivers/net/netvsc/hn_os.h | 2 + drivers/net/netvsc/linux/hn_os.c | 90 ++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 84 deletions(-) diff --git a/drivers/net/netvsc/freebsd/hn_os.c b/drivers/net/netvsc/freebsd/hn_os.c index 4c6a79872d..fece1be9c9 100644 --- a/drivers/net/netvsc/freebsd/hn_os.c +++ b/drivers/net/netvsc/freebsd/hn_os.c @@ -14,3 +14,8 @@ int eth_hn_os_dev_event(void) PMD_DRV_LOG(DEBUG, "rte_dev_event_monitor_start not supported on FreeBSD"); return 0; } + +void netvsc_hotplug_retry(void *args) +{ + RTE_SET_USED(args); +} diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c index 104c7aebc5..dd4b872fed 100644 --- a/drivers/net/netvsc/hn_ethdev.c +++ b/drivers/net/netvsc/hn_ethdev.c @@ -57,9 +57,6 @@ #define NETVSC_ARG_TXBREAK "tx_copybreak" #define NETVSC_ARG_RX_EXTMBUF_ENABLE "rx_extmbuf_enable" -/* The max number of retry when hot adding a VF device */ -#define NETVSC_MAX_HOTADD_RETRY 10 - struct hn_xstats_name_off { char name[RTE_ETH_XSTATS_NAME_SIZE]; unsigned int offset; @@ -556,87 +553,6 @@ static int hn_subchan_configure(struct hn_data *hv, return err; } -static void netvsc_hotplug_retry(void *args) -{ - int ret; - struct hn_data *hv = args; - struct rte_eth_dev *dev = &rte_eth_devices[hv->port_id]; - struct rte_devargs *d = &hv->devargs; - char buf[256]; - - DIR *di; - struct dirent *dir; - struct ifreq req; - struct rte_ether_addr eth_addr; - int s; - - PMD_DRV_LOG(DEBUG, "%s: retry count %d", - __func__, hv->eal_hot_plug_retry); - - if (hv->eal_hot_plug_retry++ > NETVSC_MAX_HOTADD_RETRY) - return; - - snprintf(buf, sizeof(buf), "/sys/bus/pci/devices/%s/net", d->name); - di = opendir(buf); - if (!di) { - PMD_DRV_LOG(DEBUG, "%s: can't open directory %s, " - "retrying in 1 second", __func__, buf); - goto retry; - } - - while ((dir = readdir(di))) { - /* Skip . and .. directories */ - if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) - continue; - - /* trying to get mac address if this is a network device*/ - s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); - if (s == -1) { - PMD_DRV_LOG(ERR, "Failed to create socket errno %d", - errno); - break; - } - strlcpy(req.ifr_name, dir->d_name, sizeof(req.ifr_name)); - ret = ioctl(s, SIOCGIFHWADDR, &req); - close(s); - if (ret == -1) { - PMD_DRV_LOG(ERR, - "Failed to send SIOCGIFHWADDR for device %s", - dir->d_name); - break; - } - if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER) { - closedir(di); - return; - } - memcpy(eth_addr.addr_bytes, req.ifr_hwaddr.sa_data, - RTE_DIM(eth_addr.addr_bytes)); - - if (rte_is_same_ether_addr(ð_addr, dev->data->mac_addrs)) { - PMD_DRV_LOG(NOTICE, - "Found matching MAC address, adding device %s network name %s", - d->name, dir->d_name); - ret = rte_eal_hotplug_add(d->bus->name, d->name, - d->args); - if (ret) { - PMD_DRV_LOG(ERR, - "Failed to add PCI device %s", - d->name); - break; - } - } - /* When the code reaches here, we either have already added - * the device, or its MAC address did not match. - */ - closedir(di); - return; - } - closedir(di); -retry: - /* The device is still being initialized, retry after 1 second */ - rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hv); -} - static void netvsc_hotadd_callback(const char *device_name, enum rte_dev_event_type type, void *arg) diff --git a/drivers/net/netvsc/hn_os.h b/drivers/net/netvsc/hn_os.h index 618c53cdcd..1fb7292b17 100644 --- a/drivers/net/netvsc/hn_os.h +++ b/drivers/net/netvsc/hn_os.h @@ -4,3 +4,5 @@ */ int eth_hn_os_dev_event(void); + +void netvsc_hotplug_retry(void *args); diff --git a/drivers/net/netvsc/linux/hn_os.c b/drivers/net/netvsc/linux/hn_os.c index 1ea12ce928..9c2f4cd7a8 100644 --- a/drivers/net/netvsc/linux/hn_os.c +++ b/drivers/net/netvsc/linux/hn_os.c @@ -3,12 +3,21 @@ */ #include +#include +#include +#include +#include #include +#include #include "hn_logs.h" +#include "hn_var.h" #include "hn_os.h" +/* The max number of retry when hot adding a VF device */ +#define NETVSC_MAX_HOTADD_RETRY 10 + int eth_hn_os_dev_event(void) { int ret; @@ -19,3 +28,84 @@ int eth_hn_os_dev_event(void) return ret; } + +void netvsc_hotplug_retry(void *args) +{ + int ret; + struct hn_data *hv = args; + struct rte_eth_dev *dev = &rte_eth_devices[hv->port_id]; + struct rte_devargs *d = &hv->devargs; + char buf[256]; + + DIR *di; + struct dirent *dir; + struct ifreq req; + struct rte_ether_addr eth_addr; + int s; + + PMD_DRV_LOG(DEBUG, "%s: retry count %d", + __func__, hv->eal_hot_plug_retry); + + if (hv->eal_hot_plug_retry++ > NETVSC_MAX_HOTADD_RETRY) + return; + + snprintf(buf, sizeof(buf), "/sys/bus/pci/devices/%s/net", d->name); + di = opendir(buf); + if (!di) { + PMD_DRV_LOG(DEBUG, "%s: can't open directory %s, " + "retrying in 1 second", __func__, buf); + goto retry; + } + + while ((dir = readdir(di))) { + /* Skip . and .. directories */ + if (!strcmp(dir->d_name, ".") || !strcmp(dir->d_name, "..")) + continue; + + /* trying to get mac address if this is a network device*/ + s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); + if (s == -1) { + PMD_DRV_LOG(ERR, "Failed to create socket errno %d", + errno); + break; + } + strlcpy(req.ifr_name, dir->d_name, sizeof(req.ifr_name)); + ret = ioctl(s, SIOCGIFHWADDR, &req); + close(s); + if (ret == -1) { + PMD_DRV_LOG(ERR, + "Failed to send SIOCGIFHWADDR for device %s", + dir->d_name); + break; + } + if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER) { + closedir(di); + return; + } + memcpy(eth_addr.addr_bytes, req.ifr_hwaddr.sa_data, + RTE_DIM(eth_addr.addr_bytes)); + + if (rte_is_same_ether_addr(ð_addr, dev->data->mac_addrs)) { + PMD_DRV_LOG(NOTICE, + "Found matching MAC address, adding device %s network name %s", + d->name, dir->d_name); + ret = rte_eal_hotplug_add(d->bus->name, d->name, + d->args); + if (ret) { + PMD_DRV_LOG(ERR, + "Failed to add PCI device %s", + d->name); + break; + } + } + /* When the code reaches here, we either have already added + * the device, or its MAC address did not match. + */ + closedir(di); + return; + } + closedir(di); +retry: + /* The device is still being initialized, retry after 1 second */ + rte_eal_alarm_set(1000000, netvsc_hotplug_retry, hv); +} From patchwork Mon Apr 18 04:29:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109883 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8EEA6A00BE; Tue, 19 Apr 2022 11:35:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE96942827; Tue, 19 Apr 2022 11:33:51 +0200 (CEST) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 3126640141 for ; Mon, 18 Apr 2022 06:30:12 +0200 (CEST) Received: by mail-pj1-f47.google.com with SMTP id bg24so12077935pjb.1 for ; Sun, 17 Apr 2022 21:30:12 -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=JdCuYyvNG8XMsUzptnHxTrxrMeKnJ8w5v+asPgAEvq4=; b=W47oROYLSvXEW1Ci6pNEy1C370lC0soHwbH399Ulr72IQ+RHNlTWAghultuorOk8yl AGwJTa1XPxY9xe+wyGinM7ZzoNliZSW2HXkji/I9vAPSBkcLCYRwfI3ZP1HnWJTbn3Fa pJB6S+1EncoENV2Noa73uFKSu5bkD9nhhnhFw= 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=JdCuYyvNG8XMsUzptnHxTrxrMeKnJ8w5v+asPgAEvq4=; b=e/Wx47wC4psBbkdB1ffpy4R6AsMxLOOYQtG9n47qsYvUnQ/sDH5+wnxIt3y2pmehag xZnufFzyy/aC0VYUVjKNPt+pP8LI1aNWzXkU9SJ4U7OoSWaPlnEANNY0IMXaj5/m3Fot nHVyACAu+m/GI/zadIsdNWYbuQl86N/L9CO1zwOPWQMXfe+OCD+HBAU9k7At+xf5narj 1j1RTsBFMbQt1KFPOiH4NAJg/qg0XsZrTAiff9wEFiJEKddYRQ6e2fC+VNN+dFDhRO5z WKWkn6hGJItZLe8E6xRpzUb/fhmY4oB1KNyLOM/QtJDC/0EYzss5aTuqXEjI5IZ3nufK P5FA== X-Gm-Message-State: AOAM533WH5YBoXjBGXrc9v0ASQWyQ8qMvBx42A7U2XhgHHRyFivMHFP1 hwpt/pEfj3rt3/K3dkhP/3rnhw== X-Google-Smtp-Source: ABdhPJyB/hoWt1Nsm5KhXsOYi1S+3Kbrqn8coC9MFRVkmMlq9dVpoTaNvtfnktKCE7ItTNiDtzB3Gw== X-Received: by 2002:a17:90b:390d:b0:1d2:7a7d:170e with SMTP id ob13-20020a17090b390d00b001d27a7d170emr7265550pjb.230.1650256211435; Sun, 17 Apr 2022 21:30:11 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 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 v4 13/14] bus/vmbus: add meson support for FreeBSD Date: Mon, 18 Apr 2022 09:59:14 +0530 Message-Id: <20220418042915.5765-14-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 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 add meson support for FreeBSD OS Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- drivers/bus/vmbus/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/bus/vmbus/meson.build b/drivers/bus/vmbus/meson.build index fe9c72bce1..84ad434177 100644 --- a/drivers/bus/vmbus/meson.build +++ b/drivers/bus/vmbus/meson.build @@ -26,7 +26,11 @@ if is_linux sources += files('linux/vmbus_bus.c', 'linux/vmbus_uio.c') includes += include_directories('linux') +elif is_freebsd + sources += files('freebsd/vmbus_bus.c', + 'freebsd/vmbus_uio.c') + includes += include_directories('freebsd') else build = false - reason = 'only supported on Linux' + reason = 'only supported on Linux & FreeBSD' endif From patchwork Mon Apr 18 04:29:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srikanth Kaka X-Patchwork-Id: 109884 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 184E8A00BE; Tue, 19 Apr 2022 11:35:11 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C8EF84282B; Tue, 19 Apr 2022 11:33:52 +0200 (CEST) Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.68]) by mails.dpdk.org (Postfix) with ESMTP id 4BAE540141 for ; Mon, 18 Apr 2022 06:30:15 +0200 (CEST) Received: by mail-pj1-f68.google.com with SMTP id o5so12107490pjr.0 for ; Sun, 17 Apr 2022 21:30:15 -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=I18G2N20EmCoCAND3iCFjcJIfrY+ZoSlqbJmm5TP6TE=; b=Auyu2SjpfBrD+3zBVjzG2+zqELF4vzsYDN/WLvYRCn7baA3H5ZJS221SpBLPU1VtqI sgng+CmCAgb3xSbvZxJhYkMH+skS+FT7xFU6PXAJWdaqzjqKQhyIVPQbT5w5abdqGg5o wd2utvowdDPD5QGhCi3bk0c04qx7TlIPwTY/o= 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=I18G2N20EmCoCAND3iCFjcJIfrY+ZoSlqbJmm5TP6TE=; b=ZtDicbpM2NA6d4mFFHR2t/vYm9ZXxz8QLQOVkUYOQ73EiEIzmbduDP0DzJpkzvHSAK uJY+43EZlxcH3OfIXSqN1p83rJ1fif/6LulAC89RgUXcTdK6XR9u5kuemyMpT1k4kU0v ZgQ893aOArO5jk1iPmWD/6lnmMT9YsQz9Y+XtiitY3Jt91q0KUnKyoPk8LHK7mbQeTU0 PsX7um/z7tQ6R0IsBHd2ypxmH6PAn7aTmHJx8pkAWLLjc8pn783whxmvsVuCPshi+2Gm WGsBcy+LlD83oWuwg/Hn5A2Eh+b73XkWvilnTy/yadiXEkwZLcG/l0JeHONhPU+Vdssv 3OmA== X-Gm-Message-State: AOAM5314P7jcKl4CsDm74POWHArvpAMFB2E01s3L0sxJN7ygqZsCMYg9 4PuFHxZqr9c4ptYq9dREzC3U9A== X-Google-Smtp-Source: ABdhPJzPwLBpW6bmRaUoIY+qIJJqjohj1lkmZrfWHpFf8W3D914K4AzClSoeiZhoD+Ws2eQDbsoV1A== X-Received: by 2002:a17:90b:352:b0:1c6:77e:a4f7 with SMTP id fh18-20020a17090b035200b001c6077ea4f7mr16202702pjb.77.1650256214530; Sun, 17 Apr 2022 21:30:14 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Apr 2022 21:30:13 -0700 (PDT) From: Srikanth Kaka To: Stephen Hemminger , Long Li Cc: dev@dpdk.org, Vag Singh , Anand Thulasiram , Srikanth Kaka Subject: [PATCH v4 14/14] bus/vmbus: update MAINTAINERS and docs Date: Mon, 18 Apr 2022 09:59:15 +0530 Message-Id: <20220418042915.5765-15-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 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 updated MAINTAINERS and doc files for FreeBSD support Signed-off-by: Srikanth Kaka Signed-off-by: Vag Singh Signed-off-by: Anand Thulasiram --- MAINTAINERS | 2 ++ doc/guides/nics/netvsc.rst | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7c4f541dba..01a494ef0e 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -567,6 +567,7 @@ F: app/test/test_vdev.c VMBUS bus driver M: Stephen Hemminger M: Long Li +M: Srikanth Kaka F: drivers/bus/vmbus/ @@ -823,6 +824,7 @@ F: doc/guides/nics/vdev_netvsc.rst Microsoft Hyper-V netvsc M: Stephen Hemminger M: Long Li +M: Srikanth Kaka F: drivers/net/netvsc/ F: doc/guides/nics/netvsc.rst F: doc/guides/nics/features/netvsc.ini diff --git a/doc/guides/nics/netvsc.rst b/doc/guides/nics/netvsc.rst index 77efe1dc91..12d17024b7 100644 --- a/doc/guides/nics/netvsc.rst +++ b/doc/guides/nics/netvsc.rst @@ -91,6 +91,12 @@ operations: The dpdk-devbind.py script can not be used since it only handles PCI devices. +On FreeBSD, with hv_uio kernel driver loaded, do the following: + + .. code-block:: console + + devctl set driver -f hn1 hv_uio + Prerequisites ------------- @@ -101,6 +107,11 @@ The following prerequisites apply: Full support of multiple queues requires the 4.17 kernel. It is possible to use the netvsc PMD with 4.16 kernel but it is limited to a single queue. +* FreeBSD support for UIO on vmbus is done with hv_uio driver and it is still + in `review`_ + +.. _`review`: https://reviews.freebsd.org/D32184 + Netvsc PMD arguments --------------------