From: "Michael S. Tsirkin" <mst@redhat.com>
To: Parav Pandit <parav@nvidia.com>
Cc: "Zhu, Lingshan" <lingshan.zhu@intel.com>,
"jasowang@redhat.com" <jasowang@redhat.com>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"xieyongji@bytedance.com" <xieyongji@bytedance.com>,
"gautam.dawar@amd.com" <gautam.dawar@amd.com>
Subject: Re: [PATCH 2/2] vDPA: conditionally read fields in virtio-net dev
Date: Tue, 16 Aug 2022 17:09:53 -0400 [thread overview]
Message-ID: <20220816170753-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <PH0PR12MB5481EBA9E08963DEF0743063DC6B9@PH0PR12MB5481.namprd12.prod.outlook.com>
On Tue, Aug 16, 2022 at 09:02:17PM +0000, Parav Pandit wrote:
>
> > From: Zhu, Lingshan <lingshan.zhu@intel.com>
> > Sent: Tuesday, August 16, 2022 12:19 AM
> >
> >
> > On 8/16/2022 10:32 AM, Parav Pandit wrote:
> > >> From: Zhu Lingshan <lingshan.zhu@intel.com>
> > >> Sent: Monday, August 15, 2022 5:27 AM
> > >>
> > >> Some fields of virtio-net device config space are conditional on the
> > >> feature bits, the spec says:
> > >>
> > >> "The mac address field always exists
> > >> (though is only valid if VIRTIO_NET_F_MAC is set)"
> > >>
> > >> "max_virtqueue_pairs only exists if VIRTIO_NET_F_MQ or
> > >> VIRTIO_NET_F_RSS is set"
> > >>
> > >> "mtu only exists if VIRTIO_NET_F_MTU is set"
> > >>
> > >> so we should read MTU, MAC and MQ in the device config space only
> > >> when these feature bits are offered.
> > > Yes.
> > >
> > >> For MQ, if both VIRTIO_NET_F_MQ and VIRTIO_NET_F_RSS are not set,
> > the
> > >> virtio device should have one queue pair as default value, so when
> > >> userspace querying queue pair numbers, it should return mq=1 than zero.
> > > No.
> > > No need to treat mac and max_qps differently.
> > > It is meaningless to differentiate when field exist/not-exists vs value
> > valid/not valid.
> > as we discussed before, MQ has a default value 1, to be a functional virtio-
> > net device, while MAC has no default value, if no VIRTIO_NET_F_MAC set,
> > the driver should generate a random MAC.
> > >
> > >> For MTU, if VIRTIO_NET_F_MTU is not set, we should not read MTU from
> > >> the device config sapce.
> > >> RFC894 <A Standard for the Transmission of IP Datagrams over Ethernet
> > >> Networks> says:"The minimum length of the data field of a packet sent
> > >> Networks> over
> > >> an Ethernet is 1500 octets, thus the maximum length of an IP datagram
> > >> sent over an Ethernet is 1500 octets. Implementations are encouraged
> > >> to support full-length packets"
> > > This line in the RFC 894 of 1984 is wrong.
> > > Errata already exists for it at [1].
> > >
> > > [1] https://www.rfc-editor.org/errata_search.php?rfc=894&rec_status=0
> > OK, so I think we should return nothing if _F_MTU not set, like handling the
> > MAC
> > >
> > >> virtio spec says:"The virtio network device is a virtual ethernet
> > >> card", so the default MTU value should be 1500 for virtio-net.
> > >>
> > > Practically I have seen 1500 and highe mtu.
> > > And this derivation is not good of what should be the default mtu as above
> > errata exists.
> > >
> > > And I see the code below why you need to work so hard to define a default
> > value so that _MQ and _MTU can report default values.
> > >
> > > There is really no need for this complexity and such a long commit
> > message.
> > >
> > > Can we please expose feature bits as-is and report config space field which
> > are valid?
> > >
> > > User space will be querying both.
> > I think MAC and MTU don't have default values, so return nothing if the
> > feature bits not set,
>
> > for MQ, it is still max_vq_paris == 1 by default.
>
> I have stressed enough to highlight the fact that we don’t want to start digging default/no default, valid/no-valid part of the spec.
> I prefer kernel to reporting fields that _exists_ in the config space and are valid.
> I will let MST to handle the maintenance nightmare that this kind of patch brings in without any visible gain to user space/orchestration apps.
>
> A logic that can be easily build in user space, should be written in user space.
> I conclude my thoughts here for this discussion.
>
> I will let MST to decide how he prefers to proceed.
>
> >
> > >> + if ((features & BIT_ULL(VIRTIO_NET_F_MTU)) == 0)
> > >> + val_u16 = 1500;
> > >> + else
> > >> + val_u16 = __virtio16_to_cpu(true, config->mtu);
> > >> +
> > > Need to work hard to find default values and that too turned out had
> > errata.
> > > There are more fields that doesn’t have default values.
> > >
> > > There is no point in kernel doing this guess work, that user space can figure
> > out of what is valid/invalid.
> > It's not guest work, when guest finds no feature bits set, it can decide what
> > to do.
>
> Above code of doing 1500 was probably an honest attempt to find a legitimate default value, and we saw that it doesn’t work.
> This is second example after _MQ that we both agree should not return default.
>
> And there are more fields coming in this area.
> Hence, I prefer to not avoid returning such defaults for MAC, MTU, MQ and rest all fields which doesn’t _exists_.
>
> I will let MST to decide how he prefers to proceed for every field to come next.
> Thanks.
>
If MTU does not return a value without _F_MTU, and MAC does not return
a value without _F_MAC then IMO yes, number of queues should not return
a value without _F_MQ.
--
MST
next prev parent reply other threads:[~2022-08-16 21:10 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 9:26 [PATCH 0/2] allow userspace to query device features Zhu Lingshan
2022-08-15 9:26 ` [PATCH 1/2] vDPA: allow userspace to query features of a vDPA device Zhu Lingshan
2022-08-15 18:15 ` Si-Wei Liu
2022-08-16 1:49 ` Zhu, Lingshan
2022-08-16 2:07 ` Parav Pandit
2022-08-16 4:21 ` Zhu, Lingshan
2022-08-15 9:26 ` [PATCH 2/2] vDPA: conditionally read fields in virtio-net dev Zhu Lingshan
2022-08-15 15:52 ` Michael S. Tsirkin
2022-08-15 23:32 ` Si-Wei Liu
2022-08-16 1:58 ` Zhu, Lingshan
2022-08-16 4:26 ` Zhu, Lingshan
2022-08-16 7:58 ` Si-Wei Liu
2022-08-16 9:08 ` Zhu, Lingshan
2022-08-16 23:14 ` Si-Wei Liu
2022-08-17 2:14 ` Zhu, Lingshan
2022-08-17 8:55 ` Michael S. Tsirkin
2022-08-17 9:13 ` Zhu, Lingshan
2022-08-17 9:39 ` Michael S. Tsirkin
2022-08-17 9:43 ` Zhu, Lingshan
2022-08-17 10:37 ` Michael S. Tsirkin
2022-08-18 4:15 ` Jason Wang
2022-08-18 7:58 ` Zhu, Lingshan
2022-08-18 23:20 ` Si-Wei Liu
2022-08-19 0:42 ` Jason Wang
2022-08-19 3:52 ` Michael S. Tsirkin
2022-08-20 8:55 ` Si-Wei Liu
2022-08-22 5:07 ` Zhu, Lingshan
2022-08-23 3:26 ` Jason Wang
2022-08-23 6:52 ` Zhu, Lingshan
2022-08-30 9:43 ` Zhu, Lingshan
2022-08-26 6:23 ` Si-Wei Liu
2022-09-02 6:03 ` Jason Wang
2022-09-02 6:14 ` Michael S. Tsirkin
2022-09-05 3:54 ` Jason Wang
2022-08-16 2:32 ` Parav Pandit
2022-08-16 4:18 ` Zhu, Lingshan
2022-08-16 21:02 ` Parav Pandit
2022-08-16 21:09 ` Michael S. Tsirkin [this message]
2022-08-17 2:03 ` Zhu, Lingshan
2022-08-18 4:18 ` Jason Wang
2022-08-18 6:38 ` Zhu, Lingshan
2022-08-18 17:20 ` Parav Pandit
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=20220816170753-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=gautam.dawar@amd.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lingshan.zhu@intel.com \
--cc=netdev@vger.kernel.org \
--cc=parav@nvidia.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=xieyongji@bytedance.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).