Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp730043rwd; Thu, 18 May 2023 03:11:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6C/jH3HAJFSkykZ+w+Zkaz1v1tSSIi4f1VDGIjEEUW+HY+AMH4313LO6lw1hdDhOlK1d0A X-Received: by 2002:a17:90a:4003:b0:247:4f32:d108 with SMTP id u3-20020a17090a400300b002474f32d108mr1863752pjc.13.1684404695409; Thu, 18 May 2023 03:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684404695; cv=none; d=google.com; s=arc-20160816; b=bdUm4gPEqDZfY/BKANDHAlmyeOvsEz5nohqCUux68lW9h5ta6mXauH+QpHn2QHk1cT lxsoawC1gaM3Z/3WgdpbDIgoVeubvbMfL/TyJTkONZgyIK73jN3zz+mBry9741iZnyyw gwiGXM5Xw+39jeUHUJNjRS2PL4TxBD93lD1ZymSyHZrhhXpgN6PS8miJXV5ayafFA0on 70WGtVwpJr6W/1TK0YPwQpkOjD51ZmSA2P/T4wrpetPtO4Mgg9KJ9iyVh0x7bbmmLw2M 0yt+qixT2mMVdRS7+ym3YMQqJrpUpMUnf6FQxdYhEjDiqSRfIk3UbLSl1NYZ2KbrdQQl 06Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=Wt78fUxV6LOew5dfjUF3WMm8EbNEfc8NoopwolgUsm4=; b=IfS9OQcNGKpPgAZCTvPDXPE67Aol72OfQNDjiYLQREzBOSHMLeaSrqa9LSAMkIVSpL vZvnrZozzhunpSSeG6vlK/DQ6a2ZKTxbLhbQ0caTpVQTtS9pOXfz8ns+E20dBSZB0d7W Seb+eXKU3T19H8mIxKWZbOrPHh18G3n82CvC/kq14AtG2yRMq7xb+YleXsY//icwhDAZ IgO8kgXtSsfDVUaCnyJLVLMVJe6y7+Jn3+WC9sw4gZzaatdu6sesXsAdXmYgbUWUbwlS vGsu5ASAAntT8uDEK20thvDN+Iwsf9vwgKS5QIYP1VcTGNup5SfYXr1JAiEyoODBHplx yPww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20221208.gappssmtp.com header.s=20221208 header.b="oa56e/cO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a17090a974400b00250a96ec646si1382086pjw.21.2023.05.18.03.11.19; Thu, 18 May 2023 03:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@igel-co-jp.20221208.gappssmtp.com header.s=20221208 header.b="oa56e/cO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbjERJym (ORCPT + 99 others); Thu, 18 May 2023 05:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbjERJyf (ORCPT ); Thu, 18 May 2023 05:54:35 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84FB710E9 for ; Thu, 18 May 2023 02:54:33 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6434e65d808so1797616b3a.3 for ; Thu, 18 May 2023 02:54:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20221208.gappssmtp.com; s=20221208; t=1684403673; x=1686995673; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Wt78fUxV6LOew5dfjUF3WMm8EbNEfc8NoopwolgUsm4=; b=oa56e/cOFzouJJv0/MzasDsZCTvPgTaB7sJCEQvT0wP/eycS8LqxRbFSmGBHFcW/Yq Pwv7SlrXHAGE59pwj9hnqdqU7DpahBba+IByjlAPLS1zUdYSkJcYUpMUSosYJ3Lu5uB9 CDKTb4GxrgeG5GpL6s/9AfD0UA0vnb7N4XzTazYWjs9BY1tLyUFC4qMBLhLUVjk2JPgB nMskIF5V7Yja08OJ8yxnmF2EFh0RpY4ntmNWK2sbo9f+wo61nMXezi0/kPgo3n9KcTTh o/5xbZfbWEvLkr6Nf8y79uiYypC2sHNc9A/mDzgt5M6SupbpWyL8NVHk8ERp7kCSaQUO enng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684403673; x=1686995673; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Wt78fUxV6LOew5dfjUF3WMm8EbNEfc8NoopwolgUsm4=; b=gtEpKUTyVJkHEM0PatCXFIJtfY1sB7kAe+rb6c9TiJ7vZ9WTV130dlFsp+3m+DLPxK 14IxLuBmfaysaakuGxaKv+webaM/TKk20W/TSYoHu1NMgHKpILciMffyl1n8GYXONEeo gXgwheJxycRJADoNhBKQG8ec1UVdkBbAc2Gz8/XpD6ikPg0zu3BCHtw1vAyY5rsjunog ouCxr04pEhkAQb4JkG8eHLmIxQP3TRaXZTgvLx/MJpbNqAUcRTw/LYA+nLTEzyc20pGe oDgOX9sWZ2g+yTn04LFfgKLyLIB7Jb60OiWGv8Skn7SEYrnisgRxDMHiKKawwcj7rESi pYaQ== X-Gm-Message-State: AC+VfDzB0UlJ0V7mNP8CZX1QSKeEKaLC5BvcUr4zjWyEXY+bomkwMHBC Ji7/NZex0tj/I9C02lI/jiUAyA== X-Received: by 2002:a05:6a20:8e1c:b0:109:c500:376c with SMTP id y28-20020a056a208e1c00b00109c500376cmr256819pzj.12.1684403672718; Thu, 18 May 2023 02:54:32 -0700 (PDT) Received: from [10.16.161.199] (napt.igel.co.jp. [219.106.231.132]) by smtp.gmail.com with ESMTPSA id x53-20020a056a000bf500b0063d3801d196sm996774pfu.23.2023.05.18.02.54.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 May 2023 02:54:32 -0700 (PDT) Message-ID: Date: Thu, 18 May 2023 18:54:28 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC PATCH v2 3/3] PCI: endpoint: Add EP function driver to provide virtio-console functionality Content-Language: en-US From: Shunsuke Mie To: Jason Wang Cc: Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Manivannan Sadhasivam , Kishon Vijay Abraham I , Bjorn Helgaas , "Michael S. Tsirkin" , Frank Li , Jon Mason , Randy Dunlap , Ren Zhijie , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, virtualization@lists.linux-foundation.org References: <20230427104428.862643-1-mie@igel.co.jp> <20230427104428.862643-4-mie@igel.co.jp> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Gentle ping ... Thanks, Shunsuke. On 2023/05/10 12:17, Shunsuke Mie wrote: > Hi Json, > 2023年5月8日(月) 13:03 Jason Wang : >> On Thu, Apr 27, 2023 at 6:44 PM Shunsuke Mie wrote: >>> Add a new PCIe endpoint function driver that works as a pci virtio-console >>> device. The console connect to endpoint side console. It enables to >>> communicate PCIe host and endpoint. >>> >>> Architecture is following: >>> >>> ┌────────────┐ ┌──────────────────────┬────────────┐ >>> │virtioe │ │ │virtio │ >>> │console drv │ ├───────────────┐ │console drv │ >>> ├────────────┤ │(virtio console│ ├────────────┤ >>> │ virtio bus │ │ device) │◄────►│ virtio bus │ >>> ├────────────┤ ├---------------┤ └────────────┤ >>> │ │ │ pci ep virtio │ │ >>> │ pci bus │ │ console drv │ │ >>> │ │ pcie ├───────────────┤ │ >>> │ │ ◄─────► │ pci ep Bus │ │ >>> └────────────┘ └───────────────┴───────────────────┘ >>> PCIe Root PCIe Endpoint >>> >> I think it might only works for peer devices like: >> >> net, console or vsock. > Could you tell me what "peer devices" means? > >> So there're many choices here, I'd like to know what's the reason for >> you to implement a mediation. >> >> An alternative is to implement a dedicated net, console and vsock >> driver for vringh (CAIF somehow works like this). This would have >> better performance. > Does it mean that the driver also functions as a network driver directly? >> >>> This driver has two roles. The first is as a PCIe endpoint virtio console >>> function, which is implemented using the PCIe endpoint framework and PCIe >>> EP virtio helpers. The second is as a virtual virtio console device >>> connected to the virtio bus on PCIe endpoint Linux. >>> >>> Communication between the two is achieved by copying the virtqueue data >>> between PCIe root and endpoint, respectively. >>> >>> This is a simple implementation and does not include features of >>> virtio-console such as MULTIPORT, EMERG_WRITE, etc. As a result, each >>> virtio console driver only displays /dev/hvc0. >>> >>> As an example of usage, by setting getty to /dev/hvc0, it is possible to >>> login to another host. >>> >>> Signed-off-by: Shunsuke Mie >>> --- >>> Changes from v2: >>> - Change to use copy functions between kiovs of pci-epf-virtio. >>> >>> drivers/pci/endpoint/functions/Kconfig | 12 + >>> drivers/pci/endpoint/functions/Makefile | 1 + >>> drivers/pci/endpoint/functions/pci-epf-vcon.c | 596 ++++++++++++++++++ >>> 3 files changed, 609 insertions(+) >>> create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c >>> >>> diff --git a/drivers/pci/endpoint/functions/Kconfig b/drivers/pci/endpoint/functions/Kconfig >>> index fa1a6a569a8f..9ce2698b67e1 100644 >>> --- a/drivers/pci/endpoint/functions/Kconfig >>> +++ b/drivers/pci/endpoint/functions/Kconfig >>> @@ -44,3 +44,15 @@ config PCI_EPF_VIRTIO >>> select VHOST_RING_IOMEM >>> help >>> Helpers to implement PCI virtio Endpoint function >>> + >>> +config PCI_EPF_VCON >>> + tristate "PCI Endpoint virito-console driver" >>> + depends on PCI_ENDPOINT >>> + select VHOST_RING >>> + select PCI_EPF_VIRTIO >>> + help >>> + PCIe Endpoint virtio-console function implementatino. This module >>> + enables to show the virtio-console as pci device to PCIe host side, and >>> + another virtual virtio-console device registers to endpoint system. >>> + Those devices are connected virtually and can communicate each other. >>> + >>> diff --git a/drivers/pci/endpoint/functions/Makefile b/drivers/pci/endpoint/functions/Makefile >>> index a96f127ce900..b4056689ce33 100644 >>> --- a/drivers/pci/endpoint/functions/Makefile >>> +++ b/drivers/pci/endpoint/functions/Makefile >>> @@ -7,3 +7,4 @@ obj-$(CONFIG_PCI_EPF_TEST) += pci-epf-test.o >>> obj-$(CONFIG_PCI_EPF_NTB) += pci-epf-ntb.o >>> obj-$(CONFIG_PCI_EPF_VNTB) += pci-epf-vntb.o >>> obj-$(CONFIG_PCI_EPF_VIRTIO) += pci-epf-virtio.o >>> +obj-$(CONFIG_PCI_EPF_VCON) += pci-epf-vcon.o >>> diff --git a/drivers/pci/endpoint/functions/pci-epf-vcon.c b/drivers/pci/endpoint/functions/pci-epf-vcon.c >>> new file mode 100644 >>> index 000000000000..31f4247cd10f >>> --- /dev/null >>> +++ b/drivers/pci/endpoint/functions/pci-epf-vcon.c >>> @@ -0,0 +1,596 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> +/* >>> + * PCI Endpoint function driver to impliment virtio-console device >>> + * functionality. >>> + */ >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> + >>> +#include "pci-epf-virtio.h" >>> + >>> +static int virtio_queue_size = 0x100; >>> +module_param(virtio_queue_size, int, 0444); >>> +MODULE_PARM_DESC(virtio_queue_size, "A length of virtqueue"); >>> + >>> +struct epf_vcon { >>> + /* To access virtqueues on remote host */ >>> + struct epf_virtio evio; >>> + struct vringh_kiov *rdev_iovs; >>> + >>> + /* To register a local virtio bus */ >>> + struct virtio_device vdev; >>> + >>> + /* To access virtqueus of local host driver */ >>> + struct vringh *vdev_vrhs; >>> + struct vringh_kiov *vdev_iovs; >>> + struct virtqueue **vdev_vqs; >>> + >>> + /* For transportation and notification */ >>> + struct workqueue_struct *task_wq; >>> + struct work_struct raise_irq_work, rx_work, tx_work; >>> + >>> + /* To retain virtio features. It is commonly used local and remote. */ >>> + u64 features; >>> + >>> + /* To show a status whether this driver is ready and the remote is connected */ >>> + bool connected; >>> +}; >>> + >>> +enum { >>> + VCON_VIRTQUEUE_RX, >>> + VCON_VIRTQUEUE_TX, >>> + // Should be end of enum >>> + VCON_VIRTQUEUE_NUM >>> +}; >> It would be better if we can split the console specific thing out, >> then it allows us to do ethernet and vsock in the future. > I'm planning to implement each virtio device in a separate file. > https://lwn.net/Articles/922124/ > > > >> Thanks >> > Best regards, > Shunsuke