All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
	netdev@vger.kernel.org,
	"Willem de Bruijn" <willemdebruijn.kernel@gmail.com>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
	"Eugenio Pérez" <eperezma@redhat.com>
Subject: Re: [PATCH net-next 2/8] virtio_pci_modern: allow setting configuring extended features
Date: Thu, 29 May 2025 10:28:51 -0400	[thread overview]
Message-ID: <20250529102840-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <f0a36685-45d0-4c4a-a256-74f3d4a31bd5@redhat.com>

On Thu, May 29, 2025 at 01:07:30PM +0200, Paolo Abeni wrote:
> On 5/29/25 4:22 AM, Jason Wang wrote:
> > On Thu, May 29, 2025 at 12:02 AM Paolo Abeni <pabeni@redhat.com> wrote:
> >> On 5/27/25 5:04 AM, Jason Wang wrote:
> >>> On Mon, May 26, 2025 at 6:53 PM Paolo Abeni <pabeni@redhat.com> wrote:
> >>>> On 5/26/25 2:49 AM, Jason Wang wrote:
> >>>>> On Wed, May 21, 2025 at 6:33 PM Paolo Abeni <pabeni@redhat.com> wrote:
> >>>>>>
> >>>>>> The virtio specifications allows for up to 128 bits for the
> >>>>>> device features. Soon we are going to use some of the 'extended'
> >>>>>> bits features (above 64) for the virtio_net driver.
> >>>>>>
> >>>>>> Extend the virtio pci modern driver to support configuring the full
> >>>>>> virtio features range, replacing the unrolled loops reading and
> >>>>>> writing the features space with explicit one bounded to the actual
> >>>>>> features space size in word.
> >>>>>>
> >>>>>> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> >>>>>> ---
> >>>>>>  drivers/virtio/virtio_pci_modern_dev.c | 39 +++++++++++++++++---------
> >>>>>>  1 file changed, 25 insertions(+), 14 deletions(-)
> >>>>>>
> >>>>>> diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c
> >>>>>> index 1d34655f6b658..e3025b6fa8540 100644
> >>>>>> --- a/drivers/virtio/virtio_pci_modern_dev.c
> >>>>>> +++ b/drivers/virtio/virtio_pci_modern_dev.c
> >>>>>> @@ -396,12 +396,16 @@ EXPORT_SYMBOL_GPL(vp_modern_remove);
> >>>>>>  virtio_features_t vp_modern_get_features(struct virtio_pci_modern_device *mdev)
> >>>>>>  {
> >>>>>>         struct virtio_pci_common_cfg __iomem *cfg = mdev->common;
> >>>>>> -       virtio_features_t features;
> >>>>>> +       virtio_features_t features = 0;
> >>>>>> +       int i;
> >>>>>>
> >>>>>> -       vp_iowrite32(0, &cfg->device_feature_select);
> >>>>>> -       features = vp_ioread32(&cfg->device_feature);
> >>>>>> -       vp_iowrite32(1, &cfg->device_feature_select);
> >>>>>> -       features |= ((u64)vp_ioread32(&cfg->device_feature) << 32);
> >>>>>> +       for (i = 0; i < VIRTIO_FEATURES_WORDS; i++) {
> >>>>>> +               virtio_features_t cur;
> >>>>>> +
> >>>>>> +               vp_iowrite32(i, &cfg->device_feature_select);
> >>>>>> +               cur = vp_ioread32(&cfg->device_feature);
> >>>>>> +               features |= cur << (32 * i);
> >>>>>> +       }
> >>>>>
> >>>>> No matter if we decide to go with 128bit or not. I think at the lower
> >>>>> layer like this, it's time to allow arbitrary length of the features
> >>>>> as the spec supports.
> >>>>
> >>>> Is that useful if the vhost interface is not going to support it?
> >>>
> >>> I think so, as there are hardware virtio devices that can benefit from this.
> >>
> >> Let me look at the question from another perspective. Let's suppose that
> >> the virtio device supports an arbitrary wide features space, and the
> >> uAPI allows passing to/from the kernel an arbitrary high number of features.
> >>
> >> How could the kernel stop the above loop? AFAICS the virtio spec does
> >> not define any way to detect the end of the features space. An arbitrary
> >> bound is actually needed.
> > 
> > I think this is a good question ad we have something that could work:
> > 
> > 1) current driver has drv->feature_table_size, so the driver knows
> > it's meaningless to read above the size
> > 
> > and
> > 
> > 2) we can extend the spec, e.g add a transport specific field to let
> > the driver to know the feature size
> 
> So I guess we can postpone any additional change here until we have some
> spec in place, right?
> 
> /P

Agree on this.


  reply	other threads:[~2025-05-29 14:29 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21 10:32 [PATCH net-next 0/8] virtio: introduce GSO over UDP tunnel Paolo Abeni
2025-05-21 10:32 ` [PATCH net-next 1/8] virtio: introduce virtio_features_t Paolo Abeni
2025-05-21 16:02   ` Michael S. Tsirkin
2025-05-22  7:29     ` Paolo Abeni
2025-05-22 15:26       ` Paolo Abeni
2025-05-23 19:50         ` Michael S. Tsirkin
2025-05-22  8:17   ` kernel test robot
2025-05-26  0:43   ` Jason Wang
2025-05-26  7:20     ` Paolo Abeni
2025-05-27  3:51       ` Jason Wang
2025-05-28 15:47         ` Paolo Abeni
2025-05-28 15:52           ` Michael S. Tsirkin
2025-05-29  2:15             ` Jason Wang
2025-05-27 14:14       ` Michael S. Tsirkin
2025-05-21 10:32 ` [PATCH net-next 2/8] virtio_pci_modern: allow setting configuring extended features Paolo Abeni
2025-05-26  0:49   ` Jason Wang
2025-05-26 10:53     ` Paolo Abeni
2025-05-27  3:04       ` Jason Wang
2025-05-28 16:02         ` Paolo Abeni
2025-05-29  2:22           ` Jason Wang
2025-05-29 11:07             ` Paolo Abeni
2025-05-29 14:28               ` Michael S. Tsirkin [this message]
2025-06-03  2:11               ` Jason Wang
2025-05-29 14:28           ` Michael S. Tsirkin
2025-05-21 10:32 ` [PATCH net-next 3/8] vhost-net: allow " Paolo Abeni
2025-05-26  0:47   ` Jason Wang
2025-05-26 10:57     ` Paolo Abeni
2025-05-27  3:56       ` Jason Wang
2025-05-29 11:10         ` Paolo Abeni
2025-06-03  2:11           ` Jason Wang
2025-05-21 10:32 ` [PATCH net-next 4/8] virtio_net: add supports for extended offloads Paolo Abeni
2025-05-26  1:01   ` Jason Wang
2025-05-21 10:32 ` [PATCH net-next 5/8] net: implement virtio helpers to handle UDP GSO tunneling Paolo Abeni
2025-05-22 22:29   ` Willem de Bruijn
2025-05-23  6:09     ` Paolo Abeni
2025-05-23  6:44       ` Paolo Abeni
2025-05-23 13:42       ` Willem de Bruijn
2025-05-23 14:00         ` Paolo Abeni
2025-05-26  4:40   ` Jason Wang
2025-05-29 11:55     ` Paolo Abeni
2025-05-30  8:43       ` Paolo Abeni
2025-06-03  2:11       ` Jason Wang
2025-05-29 15:30     ` Paolo Abeni
2025-06-03  2:11       ` Jason Wang
2025-05-21 10:32 ` [PATCH net-next 6/8] virtio_net: enable gso over UDP tunnel support Paolo Abeni
2025-05-22  8:38   ` kernel test robot
2025-05-22 22:33   ` Willem de Bruijn
2025-05-21 10:32 ` [PATCH net-next 7/8] tun: " Paolo Abeni
2025-05-26  4:40   ` Jason Wang
2025-05-26 11:20     ` Paolo Abeni
2025-05-27  4:19       ` Jason Wang
2025-05-29 16:17         ` Paolo Abeni
2025-06-03  2:11           ` Jason Wang
2025-05-21 10:32 ` [PATCH net-next 8/8] vhost/net: " Paolo Abeni
2025-05-22  6:43   ` kernel test robot
2025-05-23 19:54     ` Michael S. Tsirkin
2025-05-26  4:40   ` Jason Wang
2025-05-21 11:38 ` [PATCH net-next 0/8] virtio: introduce GSO over UDP tunnel Paolo Abeni
2025-05-21 15:52 ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250529102840-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.