All of lore.kernel.org
 help / color / mirror / Atom feed
* [virtio-dev] [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-22 12:12 ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-22 12:12 UTC (permalink / raw)
  To: virtio-dev, virtio-comment
  Cc: Michael S . Tsirkin, Jason Wang, Parav Pandit, Xuan Zhuo


Currently, the VIRTIO_NET_F_GUEST_CSUM(NETIF_F_RXCSUM) feature of the virtio-net
driver conflicts with the loading of the XDP program, which is caused by the
problem described in [1][2], that is, XDP may cause errors in partial csumed-related
fields and resulting in packet dropping. rx CHECKSUM_PARTIAL mainly exists in the
virtualized environment, and its purpose is to save computing resource overhead.

The *goal* of this proposal is to enable the coexistence of XDP and VIRTIO_NET_F_GUEST_CSUM.

1. We need to understand why the device driver receives the rx CHECKSUM_PARTIAL packet.

Drivers related to the virtualized environment, such as virtio-net/veth/loopback,
etc., may receive partial csumed packets.

When the tx device finds that the destination rx device of the packet is
located on the same host, it is clear that the packet may not pass through
the physical link, so the tx device sends the packet with csum_{start, offset}
directly to the rx side to save computational resources without computing a fully csum
(depends on the specific implementation, some virtio-net backend devices are known to
behave like this currently). From [3], the stack trusts such packets.

However, veth still has NETIF_F_RXCSUM turned on when loading XDP. This may cause
packet dropping as [1][2] stated. But currently the veth community does not seem to
have reported such problems, can we guess that the coexistence of XDP and
rx CHECKSUM_PARTIAL has less negative impact?

2. About rx CHECKSUM_UNECESSARY:

We have just seen that in a virtualized environment a packet may flow between the
same host, so not computing the complete csum for the packet saves some cpu resources.

The purpose of the checksum is to verify that packets passing through the
physical link are correct. Of course, it is also reasonable to do a fully csum for
packets of the virtualized environment, which is exactly what we need.

rx CHECKSUM_UNECESSARY indicates that the packet has been fully checked,
that is, it is a credible packet. If such a packet is modified by the XDP program,
the user should recalculate the correct checksum using bpf_csum_diff() and
bpf_{l3,l4}_csum_replace().

Therefore, for those drivers(physical nic drivers?), such as atlantic/bnxt/mlx,
etc., XDP and NETIF_F_RXCSUM coexist, because their packets will be fully checked
at the tx side.

AWS's ena driver is also designed to be in this fully checksum mode
(we also mentioned below that a feature bit can be provided for virtio-net,
telling the sender that a fully checksum must be calculated to implement similar
behavior to other drivers), although it is in a virtualized environment.

3. To sum up:

It seems that only virtio-net sets XDP and VIRTIO_NET_F_GUEST_CSUM as mutually
exclusive, which may cause the following problems:

When XDP loads,

1) For packets that are fully checked by the sender, packets are marked as CHECKSUM_UNECESSARY
by the rx csum hw offloading.

virtio-net driver needs additional CPU resources to compute the checksum for any packet.

When testing with the following command in Aliyun ECS:
    qperf dst_ip -lp 8989 -m 64K -t 20 tcp_bw
    (mtu = 1500, dev layer GRO is on)

The csum-related overhead we tested on X86 is 11.7%, and on ARM is 15.8%.

2)
One of the main functions of the XDP prog is to be used as a monitoring and
firewall, etc., which means that the XDP prog may not modify the packet.
This is applicable to both rx CHECKSUM_PARTIAL and rx CHECKSUM_UNECESSARY,
but we ignore the rx csum hw offloading capability for both cases.

4. How we try to solve:

1) Add a feature bit to the virtio specification to tell the sender that a fully
csumed packet must be sent. Then XDP can coexist with VIRTIO_NET_F_GUEST_CSUM when this
feature bit is negotiated. (similar to ENA behavior)

2) Modify the current virtio-net driver

No longer filter the VIRTIO_NET_F_GUEST_CSUM feature in virtnet_xdp_set().
Then we can immediately get the ability from VIRTIO_NET_F_GUEST_CSUM and enjoy the software
CPU resources saved by rx csum hw offloading.
(This method is a bit rude)

5. Ending 

This is a proposal and does not represent a formal solution. Looking forward to feedback
from the community and exploring a possible/common solution to the problem described in
this proposal.

6. Quote

[1] 18ba58e1c234

    virtio-net: fail XDP set if guest csum is negotiated

    We don't support partial csumed packet since its metadata will be lost
    or incorrect during XDP processing. So fail the XDP set if guest_csum
    feature is negotiated.

[2] e59ff2c49ae1

    virtio-net: disable guest csum during XDP set

    We don't disable VIRTIO_NET_F_GUEST_CSUM if XDP was set. This means we
    can receive partial csumed packets with metadata kept in the
    vnet_hdr. This may have several side effects:

    - It could be overridden by header adjustment, thus is might be not
      correct after XDP processing.
    - There's no way to pass such metadata information through
      XDP_REDIRECT to another driver.
    - XDP does not support checksum offload right now.

    So simply disable guest csum if possible in this the case of XDP.

[3] static inline int skb_csum_unnecessary(const struct sk_buff *skb)
    {
        return ((skb->ip_summed == CHECKSUM_UNNECESSARY) ||
            skb->csum_valid ||
            (skb->ip_summed == CHECKSUM_PARTIAL &&
            skb_checksum_start_offset(skb) >= 0));
    }


Thanks a lot!
-- 
2.19.1.6.gb485710b


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-22 12:12 ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-22 12:12 UTC (permalink / raw)
  To: virtio-dev, virtio-comment
  Cc: Michael S . Tsirkin, Jason Wang, Parav Pandit, Xuan Zhuo


Currently, the VIRTIO_NET_F_GUEST_CSUM(NETIF_F_RXCSUM) feature of the virtio-net
driver conflicts with the loading of the XDP program, which is caused by the
problem described in [1][2], that is, XDP may cause errors in partial csumed-related
fields and resulting in packet dropping. rx CHECKSUM_PARTIAL mainly exists in the
virtualized environment, and its purpose is to save computing resource overhead.

The *goal* of this proposal is to enable the coexistence of XDP and VIRTIO_NET_F_GUEST_CSUM.

1. We need to understand why the device driver receives the rx CHECKSUM_PARTIAL packet.

Drivers related to the virtualized environment, such as virtio-net/veth/loopback,
etc., may receive partial csumed packets.

When the tx device finds that the destination rx device of the packet is
located on the same host, it is clear that the packet may not pass through
the physical link, so the tx device sends the packet with csum_{start, offset}
directly to the rx side to save computational resources without computing a fully csum
(depends on the specific implementation, some virtio-net backend devices are known to
behave like this currently). From [3], the stack trusts such packets.

However, veth still has NETIF_F_RXCSUM turned on when loading XDP. This may cause
packet dropping as [1][2] stated. But currently the veth community does not seem to
have reported such problems, can we guess that the coexistence of XDP and
rx CHECKSUM_PARTIAL has less negative impact?

2. About rx CHECKSUM_UNECESSARY:

We have just seen that in a virtualized environment a packet may flow between the
same host, so not computing the complete csum for the packet saves some cpu resources.

The purpose of the checksum is to verify that packets passing through the
physical link are correct. Of course, it is also reasonable to do a fully csum for
packets of the virtualized environment, which is exactly what we need.

rx CHECKSUM_UNECESSARY indicates that the packet has been fully checked,
that is, it is a credible packet. If such a packet is modified by the XDP program,
the user should recalculate the correct checksum using bpf_csum_diff() and
bpf_{l3,l4}_csum_replace().

Therefore, for those drivers(physical nic drivers?), such as atlantic/bnxt/mlx,
etc., XDP and NETIF_F_RXCSUM coexist, because their packets will be fully checked
at the tx side.

AWS's ena driver is also designed to be in this fully checksum mode
(we also mentioned below that a feature bit can be provided for virtio-net,
telling the sender that a fully checksum must be calculated to implement similar
behavior to other drivers), although it is in a virtualized environment.

3. To sum up:

It seems that only virtio-net sets XDP and VIRTIO_NET_F_GUEST_CSUM as mutually
exclusive, which may cause the following problems:

When XDP loads,

1) For packets that are fully checked by the sender, packets are marked as CHECKSUM_UNECESSARY
by the rx csum hw offloading.

virtio-net driver needs additional CPU resources to compute the checksum for any packet.

When testing with the following command in Aliyun ECS:
    qperf dst_ip -lp 8989 -m 64K -t 20 tcp_bw
    (mtu = 1500, dev layer GRO is on)

The csum-related overhead we tested on X86 is 11.7%, and on ARM is 15.8%.

2)
One of the main functions of the XDP prog is to be used as a monitoring and
firewall, etc., which means that the XDP prog may not modify the packet.
This is applicable to both rx CHECKSUM_PARTIAL and rx CHECKSUM_UNECESSARY,
but we ignore the rx csum hw offloading capability for both cases.

4. How we try to solve:

1) Add a feature bit to the virtio specification to tell the sender that a fully
csumed packet must be sent. Then XDP can coexist with VIRTIO_NET_F_GUEST_CSUM when this
feature bit is negotiated. (similar to ENA behavior)

2) Modify the current virtio-net driver

No longer filter the VIRTIO_NET_F_GUEST_CSUM feature in virtnet_xdp_set().
Then we can immediately get the ability from VIRTIO_NET_F_GUEST_CSUM and enjoy the software
CPU resources saved by rx csum hw offloading.
(This method is a bit rude)

5. Ending 

This is a proposal and does not represent a formal solution. Looking forward to feedback
from the community and exploring a possible/common solution to the problem described in
this proposal.

6. Quote

[1] 18ba58e1c234

    virtio-net: fail XDP set if guest csum is negotiated

    We don't support partial csumed packet since its metadata will be lost
    or incorrect during XDP processing. So fail the XDP set if guest_csum
    feature is negotiated.

[2] e59ff2c49ae1

    virtio-net: disable guest csum during XDP set

    We don't disable VIRTIO_NET_F_GUEST_CSUM if XDP was set. This means we
    can receive partial csumed packets with metadata kept in the
    vnet_hdr. This may have several side effects:

    - It could be overridden by header adjustment, thus is might be not
      correct after XDP processing.
    - There's no way to pass such metadata information through
      XDP_REDIRECT to another driver.
    - XDP does not support checksum offload right now.

    So simply disable guest csum if possible in this the case of XDP.

[3] static inline int skb_csum_unnecessary(const struct sk_buff *skb)
    {
        return ((skb->ip_summed == CHECKSUM_UNNECESSARY) ||
            skb->csum_valid ||
            (skb->ip_summed == CHECKSUM_PARTIAL &&
            skb_checksum_start_offset(skb) >= 0));
    }


Thanks a lot!
-- 
2.19.1.6.gb485710b


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-22 12:12 ` [virtio-comment] " Heng Qi
@ 2023-05-22 19:10   ` Michael S. Tsirkin
  -1 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-22 19:10 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> 1) Add a feature bit to the virtio specification to tell the sender that a fully
> csumed packet must be sent.

Who is the sender in this picture? The driver?

-- 
MST


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-22 19:10   ` Michael S. Tsirkin
  0 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-22 19:10 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> 1) Add a feature bit to the virtio specification to tell the sender that a fully
> csumed packet must be sent.

Who is the sender in this picture? The driver?

-- 
MST


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-22 19:10   ` [virtio-comment] " Michael S. Tsirkin
@ 2023-05-23  2:41     ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-23  2:41 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > csumed packet must be sent.
> 
> Who is the sender in this picture? The driver?

The device or the driver.

When the device is hw, the sender is more likely to be a device.
When the device is sw, the sender can be a device or a driver.

But in general, this feature is inclined to constrain the behavior of the device and
the driver from the receiving side.

For example: 
VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.

Then the specific implementation can be

(1) the sender sends a fully csumed packet;
(2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
    (because the two parties in the communication are located on the same host, the packet is trusted.).

In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.

Thanks.

> 
> -- 
> MST

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-23  2:41     ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-23  2:41 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > csumed packet must be sent.
> 
> Who is the sender in this picture? The driver?

The device or the driver.

When the device is hw, the sender is more likely to be a device.
When the device is sw, the sender can be a device or a driver.

But in general, this feature is inclined to constrain the behavior of the device and
the driver from the receiving side.

For example: 
VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.

Then the specific implementation can be

(1) the sender sends a fully csumed packet;
(2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
    (because the two parties in the communication are located on the same host, the packet is trusted.).

In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.

Thanks.

> 
> -- 
> MST

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-23  2:41     ` [virtio-comment] " Heng Qi
@ 2023-05-23  7:15       ` Michael S. Tsirkin
  -1 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-23  7:15 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > csumed packet must be sent.
> > 
> > Who is the sender in this picture? The driver?
> 
> The device or the driver.
> 
> When the device is hw, the sender is more likely to be a device.
> When the device is sw, the sender can be a device or a driver.
>
> But in general, this feature is inclined to constrain the behavior of the device and
> the driver from the receiving side.

Based on above I am guessing you are talking about driver getting
packets from device, I wish you used terms from virtio spec.

> For example: 
> VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> 
> Then the specific implementation can be
> 
> (1) the sender sends a fully csumed packet;
> (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
>     (because the two parties in the communication are located on the same host, the packet is trusted.).
> 
> In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> 
> Thanks.

This is what clearing VIRTIO_NET_F_GUEST_CSUM does.

I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
disables all offloads but you want to keep some of them?

Again please use virtio terminology not Linux. to help you out,
in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.


-- 
MST


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-23  7:15       ` Michael S. Tsirkin
  0 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-23  7:15 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > csumed packet must be sent.
> > 
> > Who is the sender in this picture? The driver?
> 
> The device or the driver.
> 
> When the device is hw, the sender is more likely to be a device.
> When the device is sw, the sender can be a device or a driver.
>
> But in general, this feature is inclined to constrain the behavior of the device and
> the driver from the receiving side.

Based on above I am guessing you are talking about driver getting
packets from device, I wish you used terms from virtio spec.

> For example: 
> VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> 
> Then the specific implementation can be
> 
> (1) the sender sends a fully csumed packet;
> (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
>     (because the two parties in the communication are located on the same host, the packet is trusted.).
> 
> In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> 
> Thanks.

This is what clearing VIRTIO_NET_F_GUEST_CSUM does.

I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
disables all offloads but you want to keep some of them?

Again please use virtio terminology not Linux. to help you out,
in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.


-- 
MST


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-23  7:15       ` [virtio-comment] " Michael S. Tsirkin
@ 2023-05-23  9:18         ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-23  9:18 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > csumed packet must be sent.
> > > 
> > > Who is the sender in this picture? The driver?
> > 
> > The device or the driver.
> > 
> > When the device is hw, the sender is more likely to be a device.
> > When the device is sw, the sender can be a device or a driver.
> >
> > But in general, this feature is inclined to constrain the behavior of the device and
> > the driver from the receiving side.
> 
> Based on above I am guessing you are talking about driver getting
> packets from device, I wish you used terms from virtio spec.

Yes, I'm going to use the terminology of the virtio spec.

> 
> > For example: 
> > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > 
> > Then the specific implementation can be
> > 
> > (1) the sender sends a fully csumed packet;
> > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > 
> > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > 
> > Thanks.
> 
> This is what clearing VIRTIO_NET_F_GUEST_CSUM does.

Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
receive a fully checksummed packet, we can no longer enjoy
the device's ability to validate the packet checksum. That is, the value
of \field{flags} in the virtio_net_hdr structure is set to 0, which means
that the packet received by the driver will not be marked as
VIRTIO_NET_HDR_F_DATA_VALID.

So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
driver a fully checksummed packet, and the packet is validated by the
device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.

> 
> I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> disables all offloads but you want to keep some of them?
> 

No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
then the driver may always receive packets marked as
VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
same time.

> Again please use virtio terminology not Linux. to help you out,
> in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> 

Sure. Will do as you suggested.

Thanks.

> 
> -- 
> MST
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-23  9:18         ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-23  9:18 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > csumed packet must be sent.
> > > 
> > > Who is the sender in this picture? The driver?
> > 
> > The device or the driver.
> > 
> > When the device is hw, the sender is more likely to be a device.
> > When the device is sw, the sender can be a device or a driver.
> >
> > But in general, this feature is inclined to constrain the behavior of the device and
> > the driver from the receiving side.
> 
> Based on above I am guessing you are talking about driver getting
> packets from device, I wish you used terms from virtio spec.

Yes, I'm going to use the terminology of the virtio spec.

> 
> > For example: 
> > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > 
> > Then the specific implementation can be
> > 
> > (1) the sender sends a fully csumed packet;
> > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > 
> > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > 
> > Thanks.
> 
> This is what clearing VIRTIO_NET_F_GUEST_CSUM does.

Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
receive a fully checksummed packet, we can no longer enjoy
the device's ability to validate the packet checksum. That is, the value
of \field{flags} in the virtio_net_hdr structure is set to 0, which means
that the packet received by the driver will not be marked as
VIRTIO_NET_HDR_F_DATA_VALID.

So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
driver a fully checksummed packet, and the packet is validated by the
device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.

> 
> I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> disables all offloads but you want to keep some of them?
> 

No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
then the driver may always receive packets marked as
VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
same time.

> Again please use virtio terminology not Linux. to help you out,
> in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> 

Sure. Will do as you suggested.

Thanks.

> 
> -- 
> MST
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-23  9:18         ` [virtio-comment] " Heng Qi
@ 2023-05-23 13:30           ` Michael S. Tsirkin
  -1 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-23 13:30 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > csumed packet must be sent.
> > > > 
> > > > Who is the sender in this picture? The driver?
> > > 
> > > The device or the driver.
> > > 
> > > When the device is hw, the sender is more likely to be a device.
> > > When the device is sw, the sender can be a device or a driver.
> > >
> > > But in general, this feature is inclined to constrain the behavior of the device and
> > > the driver from the receiving side.
> > 
> > Based on above I am guessing you are talking about driver getting
> > packets from device, I wish you used terms from virtio spec.
> 
> Yes, I'm going to use the terminology of the virtio spec.
> 
> > 
> > > For example: 
> > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > 
> > > Then the specific implementation can be
> > > 
> > > (1) the sender sends a fully csumed packet;
> > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > 
> > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > 
> > > Thanks.
> > 
> > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> 
> Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> receive a fully checksummed packet, we can no longer enjoy
> the device's ability to validate the packet checksum. That is, the value
> of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> that the packet received by the driver will not be marked as
> VIRTIO_NET_HDR_F_DATA_VALID.
> 
> So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> driver a fully checksummed packet, and the packet is validated by the
> device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> 
> > 
> > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > disables all offloads but you want to keep some of them?
> > 
> 
> No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> then the driver may always receive packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> same time.

Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
VIRTIO_NET_HDR_F_DATA_VALID:
\item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
  VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
  set: if so, the packet checksum at offset \field{csum_offset}
  from \field{csum_start} and any preceding checksums
  have been validated.  The checksum on the packet is incomplete and
  if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
  then \field{csum_start} and \field{csum_offset} indicate how to calculate it
  (see Packet Transmission point 1).

Did you maybe mean if either feature is negotiated?



> > Again please use virtio terminology not Linux. to help you out,
> > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > 
> 
> Sure. Will do as you suggested.
> 
> Thanks.
> 
> > 
> > -- 
> > MST
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-23 13:30           ` Michael S. Tsirkin
  0 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-23 13:30 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > csumed packet must be sent.
> > > > 
> > > > Who is the sender in this picture? The driver?
> > > 
> > > The device or the driver.
> > > 
> > > When the device is hw, the sender is more likely to be a device.
> > > When the device is sw, the sender can be a device or a driver.
> > >
> > > But in general, this feature is inclined to constrain the behavior of the device and
> > > the driver from the receiving side.
> > 
> > Based on above I am guessing you are talking about driver getting
> > packets from device, I wish you used terms from virtio spec.
> 
> Yes, I'm going to use the terminology of the virtio spec.
> 
> > 
> > > For example: 
> > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > 
> > > Then the specific implementation can be
> > > 
> > > (1) the sender sends a fully csumed packet;
> > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > 
> > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > 
> > > Thanks.
> > 
> > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> 
> Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> receive a fully checksummed packet, we can no longer enjoy
> the device's ability to validate the packet checksum. That is, the value
> of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> that the packet received by the driver will not be marked as
> VIRTIO_NET_HDR_F_DATA_VALID.
> 
> So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> driver a fully checksummed packet, and the packet is validated by the
> device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> 
> > 
> > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > disables all offloads but you want to keep some of them?
> > 
> 
> No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> then the driver may always receive packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> same time.

Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
VIRTIO_NET_HDR_F_DATA_VALID:
\item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
  VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
  set: if so, the packet checksum at offset \field{csum_offset}
  from \field{csum_start} and any preceding checksums
  have been validated.  The checksum on the packet is incomplete and
  if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
  then \field{csum_start} and \field{csum_offset} indicate how to calculate it
  (see Packet Transmission point 1).

Did you maybe mean if either feature is negotiated?



> > Again please use virtio terminology not Linux. to help you out,
> > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > 
> 
> Sure. Will do as you suggested.
> 
> Thanks.
> 
> > 
> > -- 
> > MST
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-23 13:30           ` [virtio-comment] " Michael S. Tsirkin
@ 2023-05-23 13:51             ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-23 13:51 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > csumed packet must be sent.
> > > > > 
> > > > > Who is the sender in this picture? The driver?
> > > > 
> > > > The device or the driver.
> > > > 
> > > > When the device is hw, the sender is more likely to be a device.
> > > > When the device is sw, the sender can be a device or a driver.
> > > >
> > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > the driver from the receiving side.
> > > 
> > > Based on above I am guessing you are talking about driver getting
> > > packets from device, I wish you used terms from virtio spec.
> > 
> > Yes, I'm going to use the terminology of the virtio spec.
> > 
> > > 
> > > > For example: 
> > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > 
> > > > Then the specific implementation can be
> > > > 
> > > > (1) the sender sends a fully csumed packet;
> > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > 
> > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > 
> > > > Thanks.
> > > 
> > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > 
> > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > receive a fully checksummed packet, we can no longer enjoy
> > the device's ability to validate the packet checksum. That is, the value
> > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > that the packet received by the driver will not be marked as
> > VIRTIO_NET_HDR_F_DATA_VALID.
> > 
> > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > driver a fully checksummed packet, and the packet is validated by the
> > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > 
> > > 
> > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > disables all offloads but you want to keep some of them?
> > > 
> > 
> > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > then the driver may always receive packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > same time.
> 
> Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> VIRTIO_NET_HDR_F_DATA_VALID:

We need to focus on what happens when the XDP program is loaded:

The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
feature when loading XDP. The main reason for doing this is because
VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
XDP programs, because we cannot guarantee that the csum_{start, offset}
fields are correct after XDP modifies the packets.

So in order for the driver to continue to enjoy the device's ability to
validate packets while XDP is loaded, we need a new feature to tell the
device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
other words, the device can only deliver packets marked as
VIRTIO_NET_HDR_F_DATA_VALID).

Thanks.

> \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
>   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
>   set: if so, the packet checksum at offset \field{csum_offset}
>   from \field{csum_start} and any preceding checksums
>   have been validated.  The checksum on the packet is incomplete and
>   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
>   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
>   (see Packet Transmission point 1).
> 
> Did you maybe mean if either feature is negotiated?
> 
> 
> 
> > > Again please use virtio terminology not Linux. to help you out,
> > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > 
> > 
> > Sure. Will do as you suggested.
> > 
> > Thanks.
> > 
> > > 
> > > -- 
> > > MST
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> 
> 
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
> 
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
> 
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-23 13:51             ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-23 13:51 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > csumed packet must be sent.
> > > > > 
> > > > > Who is the sender in this picture? The driver?
> > > > 
> > > > The device or the driver.
> > > > 
> > > > When the device is hw, the sender is more likely to be a device.
> > > > When the device is sw, the sender can be a device or a driver.
> > > >
> > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > the driver from the receiving side.
> > > 
> > > Based on above I am guessing you are talking about driver getting
> > > packets from device, I wish you used terms from virtio spec.
> > 
> > Yes, I'm going to use the terminology of the virtio spec.
> > 
> > > 
> > > > For example: 
> > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > 
> > > > Then the specific implementation can be
> > > > 
> > > > (1) the sender sends a fully csumed packet;
> > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > 
> > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > 
> > > > Thanks.
> > > 
> > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > 
> > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > receive a fully checksummed packet, we can no longer enjoy
> > the device's ability to validate the packet checksum. That is, the value
> > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > that the packet received by the driver will not be marked as
> > VIRTIO_NET_HDR_F_DATA_VALID.
> > 
> > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > driver a fully checksummed packet, and the packet is validated by the
> > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > 
> > > 
> > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > disables all offloads but you want to keep some of them?
> > > 
> > 
> > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > then the driver may always receive packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > same time.
> 
> Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> VIRTIO_NET_HDR_F_DATA_VALID:

We need to focus on what happens when the XDP program is loaded:

The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
feature when loading XDP. The main reason for doing this is because
VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
XDP programs, because we cannot guarantee that the csum_{start, offset}
fields are correct after XDP modifies the packets.

So in order for the driver to continue to enjoy the device's ability to
validate packets while XDP is loaded, we need a new feature to tell the
device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
other words, the device can only deliver packets marked as
VIRTIO_NET_HDR_F_DATA_VALID).

Thanks.

> \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
>   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
>   set: if so, the packet checksum at offset \field{csum_offset}
>   from \field{csum_start} and any preceding checksums
>   have been validated.  The checksum on the packet is incomplete and
>   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
>   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
>   (see Packet Transmission point 1).
> 
> Did you maybe mean if either feature is negotiated?
> 
> 
> 
> > > Again please use virtio terminology not Linux. to help you out,
> > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > 
> > 
> > Sure. Will do as you suggested.
> > 
> > Thanks.
> > 
> > > 
> > > -- 
> > > MST
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> 
> 
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
> 
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
> 
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-23 13:51             ` Heng Qi
@ 2023-05-24  4:09               ` Jason Wang
  -1 siblings, 0 replies; 34+ messages in thread
From: Jason Wang @ 2023-05-24  4:09 UTC (permalink / raw)
  To: Heng Qi
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>
> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > csumed packet must be sent.
> > > > > >
> > > > > > Who is the sender in this picture? The driver?
> > > > >
> > > > > The device or the driver.
> > > > >
> > > > > When the device is hw, the sender is more likely to be a device.
> > > > > When the device is sw, the sender can be a device or a driver.
> > > > >
> > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > the driver from the receiving side.
> > > >
> > > > Based on above I am guessing you are talking about driver getting
> > > > packets from device, I wish you used terms from virtio spec.
> > >
> > > Yes, I'm going to use the terminology of the virtio spec.
> > >
> > > >
> > > > > For example:
> > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > >
> > > > > Then the specific implementation can be
> > > > >
> > > > > (1) the sender sends a fully csumed packet;
> > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > >
> > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > >
> > > > > Thanks.
> > > >
> > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > >
> > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > receive a fully checksummed packet, we can no longer enjoy
> > > the device's ability to validate the packet checksum. That is, the value
> > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > that the packet received by the driver will not be marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID.
> > >
> > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > driver a fully checksummed packet, and the packet is validated by the
> > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > >
> > > >
> > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > disables all offloads but you want to keep some of them?
> > > >
> > >
> > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > then the driver may always receive packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > same time.
> >
> > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > VIRTIO_NET_HDR_F_DATA_VALID:
>
> We need to focus on what happens when the XDP program is loaded:
>
> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> feature when loading XDP. The main reason for doing this is because
> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> XDP programs, because we cannot guarantee that the csum_{start, offset}
> fields are correct after XDP modifies the packets.

We can try to fix or workaround this. A rough idea is for example by
using a flow dissector? Anyhow the GSO of virtio-net was marked as
dodgy which means the csum_start/offset needs to be validated again in
the xmit path. Or we can monitor if the packet is modified or not, if
not, we don't need to zero vnet header?

Thanks

>
> So in order for the driver to continue to enjoy the device's ability to
> validate packets while XDP is loaded, we need a new feature to tell the
> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> other words, the device can only deliver packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID).
>
> Thanks.
>
> > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> >   set: if so, the packet checksum at offset \field{csum_offset}
> >   from \field{csum_start} and any preceding checksums
> >   have been validated.  The checksum on the packet is incomplete and
> >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> >   (see Packet Transmission point 1).
> >
> > Did you maybe mean if either feature is negotiated?
> >
> >
> >
> > > > Again please use virtio terminology not Linux. to help you out,
> > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > >
> > >
> > > Sure. Will do as you suggested.
> > >
> > > Thanks.
> > >
> > > >
> > > > --
> > > > MST
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> >
> >
> > This publicly archived list offers a means to provide input to the
> > OASIS Virtual I/O Device (VIRTIO) TC.
> >
> > In order to verify user consent to the Feedback License terms and
> > to minimize spam in the list archive, subscription is required
> > before posting.
> >
> > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > List help: virtio-comment-help@lists.oasis-open.org
> > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > Committee: https://www.oasis-open.org/committees/virtio/
> > Join OASIS: https://www.oasis-open.org/join/
>


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-24  4:09               ` Jason Wang
  0 siblings, 0 replies; 34+ messages in thread
From: Jason Wang @ 2023-05-24  4:09 UTC (permalink / raw)
  To: Heng Qi
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>
> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > csumed packet must be sent.
> > > > > >
> > > > > > Who is the sender in this picture? The driver?
> > > > >
> > > > > The device or the driver.
> > > > >
> > > > > When the device is hw, the sender is more likely to be a device.
> > > > > When the device is sw, the sender can be a device or a driver.
> > > > >
> > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > the driver from the receiving side.
> > > >
> > > > Based on above I am guessing you are talking about driver getting
> > > > packets from device, I wish you used terms from virtio spec.
> > >
> > > Yes, I'm going to use the terminology of the virtio spec.
> > >
> > > >
> > > > > For example:
> > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > >
> > > > > Then the specific implementation can be
> > > > >
> > > > > (1) the sender sends a fully csumed packet;
> > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > >
> > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > >
> > > > > Thanks.
> > > >
> > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > >
> > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > receive a fully checksummed packet, we can no longer enjoy
> > > the device's ability to validate the packet checksum. That is, the value
> > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > that the packet received by the driver will not be marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID.
> > >
> > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > driver a fully checksummed packet, and the packet is validated by the
> > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > >
> > > >
> > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > disables all offloads but you want to keep some of them?
> > > >
> > >
> > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > then the driver may always receive packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > same time.
> >
> > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > VIRTIO_NET_HDR_F_DATA_VALID:
>
> We need to focus on what happens when the XDP program is loaded:
>
> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> feature when loading XDP. The main reason for doing this is because
> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> XDP programs, because we cannot guarantee that the csum_{start, offset}
> fields are correct after XDP modifies the packets.

We can try to fix or workaround this. A rough idea is for example by
using a flow dissector? Anyhow the GSO of virtio-net was marked as
dodgy which means the csum_start/offset needs to be validated again in
the xmit path. Or we can monitor if the packet is modified or not, if
not, we don't need to zero vnet header?

Thanks

>
> So in order for the driver to continue to enjoy the device's ability to
> validate packets while XDP is loaded, we need a new feature to tell the
> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> other words, the device can only deliver packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID).
>
> Thanks.
>
> > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> >   set: if so, the packet checksum at offset \field{csum_offset}
> >   from \field{csum_start} and any preceding checksums
> >   have been validated.  The checksum on the packet is incomplete and
> >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> >   (see Packet Transmission point 1).
> >
> > Did you maybe mean if either feature is negotiated?
> >
> >
> >
> > > > Again please use virtio terminology not Linux. to help you out,
> > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > >
> > >
> > > Sure. Will do as you suggested.
> > >
> > > Thanks.
> > >
> > > >
> > > > --
> > > > MST
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> >
> >
> > This publicly archived list offers a means to provide input to the
> > OASIS Virtual I/O Device (VIRTIO) TC.
> >
> > In order to verify user consent to the Feedback License terms and
> > to minimize spam in the list archive, subscription is required
> > before posting.
> >
> > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > List help: virtio-comment-help@lists.oasis-open.org
> > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > Committee: https://www.oasis-open.org/committees/virtio/
> > Join OASIS: https://www.oasis-open.org/join/
>


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
  2023-05-24  4:09               ` Jason Wang
@ 2023-05-24  5:07                 ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  5:07 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
> On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> >
> > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > csumed packet must be sent.
> > > > > > >
> > > > > > > Who is the sender in this picture? The driver?
> > > > > >
> > > > > > The device or the driver.
> > > > > >
> > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > >
> > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > the driver from the receiving side.
> > > > >
> > > > > Based on above I am guessing you are talking about driver getting
> > > > > packets from device, I wish you used terms from virtio spec.
> > > >
> > > > Yes, I'm going to use the terminology of the virtio spec.
> > > >
> > > > >
> > > > > > For example:
> > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > >
> > > > > > Then the specific implementation can be
> > > > > >
> > > > > > (1) the sender sends a fully csumed packet;
> > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > >
> > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > >
> > > > > > Thanks.
> > > > >
> > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > >
> > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > receive a fully checksummed packet, we can no longer enjoy
> > > > the device's ability to validate the packet checksum. That is, the value
> > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > that the packet received by the driver will not be marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > >
> > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > driver a fully checksummed packet, and the packet is validated by the
> > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > >
> > > > >
> > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > disables all offloads but you want to keep some of them?
> > > > >
> > > >
> > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > then the driver may always receive packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > same time.
> > >
> > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > VIRTIO_NET_HDR_F_DATA_VALID:
> >
> > We need to focus on what happens when the XDP program is loaded:
> >
> > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > feature when loading XDP. The main reason for doing this is because
> > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > fields are correct after XDP modifies the packets.
> 
> We can try to fix or workaround this. A rough idea is for example by
> using a flow dissector? 

How can we fix this with a flow dissector? Could you please explain in
detail?

> Anyhow the GSO of virtio-net was marked as
> dodgy which means the csum_start/offset needs to be validated again in
> the xmit path. Or we can monitor if the packet is modified or not, if
> not, we don't need to zero vnet header?

Yes, this is a way, and we've thought about this solution.
A relatively simple solution is to add a new flag to the XDP program
(through XDP core layer), which indicates that the XDP program is a
read-only XDP program (ie, does not modify the packet). Then to load
such an XDP program we no longer need to filter out the
VIRTIO_NET_F_GUEST_CSUM feature.

But why we didn't propose this solution in the 'Proposal', because it
seems that only virtio-net has encountered related problems. Virtual
network cards like veth, even if they receive partial csumed packets
(corresponding to virtio-net's packets marked as
VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
(corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
another trade-off: the current virtnet_xdp_set() no longer
filters out VIRTIO_NET_F_GUEST_CSUM.

The reasons I think are the following:
1. Referring to veth’s way, the XDP program is more of a
monitoring/firewall, and may not modify data packets.

2. We can still use XDP for packets marked as
VIRTIO_NET_HDR_F_DATA_VALID.

3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
(because ip_forward sysctl is disabled by default)

Thanks.

> 
> Thanks
> 
> >
> > So in order for the driver to continue to enjoy the device's ability to
> > validate packets while XDP is loaded, we need a new feature to tell the
> > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > other words, the device can only deliver packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID).
> >
> > Thanks.
> >
> > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > >   set: if so, the packet checksum at offset \field{csum_offset}
> > >   from \field{csum_start} and any preceding checksums
> > >   have been validated.  The checksum on the packet is incomplete and
> > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > >   (see Packet Transmission point 1).
> > >
> > > Did you maybe mean if either feature is negotiated?
> > >
> > >
> > >
> > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > >
> > > >
> > > > Sure. Will do as you suggested.
> > > >
> > > > Thanks.
> > > >
> > > > >
> > > > > --
> > > > > MST
> > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > >
> > >
> > > This publicly archived list offers a means to provide input to the
> > > OASIS Virtual I/O Device (VIRTIO) TC.
> > >
> > > In order to verify user consent to the Feedback License terms and
> > > to minimize spam in the list archive, subscription is required
> > > before posting.
> > >
> > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > List help: virtio-comment-help@lists.oasis-open.org
> > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > Committee: https://www.oasis-open.org/committees/virtio/
> > > Join OASIS: https://www.oasis-open.org/join/
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
@ 2023-05-24  5:07                 ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  5:07 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
> On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> >
> > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > csumed packet must be sent.
> > > > > > >
> > > > > > > Who is the sender in this picture? The driver?
> > > > > >
> > > > > > The device or the driver.
> > > > > >
> > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > >
> > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > the driver from the receiving side.
> > > > >
> > > > > Based on above I am guessing you are talking about driver getting
> > > > > packets from device, I wish you used terms from virtio spec.
> > > >
> > > > Yes, I'm going to use the terminology of the virtio spec.
> > > >
> > > > >
> > > > > > For example:
> > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > >
> > > > > > Then the specific implementation can be
> > > > > >
> > > > > > (1) the sender sends a fully csumed packet;
> > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > >
> > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > >
> > > > > > Thanks.
> > > > >
> > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > >
> > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > receive a fully checksummed packet, we can no longer enjoy
> > > > the device's ability to validate the packet checksum. That is, the value
> > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > that the packet received by the driver will not be marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > >
> > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > driver a fully checksummed packet, and the packet is validated by the
> > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > >
> > > > >
> > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > disables all offloads but you want to keep some of them?
> > > > >
> > > >
> > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > then the driver may always receive packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > same time.
> > >
> > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > VIRTIO_NET_HDR_F_DATA_VALID:
> >
> > We need to focus on what happens when the XDP program is loaded:
> >
> > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > feature when loading XDP. The main reason for doing this is because
> > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > fields are correct after XDP modifies the packets.
> 
> We can try to fix or workaround this. A rough idea is for example by
> using a flow dissector? 

How can we fix this with a flow dissector? Could you please explain in
detail?

> Anyhow the GSO of virtio-net was marked as
> dodgy which means the csum_start/offset needs to be validated again in
> the xmit path. Or we can monitor if the packet is modified or not, if
> not, we don't need to zero vnet header?

Yes, this is a way, and we've thought about this solution.
A relatively simple solution is to add a new flag to the XDP program
(through XDP core layer), which indicates that the XDP program is a
read-only XDP program (ie, does not modify the packet). Then to load
such an XDP program we no longer need to filter out the
VIRTIO_NET_F_GUEST_CSUM feature.

But why we didn't propose this solution in the 'Proposal', because it
seems that only virtio-net has encountered related problems. Virtual
network cards like veth, even if they receive partial csumed packets
(corresponding to virtio-net's packets marked as
VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
(corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
another trade-off: the current virtnet_xdp_set() no longer
filters out VIRTIO_NET_F_GUEST_CSUM.

The reasons I think are the following:
1. Referring to veth’s way, the XDP program is more of a
monitoring/firewall, and may not modify data packets.

2. We can still use XDP for packets marked as
VIRTIO_NET_HDR_F_DATA_VALID.

3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
(because ip_forward sysctl is disabled by default)

Thanks.

> 
> Thanks
> 
> >
> > So in order for the driver to continue to enjoy the device's ability to
> > validate packets while XDP is loaded, we need a new feature to tell the
> > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > other words, the device can only deliver packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID).
> >
> > Thanks.
> >
> > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > >   set: if so, the packet checksum at offset \field{csum_offset}
> > >   from \field{csum_start} and any preceding checksums
> > >   have been validated.  The checksum on the packet is incomplete and
> > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > >   (see Packet Transmission point 1).
> > >
> > > Did you maybe mean if either feature is negotiated?
> > >
> > >
> > >
> > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > >
> > > >
> > > > Sure. Will do as you suggested.
> > > >
> > > > Thanks.
> > > >
> > > > >
> > > > > --
> > > > > MST
> > > > >
> > > > >
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > >
> > >
> > > This publicly archived list offers a means to provide input to the
> > > OASIS Virtual I/O Device (VIRTIO) TC.
> > >
> > > In order to verify user consent to the Feedback License terms and
> > > to minimize spam in the list archive, subscription is required
> > > before posting.
> > >
> > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > List help: virtio-comment-help@lists.oasis-open.org
> > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > Committee: https://www.oasis-open.org/committees/virtio/
> > > Join OASIS: https://www.oasis-open.org/join/
> >

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-24  4:09               ` Jason Wang
@ 2023-05-24  5:17                 ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  5:17 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo



在 2023/5/24 下午12:09, Jason Wang 写道:
> On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
>>> On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
>>>> On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
>>>>> On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
>>>>>> On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
>>>>>>> On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
>>>>>>>> 1) Add a feature bit to the virtio specification to tell the sender that a fully
>>>>>>>> csumed packet must be sent.
>>>>>>> Who is the sender in this picture? The driver?
>>>>>> The device or the driver.
>>>>>>
>>>>>> When the device is hw, the sender is more likely to be a device.
>>>>>> When the device is sw, the sender can be a device or a driver.
>>>>>>
>>>>>> But in general, this feature is inclined to constrain the behavior of the device and
>>>>>> the driver from the receiving side.
>>>>> Based on above I am guessing you are talking about driver getting
>>>>> packets from device, I wish you used terms from virtio spec.
>>>> Yes, I'm going to use the terminology of the virtio spec.
>>>>
>>>>>> For example:
>>>>>> VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
>>>>>>
>>>>>> Then the specific implementation can be
>>>>>>
>>>>>> (1) the sender sends a fully csumed packet;
>>>>>> (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
>>>>>>      (because the two parties in the communication are located on the same host, the packet is trusted.).
>>>>>>
>>>>>> In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
>>>>>>
>>>>>> Thanks.
>>>>> This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
>>>> Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
>>>> receive a fully checksummed packet, we can no longer enjoy
>>>> the device's ability to validate the packet checksum. That is, the value
>>>> of \field{flags} in the virtio_net_hdr structure is set to 0, which means
>>>> that the packet received by the driver will not be marked as
>>>> VIRTIO_NET_HDR_F_DATA_VALID.
>>>>
>>>> So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
>>>> If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
>>>> driver a fully checksummed packet, and the packet is validated by the
>>>> device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
>>>>
>>>>> I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
>>>>> disables all offloads but you want to keep some of them?
>>>>>
>>>> No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
>>>> in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
>>>> then the driver may always receive packets marked as
>>>> VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
>>>> same time.
>>> Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
>>> VIRTIO_NET_HDR_F_DATA_VALID:
>> We need to focus on what happens when the XDP program is loaded:
>>
>> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
>> feature when loading XDP. The main reason for doing this is because
>> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
>> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
>> XDP programs, because we cannot guarantee that the csum_{start, offset}
>> fields are correct after XDP modifies the packets.
> We can try to fix or workaround this. A rough idea is for example by
> using a flow dissector? Anyhow the GSO of virtio-net was marked as
> dodgy which means the csum_start/offset needs to be validated again in
> the xmit path. Or we can monitor if the packet is modified or not, if
> not, we don't need to zero vnet header?

The reason why we prefer the method of adding a new feature is that it 
has portability and compatibility,
and the XDP program can be directly loaded when the feature is negotiated.

When the device resources are sufficient, it can choose to offer this 
feature bit.
When the device resources are insufficient or it want to optimize the 
same host communication for vms,
it can choose not to offer this feature bit.

Thanks.

>
> Thanks
>
>> So in order for the driver to continue to enjoy the device's ability to
>> validate packets while XDP is loaded, we need a new feature to tell the
>> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
>> other words, the device can only deliver packets marked as
>> VIRTIO_NET_HDR_F_DATA_VALID).
>>
>> Thanks.
>>
>>> \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
>>>    VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
>>>    set: if so, the packet checksum at offset \field{csum_offset}
>>>    from \field{csum_start} and any preceding checksums
>>>    have been validated.  The checksum on the packet is incomplete and
>>>    if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
>>>    then \field{csum_start} and \field{csum_offset} indicate how to calculate it
>>>    (see Packet Transmission point 1).
>>>
>>> Did you maybe mean if either feature is negotiated?
>>>
>>>
>>>
>>>>> Again please use virtio terminology not Linux. to help you out,
>>>>> in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
>>>>> will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
>>>>>
>>>> Sure. Will do as you suggested.
>>>>
>>>> Thanks.
>>>>
>>>>> --
>>>>> MST
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
>>>>> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
>>>
>>> This publicly archived list offers a means to provide input to the
>>> OASIS Virtual I/O Device (VIRTIO) TC.
>>>
>>> In order to verify user consent to the Feedback License terms and
>>> to minimize spam in the list archive, subscription is required
>>> before posting.
>>>
>>> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
>>> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
>>> List help: virtio-comment-help@lists.oasis-open.org
>>> List archive: https://lists.oasis-open.org/archives/virtio-comment/
>>> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
>>> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
>>> Committee: https://www.oasis-open.org/committees/virtio/
>>> Join OASIS: https://www.oasis-open.org/join/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-24  5:17                 ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  5:17 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo



在 2023/5/24 下午12:09, Jason Wang 写道:
> On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
>>> On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
>>>> On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
>>>>> On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
>>>>>> On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
>>>>>>> On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
>>>>>>>> 1) Add a feature bit to the virtio specification to tell the sender that a fully
>>>>>>>> csumed packet must be sent.
>>>>>>> Who is the sender in this picture? The driver?
>>>>>> The device or the driver.
>>>>>>
>>>>>> When the device is hw, the sender is more likely to be a device.
>>>>>> When the device is sw, the sender can be a device or a driver.
>>>>>>
>>>>>> But in general, this feature is inclined to constrain the behavior of the device and
>>>>>> the driver from the receiving side.
>>>>> Based on above I am guessing you are talking about driver getting
>>>>> packets from device, I wish you used terms from virtio spec.
>>>> Yes, I'm going to use the terminology of the virtio spec.
>>>>
>>>>>> For example:
>>>>>> VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
>>>>>>
>>>>>> Then the specific implementation can be
>>>>>>
>>>>>> (1) the sender sends a fully csumed packet;
>>>>>> (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
>>>>>>      (because the two parties in the communication are located on the same host, the packet is trusted.).
>>>>>>
>>>>>> In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
>>>>>>
>>>>>> Thanks.
>>>>> This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
>>>> Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
>>>> receive a fully checksummed packet, we can no longer enjoy
>>>> the device's ability to validate the packet checksum. That is, the value
>>>> of \field{flags} in the virtio_net_hdr structure is set to 0, which means
>>>> that the packet received by the driver will not be marked as
>>>> VIRTIO_NET_HDR_F_DATA_VALID.
>>>>
>>>> So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
>>>> If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
>>>> driver a fully checksummed packet, and the packet is validated by the
>>>> device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
>>>>
>>>>> I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
>>>>> disables all offloads but you want to keep some of them?
>>>>>
>>>> No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
>>>> in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
>>>> then the driver may always receive packets marked as
>>>> VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
>>>> same time.
>>> Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
>>> VIRTIO_NET_HDR_F_DATA_VALID:
>> We need to focus on what happens when the XDP program is loaded:
>>
>> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
>> feature when loading XDP. The main reason for doing this is because
>> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
>> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
>> XDP programs, because we cannot guarantee that the csum_{start, offset}
>> fields are correct after XDP modifies the packets.
> We can try to fix or workaround this. A rough idea is for example by
> using a flow dissector? Anyhow the GSO of virtio-net was marked as
> dodgy which means the csum_start/offset needs to be validated again in
> the xmit path. Or we can monitor if the packet is modified or not, if
> not, we don't need to zero vnet header?

The reason why we prefer the method of adding a new feature is that it 
has portability and compatibility,
and the XDP program can be directly loaded when the feature is negotiated.

When the device resources are sufficient, it can choose to offer this 
feature bit.
When the device resources are insufficient or it want to optimize the 
same host communication for vms,
it can choose not to offer this feature bit.

Thanks.

>
> Thanks
>
>> So in order for the driver to continue to enjoy the device's ability to
>> validate packets while XDP is loaded, we need a new feature to tell the
>> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
>> other words, the device can only deliver packets marked as
>> VIRTIO_NET_HDR_F_DATA_VALID).
>>
>> Thanks.
>>
>>> \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
>>>    VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
>>>    set: if so, the packet checksum at offset \field{csum_offset}
>>>    from \field{csum_start} and any preceding checksums
>>>    have been validated.  The checksum on the packet is incomplete and
>>>    if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
>>>    then \field{csum_start} and \field{csum_offset} indicate how to calculate it
>>>    (see Packet Transmission point 1).
>>>
>>> Did you maybe mean if either feature is negotiated?
>>>
>>>
>>>
>>>>> Again please use virtio terminology not Linux. to help you out,
>>>>> in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
>>>>> will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
>>>>>
>>>> Sure. Will do as you suggested.
>>>>
>>>> Thanks.
>>>>
>>>>> --
>>>>> MST
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
>>>>> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
>>>
>>> This publicly archived list offers a means to provide input to the
>>> OASIS Virtual I/O Device (VIRTIO) TC.
>>>
>>> In order to verify user consent to the Feedback License terms and
>>> to minimize spam in the list archive, subscription is required
>>> before posting.
>>>
>>> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
>>> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
>>> List help: virtio-comment-help@lists.oasis-open.org
>>> List archive: https://lists.oasis-open.org/archives/virtio-comment/
>>> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
>>> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
>>> Committee: https://www.oasis-open.org/committees/virtio/
>>> Join OASIS: https://www.oasis-open.org/join/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
  2023-05-24  5:07                 ` Heng Qi
@ 2023-05-24  5:52                   ` Jason Wang
  -1 siblings, 0 replies; 34+ messages in thread
From: Jason Wang @ 2023-05-24  5:52 UTC (permalink / raw)
  To: Heng Qi
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 1:07 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>
> On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
> > On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> > >
> > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > csumed packet must be sent.
> > > > > > > >
> > > > > > > > Who is the sender in this picture? The driver?
> > > > > > >
> > > > > > > The device or the driver.
> > > > > > >
> > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > >
> > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > the driver from the receiving side.
> > > > > >
> > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > packets from device, I wish you used terms from virtio spec.
> > > > >
> > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > >
> > > > > >
> > > > > > > For example:
> > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > >
> > > > > > > Then the specific implementation can be
> > > > > > >
> > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > >
> > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > >
> > > > > > > Thanks.
> > > > > >
> > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > >
> > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > that the packet received by the driver will not be marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > >
> > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > >
> > > > > >
> > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > disables all offloads but you want to keep some of them?
> > > > > >
> > > > >
> > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > then the driver may always receive packets marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > same time.
> > > >
> > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > >
> > > We need to focus on what happens when the XDP program is loaded:
> > >
> > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > feature when loading XDP. The main reason for doing this is because
> > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > fields are correct after XDP modifies the packets.
> >
> > We can try to fix or workaround this. A rough idea is for example by
> > using a flow dissector?
>
> How can we fix this with a flow dissector? Could you please explain in
> detail?

I mean you can use a flow dissector to probe the csum_start and csum_offset.

>
> > Anyhow the GSO of virtio-net was marked as
> > dodgy which means the csum_start/offset needs to be validated again in
> > the xmit path. Or we can monitor if the packet is modified or not, if
> > not, we don't need to zero vnet header?
>
> Yes, this is a way, and we've thought about this solution.
> A relatively simple solution is to add a new flag to the XDP program
> (through XDP core layer), which indicates that the XDP program is a
> read-only XDP program (ie, does not modify the packet).

XDP used to have something like this. Maybe we can re add them.

> Then to load
> such an XDP program we no longer need to filter out the
> VIRTIO_NET_F_GUEST_CSUM feature.
>
> But why we didn't propose this solution in the 'Proposal', because it
> seems that only virtio-net has encountered related problems. Virtual
> network cards like veth, even if they receive partial csumed packets
> (corresponding to virtio-net's packets marked as
> VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
> (corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
> another trade-off: the current virtnet_xdp_set() no longer
> filters out VIRTIO_NET_F_GUEST_CSUM.
>
> The reasons I think are the following:
> 1. Referring to veth’s way, the XDP program is more of a
> monitoring/firewall, and may not modify data packets.

Probably not, XDP could be used for building tunnels.

>
> 2. We can still use XDP for packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID.

Not sure I get this but who is going to adjust csum_start/offset?

>
> 3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
> (because ip_forward sysctl is disabled by default)

That's suboptimal.

Thanks

>
> Thanks.
>
> >
> > Thanks
> >
> > >
> > > So in order for the driver to continue to enjoy the device's ability to
> > > validate packets while XDP is loaded, we need a new feature to tell the
> > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > other words, the device can only deliver packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID).
> > >
> > > Thanks.
> > >
> > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > >   from \field{csum_start} and any preceding checksums
> > > >   have been validated.  The checksum on the packet is incomplete and
> > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > >   (see Packet Transmission point 1).
> > > >
> > > > Did you maybe mean if either feature is negotiated?
> > > >
> > > >
> > > >
> > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > >
> > > > >
> > > > > Sure. Will do as you suggested.
> > > > >
> > > > > Thanks.
> > > > >
> > > > > >
> > > > > > --
> > > > > > MST
> > > > > >
> > > > > >
> > > > > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > >
> > > >
> > > > This publicly archived list offers a means to provide input to the
> > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > >
> > > > In order to verify user consent to the Feedback License terms and
> > > > to minimize spam in the list archive, subscription is required
> > > > before posting.
> > > >
> > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > Join OASIS: https://www.oasis-open.org/join/
> > >
>


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
@ 2023-05-24  5:52                   ` Jason Wang
  0 siblings, 0 replies; 34+ messages in thread
From: Jason Wang @ 2023-05-24  5:52 UTC (permalink / raw)
  To: Heng Qi
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 1:07 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>
> On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
> > On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> > >
> > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > csumed packet must be sent.
> > > > > > > >
> > > > > > > > Who is the sender in this picture? The driver?
> > > > > > >
> > > > > > > The device or the driver.
> > > > > > >
> > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > >
> > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > the driver from the receiving side.
> > > > > >
> > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > packets from device, I wish you used terms from virtio spec.
> > > > >
> > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > >
> > > > > >
> > > > > > > For example:
> > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > >
> > > > > > > Then the specific implementation can be
> > > > > > >
> > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > >
> > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > >
> > > > > > > Thanks.
> > > > > >
> > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > >
> > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > that the packet received by the driver will not be marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > >
> > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > >
> > > > > >
> > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > disables all offloads but you want to keep some of them?
> > > > > >
> > > > >
> > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > then the driver may always receive packets marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > same time.
> > > >
> > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > >
> > > We need to focus on what happens when the XDP program is loaded:
> > >
> > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > feature when loading XDP. The main reason for doing this is because
> > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > fields are correct after XDP modifies the packets.
> >
> > We can try to fix or workaround this. A rough idea is for example by
> > using a flow dissector?
>
> How can we fix this with a flow dissector? Could you please explain in
> detail?

I mean you can use a flow dissector to probe the csum_start and csum_offset.

>
> > Anyhow the GSO of virtio-net was marked as
> > dodgy which means the csum_start/offset needs to be validated again in
> > the xmit path. Or we can monitor if the packet is modified or not, if
> > not, we don't need to zero vnet header?
>
> Yes, this is a way, and we've thought about this solution.
> A relatively simple solution is to add a new flag to the XDP program
> (through XDP core layer), which indicates that the XDP program is a
> read-only XDP program (ie, does not modify the packet).

XDP used to have something like this. Maybe we can re add them.

> Then to load
> such an XDP program we no longer need to filter out the
> VIRTIO_NET_F_GUEST_CSUM feature.
>
> But why we didn't propose this solution in the 'Proposal', because it
> seems that only virtio-net has encountered related problems. Virtual
> network cards like veth, even if they receive partial csumed packets
> (corresponding to virtio-net's packets marked as
> VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
> (corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
> another trade-off: the current virtnet_xdp_set() no longer
> filters out VIRTIO_NET_F_GUEST_CSUM.
>
> The reasons I think are the following:
> 1. Referring to veth’s way, the XDP program is more of a
> monitoring/firewall, and may not modify data packets.

Probably not, XDP could be used for building tunnels.

>
> 2. We can still use XDP for packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID.

Not sure I get this but who is going to adjust csum_start/offset?

>
> 3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
> (because ip_forward sysctl is disabled by default)

That's suboptimal.

Thanks

>
> Thanks.
>
> >
> > Thanks
> >
> > >
> > > So in order for the driver to continue to enjoy the device's ability to
> > > validate packets while XDP is loaded, we need a new feature to tell the
> > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > other words, the device can only deliver packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID).
> > >
> > > Thanks.
> > >
> > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > >   from \field{csum_start} and any preceding checksums
> > > >   have been validated.  The checksum on the packet is incomplete and
> > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > >   (see Packet Transmission point 1).
> > > >
> > > > Did you maybe mean if either feature is negotiated?
> > > >
> > > >
> > > >
> > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > >
> > > > >
> > > > > Sure. Will do as you suggested.
> > > > >
> > > > > Thanks.
> > > > >
> > > > > >
> > > > > > --
> > > > > > MST
> > > > > >
> > > > > >
> > > > > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > >
> > > >
> > > > This publicly archived list offers a means to provide input to the
> > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > >
> > > > In order to verify user consent to the Feedback License terms and
> > > > to minimize spam in the list archive, subscription is required
> > > > before posting.
> > > >
> > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > Join OASIS: https://www.oasis-open.org/join/
> > >
>


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-23 13:51             ` Heng Qi
@ 2023-05-24  6:07               ` Michael S. Tsirkin
  -1 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-24  6:07 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > csumed packet must be sent.
> > > > > > 
> > > > > > Who is the sender in this picture? The driver?
> > > > > 
> > > > > The device or the driver.
> > > > > 
> > > > > When the device is hw, the sender is more likely to be a device.
> > > > > When the device is sw, the sender can be a device or a driver.
> > > > >
> > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > the driver from the receiving side.
> > > > 
> > > > Based on above I am guessing you are talking about driver getting
> > > > packets from device, I wish you used terms from virtio spec.
> > > 
> > > Yes, I'm going to use the terminology of the virtio spec.
> > > 
> > > > 
> > > > > For example: 
> > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > 
> > > > > Then the specific implementation can be
> > > > > 
> > > > > (1) the sender sends a fully csumed packet;
> > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > 
> > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > 
> > > > > Thanks.
> > > > 
> > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > 
> > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > receive a fully checksummed packet, we can no longer enjoy
> > > the device's ability to validate the packet checksum. That is, the value
> > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > that the packet received by the driver will not be marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > 
> > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > driver a fully checksummed packet, and the packet is validated by the
> > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > 
> > > > 
> > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > disables all offloads but you want to keep some of them?
> > > > 
> > > 
> > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > then the driver may always receive packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > same time.
> > 
> > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > VIRTIO_NET_HDR_F_DATA_VALID:
> 
> We need to focus on what happens when the XDP program is loaded:
> 
> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> feature when loading XDP. The main reason for doing this is because
> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> XDP programs, because we cannot guarantee that the csum_{start, offset}
> fields are correct after XDP modifies the packets.

What do you want the device to do with these packets?
Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
Then ... why don't you have the driver clear that bit?

> So in order for the driver to continue to enjoy the device's ability to
> validate packets while XDP is loaded, we need a new feature to tell the
> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> other words, the device can only deliver packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID).
> 
> Thanks.




> > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> >   set: if so, the packet checksum at offset \field{csum_offset}
> >   from \field{csum_start} and any preceding checksums
> >   have been validated.  The checksum on the packet is incomplete and
> >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> >   (see Packet Transmission point 1).
> > 
> > Did you maybe mean if either feature is negotiated?
> > 
> > 
> > 
> > > > Again please use virtio terminology not Linux. to help you out,
> > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > 
> > > 
> > > Sure. Will do as you suggested.
> > > 
> > > Thanks.
> > > 
> > > > 
> > > > -- 
> > > > MST
> > > > 
> > > > 
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > 
> > 
> > This publicly archived list offers a means to provide input to the
> > OASIS Virtual I/O Device (VIRTIO) TC.
> > 
> > In order to verify user consent to the Feedback License terms and
> > to minimize spam in the list archive, subscription is required
> > before posting.
> > 
> > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > List help: virtio-comment-help@lists.oasis-open.org
> > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > Committee: https://www.oasis-open.org/committees/virtio/
> > Join OASIS: https://www.oasis-open.org/join/


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-24  6:07               ` Michael S. Tsirkin
  0 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-24  6:07 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > csumed packet must be sent.
> > > > > > 
> > > > > > Who is the sender in this picture? The driver?
> > > > > 
> > > > > The device or the driver.
> > > > > 
> > > > > When the device is hw, the sender is more likely to be a device.
> > > > > When the device is sw, the sender can be a device or a driver.
> > > > >
> > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > the driver from the receiving side.
> > > > 
> > > > Based on above I am guessing you are talking about driver getting
> > > > packets from device, I wish you used terms from virtio spec.
> > > 
> > > Yes, I'm going to use the terminology of the virtio spec.
> > > 
> > > > 
> > > > > For example: 
> > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > 
> > > > > Then the specific implementation can be
> > > > > 
> > > > > (1) the sender sends a fully csumed packet;
> > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > 
> > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > 
> > > > > Thanks.
> > > > 
> > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > 
> > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > receive a fully checksummed packet, we can no longer enjoy
> > > the device's ability to validate the packet checksum. That is, the value
> > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > that the packet received by the driver will not be marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > 
> > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > driver a fully checksummed packet, and the packet is validated by the
> > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > 
> > > > 
> > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > disables all offloads but you want to keep some of them?
> > > > 
> > > 
> > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > then the driver may always receive packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > same time.
> > 
> > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > VIRTIO_NET_HDR_F_DATA_VALID:
> 
> We need to focus on what happens when the XDP program is loaded:
> 
> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> feature when loading XDP. The main reason for doing this is because
> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> XDP programs, because we cannot guarantee that the csum_{start, offset}
> fields are correct after XDP modifies the packets.

What do you want the device to do with these packets?
Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
Then ... why don't you have the driver clear that bit?

> So in order for the driver to continue to enjoy the device's ability to
> validate packets while XDP is loaded, we need a new feature to tell the
> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> other words, the device can only deliver packets marked as
> VIRTIO_NET_HDR_F_DATA_VALID).
> 
> Thanks.




> > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> >   set: if so, the packet checksum at offset \field{csum_offset}
> >   from \field{csum_start} and any preceding checksums
> >   have been validated.  The checksum on the packet is incomplete and
> >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> >   (see Packet Transmission point 1).
> > 
> > Did you maybe mean if either feature is negotiated?
> > 
> > 
> > 
> > > > Again please use virtio terminology not Linux. to help you out,
> > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > 
> > > 
> > > Sure. Will do as you suggested.
> > > 
> > > Thanks.
> > > 
> > > > 
> > > > -- 
> > > > MST
> > > > 
> > > > 
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > 
> > 
> > This publicly archived list offers a means to provide input to the
> > OASIS Virtual I/O Device (VIRTIO) TC.
> > 
> > In order to verify user consent to the Feedback License terms and
> > to minimize spam in the list archive, subscription is required
> > before posting.
> > 
> > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > List help: virtio-comment-help@lists.oasis-open.org
> > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > Committee: https://www.oasis-open.org/committees/virtio/
> > Join OASIS: https://www.oasis-open.org/join/


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
  2023-05-24  5:52                   ` Jason Wang
@ 2023-05-24  7:24                     ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  7:24 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 01:52:30PM +0800, Jason Wang wrote:
> On Wed, May 24, 2023 at 1:07 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> >
> > On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
> > > On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> > > >
> > > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > > csumed packet must be sent.
> > > > > > > > >
> > > > > > > > > Who is the sender in this picture? The driver?
> > > > > > > >
> > > > > > > > The device or the driver.
> > > > > > > >
> > > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > > >
> > > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > > the driver from the receiving side.
> > > > > > >
> > > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > > packets from device, I wish you used terms from virtio spec.
> > > > > >
> > > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > > >
> > > > > > >
> > > > > > > > For example:
> > > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > > >
> > > > > > > > Then the specific implementation can be
> > > > > > > >
> > > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > > >
> > > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > > >
> > > > > > > > Thanks.
> > > > > > >
> > > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > > >
> > > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > > that the packet received by the driver will not be marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > >
> > > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > >
> > > > > > >
> > > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > > disables all offloads but you want to keep some of them?
> > > > > > >
> > > > > >
> > > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > > then the driver may always receive packets marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > > same time.
> > > > >
> > > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > > >
> > > > We need to focus on what happens when the XDP program is loaded:
> > > >
> > > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > > feature when loading XDP. The main reason for doing this is because
> > > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > > fields are correct after XDP modifies the packets.
> > >
> > > We can try to fix or workaround this. A rough idea is for example by
> > > using a flow dissector?
> >
> > How can we fix this with a flow dissector? Could you please explain in
> > detail?
> 
> I mean you can use a flow dissector to probe the csum_start and csum_offset.
> 

I think this is a good workaround.

We save virtio-net-hdr first, and after running XDP, if the flag of
saved virtio-net-hdr contains VIRTIO_NET_HDR_F_NEEDS_CSUM, we'll probe
the csum_{start, offset}.

> >
> > > Anyhow the GSO of virtio-net was marked as
> > > dodgy which means the csum_start/offset needs to be validated again in
> > > the xmit path. Or we can monitor if the packet is modified or not, if
> > > not, we don't need to zero vnet header?
> >
> > Yes, this is a way, and we've thought about this solution.
> > A relatively simple solution is to add a new flag to the XDP program
> > (through XDP core layer), which indicates that the XDP program is a
> > read-only XDP program (ie, does not modify the packet).
> 
> XDP used to have something like this. Maybe we can re add them.

Has XDP core removed the similar flag?
I'm missing something from the past, can you give me a link to it please?

> 
> > Then to load
> > such an XDP program we no longer need to filter out the
> > VIRTIO_NET_F_GUEST_CSUM feature.
> >
> > But why we didn't propose this solution in the 'Proposal', because it
> > seems that only virtio-net has encountered related problems. Virtual
> > network cards like veth, even if they receive partial csumed packets
> > (corresponding to virtio-net's packets marked as
> > VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
> > (corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
> > another trade-off: the current virtnet_xdp_set() no longer
> > filters out VIRTIO_NET_F_GUEST_CSUM.
> >
> > The reasons I think are the following:
> > 1. Referring to veth’s way, the XDP program is more of a
> > monitoring/firewall, and may not modify data packets.
> 
> Probably not, XDP could be used for building tunnels.
>

Yes, opening VIRTIO_NET_F_GUEST_CSUM directly for XDP programs, is a
tradeoff and may cause packet loss, but we can also benefit from rx hw
csum offloading.

> >
> > 2. We can still use XDP for packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID.
> 
> Not sure I get this but who is going to adjust csum_start/offset?
> 

The information for csum_start/offset may be overwritten or may no
longer be correct. For example, XDP stores some new data in the packet headroom
and overwrites csum_{start, offset}; or pushes new data in front of the original header.

Thanks.

> >
> > 3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
> > (because ip_forward sysctl is disabled by default)
> 
> That's suboptimal.
> 
> Thanks
> 
> >
> > Thanks.
> >
> > >
> > > Thanks
> > >
> > > >
> > > > So in order for the driver to continue to enjoy the device's ability to
> > > > validate packets while XDP is loaded, we need a new feature to tell the
> > > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > > other words, the device can only deliver packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID).
> > > >
> > > > Thanks.
> > > >
> > > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > > >   from \field{csum_start} and any preceding checksums
> > > > >   have been validated.  The checksum on the packet is incomplete and
> > > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> > > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > > >   (see Packet Transmission point 1).
> > > > >
> > > > > Did you maybe mean if either feature is negotiated?
> > > > >
> > > > >
> > > > >
> > > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > > >
> > > > > >
> > > > > > Sure. Will do as you suggested.
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > MST
> > > > > > >
> > > > > > >
> > > > > > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > > >
> > > > >
> > > > > This publicly archived list offers a means to provide input to the
> > > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > > >
> > > > > In order to verify user consent to the Feedback License terms and
> > > > > to minimize spam in the list archive, subscription is required
> > > > > before posting.
> > > > >
> > > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > > Join OASIS: https://www.oasis-open.org/join/
> > > >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
@ 2023-05-24  7:24                     ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  7:24 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 01:52:30PM +0800, Jason Wang wrote:
> On Wed, May 24, 2023 at 1:07 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> >
> > On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
> > > On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
> > > >
> > > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > > csumed packet must be sent.
> > > > > > > > >
> > > > > > > > > Who is the sender in this picture? The driver?
> > > > > > > >
> > > > > > > > The device or the driver.
> > > > > > > >
> > > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > > >
> > > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > > the driver from the receiving side.
> > > > > > >
> > > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > > packets from device, I wish you used terms from virtio spec.
> > > > > >
> > > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > > >
> > > > > > >
> > > > > > > > For example:
> > > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > > >
> > > > > > > > Then the specific implementation can be
> > > > > > > >
> > > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > > >
> > > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > > >
> > > > > > > > Thanks.
> > > > > > >
> > > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > > >
> > > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > > that the packet received by the driver will not be marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > >
> > > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > >
> > > > > > >
> > > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > > disables all offloads but you want to keep some of them?
> > > > > > >
> > > > > >
> > > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > > then the driver may always receive packets marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > > same time.
> > > > >
> > > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > > >
> > > > We need to focus on what happens when the XDP program is loaded:
> > > >
> > > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > > feature when loading XDP. The main reason for doing this is because
> > > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > > fields are correct after XDP modifies the packets.
> > >
> > > We can try to fix or workaround this. A rough idea is for example by
> > > using a flow dissector?
> >
> > How can we fix this with a flow dissector? Could you please explain in
> > detail?
> 
> I mean you can use a flow dissector to probe the csum_start and csum_offset.
> 

I think this is a good workaround.

We save virtio-net-hdr first, and after running XDP, if the flag of
saved virtio-net-hdr contains VIRTIO_NET_HDR_F_NEEDS_CSUM, we'll probe
the csum_{start, offset}.

> >
> > > Anyhow the GSO of virtio-net was marked as
> > > dodgy which means the csum_start/offset needs to be validated again in
> > > the xmit path. Or we can monitor if the packet is modified or not, if
> > > not, we don't need to zero vnet header?
> >
> > Yes, this is a way, and we've thought about this solution.
> > A relatively simple solution is to add a new flag to the XDP program
> > (through XDP core layer), which indicates that the XDP program is a
> > read-only XDP program (ie, does not modify the packet).
> 
> XDP used to have something like this. Maybe we can re add them.

Has XDP core removed the similar flag?
I'm missing something from the past, can you give me a link to it please?

> 
> > Then to load
> > such an XDP program we no longer need to filter out the
> > VIRTIO_NET_F_GUEST_CSUM feature.
> >
> > But why we didn't propose this solution in the 'Proposal', because it
> > seems that only virtio-net has encountered related problems. Virtual
> > network cards like veth, even if they receive partial csumed packets
> > (corresponding to virtio-net's packets marked as
> > VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
> > (corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
> > another trade-off: the current virtnet_xdp_set() no longer
> > filters out VIRTIO_NET_F_GUEST_CSUM.
> >
> > The reasons I think are the following:
> > 1. Referring to veth’s way, the XDP program is more of a
> > monitoring/firewall, and may not modify data packets.
> 
> Probably not, XDP could be used for building tunnels.
>

Yes, opening VIRTIO_NET_F_GUEST_CSUM directly for XDP programs, is a
tradeoff and may cause packet loss, but we can also benefit from rx hw
csum offloading.

> >
> > 2. We can still use XDP for packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID.
> 
> Not sure I get this but who is going to adjust csum_start/offset?
> 

The information for csum_start/offset may be overwritten or may no
longer be correct. For example, XDP stores some new data in the packet headroom
and overwrites csum_{start, offset}; or pushes new data in front of the original header.

Thanks.

> >
> > 3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
> > (because ip_forward sysctl is disabled by default)
> 
> That's suboptimal.
> 
> Thanks
> 
> >
> > Thanks.
> >
> > >
> > > Thanks
> > >
> > > >
> > > > So in order for the driver to continue to enjoy the device's ability to
> > > > validate packets while XDP is loaded, we need a new feature to tell the
> > > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > > other words, the device can only deliver packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID).
> > > >
> > > > Thanks.
> > > >
> > > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > > >   from \field{csum_start} and any preceding checksums
> > > > >   have been validated.  The checksum on the packet is incomplete and
> > > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
> > > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > > >   (see Packet Transmission point 1).
> > > > >
> > > > > Did you maybe mean if either feature is negotiated?
> > > > >
> > > > >
> > > > >
> > > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > > >
> > > > > >
> > > > > > Sure. Will do as you suggested.
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > MST
> > > > > > >
> > > > > > >
> > > > > > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > > >
> > > > >
> > > > > This publicly archived list offers a means to provide input to the
> > > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > > >
> > > > > In order to verify user consent to the Feedback License terms and
> > > > > to minimize spam in the list archive, subscription is required
> > > > > before posting.
> > > > >
> > > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > > Join OASIS: https://www.oasis-open.org/join/
> > > >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-24  6:07               ` Michael S. Tsirkin
@ 2023-05-24  8:12                 ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  8:12 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 02:07:14AM -0400, Michael S. Tsirkin wrote:
> On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > csumed packet must be sent.
> > > > > > > 
> > > > > > > Who is the sender in this picture? The driver?
> > > > > > 
> > > > > > The device or the driver.
> > > > > > 
> > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > >
> > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > the driver from the receiving side.
> > > > > 
> > > > > Based on above I am guessing you are talking about driver getting
> > > > > packets from device, I wish you used terms from virtio spec.
> > > > 
> > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > 
> > > > > 
> > > > > > For example: 
> > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > 
> > > > > > Then the specific implementation can be
> > > > > > 
> > > > > > (1) the sender sends a fully csumed packet;
> > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > 
> > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > 
> > > > > > Thanks.
> > > > > 
> > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > 
> > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > receive a fully checksummed packet, we can no longer enjoy
> > > > the device's ability to validate the packet checksum. That is, the value
> > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > that the packet received by the driver will not be marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > 
> > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > driver a fully checksummed packet, and the packet is validated by the
> > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > 
> > > > > 
> > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > disables all offloads but you want to keep some of them?
> > > > > 
> > > > 
> > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > then the driver may always receive packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > same time.
> > > 
> > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > VIRTIO_NET_HDR_F_DATA_VALID:
> > 
> > We need to focus on what happens when the XDP program is loaded:
> > 
> > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > feature when loading XDP. The main reason for doing this is because
> > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > fields are correct after XDP modifies the packets.
> 
> What do you want the device to do with these packets?
> Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
> Then ... why don't you have the driver clear that bit?

Just clearing VIRTIO_NET_HDR_F_NEEDS_CSUM will cause the stack to drop
packets when validating the checksum.

From [1] we know that after negotiating VIRTIO_NET_F_GUEST_CSUM, the
device can choose to save some work, thus generating packets carrying
VIRTIO_NET_HDR_F_NEEDS_CSUM. The new feature just keeping the device from saving
the work it's supposed to be doing. Of course, this will bring some
device calculating overhead, but if the device has sufficient calculating
resources, it can offer the new feature.

[1] “The converse features are also available: a driver can save the
virtual device some work by negotiating these features. Note: For
example, a network packet transported between two guests on the same
system might not need checksumming at all, nor segmentation , if both
guests are amenable.”

Thanks.

> 
> > So in order for the driver to continue to enjoy the device's ability to
> > validate packets while XDP is loaded, we need a new feature to tell the
> > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > other words, the device can only deliver packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID).
> > 
> > Thanks.
> 
> 
> 
> 
> > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > >   set: if so, the packet checksum at offset \field{csum_offset}
> > >   from \field{csum_start} and any preceding checksums
> > >   have been validated.  The checksum on the packet is incomplete and
> > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > >   (see Packet Transmission point 1).
> > > 
> > > Did you maybe mean if either feature is negotiated?
> > > 
> > > 
> > > 
> > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > 
> > > > 
> > > > Sure. Will do as you suggested.
> > > > 
> > > > Thanks.
> > > > 
> > > > > 
> > > > > -- 
> > > > > MST
> > > > > 
> > > > > 
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > 
> > > 
> > > This publicly archived list offers a means to provide input to the
> > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > 
> > > In order to verify user consent to the Feedback License terms and
> > > to minimize spam in the list archive, subscription is required
> > > before posting.
> > > 
> > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > List help: virtio-comment-help@lists.oasis-open.org
> > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > Committee: https://www.oasis-open.org/committees/virtio/
> > > Join OASIS: https://www.oasis-open.org/join/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-24  8:12                 ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-24  8:12 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 02:07:14AM -0400, Michael S. Tsirkin wrote:
> On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > csumed packet must be sent.
> > > > > > > 
> > > > > > > Who is the sender in this picture? The driver?
> > > > > > 
> > > > > > The device or the driver.
> > > > > > 
> > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > >
> > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > the driver from the receiving side.
> > > > > 
> > > > > Based on above I am guessing you are talking about driver getting
> > > > > packets from device, I wish you used terms from virtio spec.
> > > > 
> > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > 
> > > > > 
> > > > > > For example: 
> > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > 
> > > > > > Then the specific implementation can be
> > > > > > 
> > > > > > (1) the sender sends a fully csumed packet;
> > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > 
> > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > 
> > > > > > Thanks.
> > > > > 
> > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > 
> > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > receive a fully checksummed packet, we can no longer enjoy
> > > > the device's ability to validate the packet checksum. That is, the value
> > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > that the packet received by the driver will not be marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > 
> > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > driver a fully checksummed packet, and the packet is validated by the
> > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > 
> > > > > 
> > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > disables all offloads but you want to keep some of them?
> > > > > 
> > > > 
> > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > then the driver may always receive packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > same time.
> > > 
> > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > VIRTIO_NET_HDR_F_DATA_VALID:
> > 
> > We need to focus on what happens when the XDP program is loaded:
> > 
> > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > feature when loading XDP. The main reason for doing this is because
> > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > fields are correct after XDP modifies the packets.
> 
> What do you want the device to do with these packets?
> Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
> Then ... why don't you have the driver clear that bit?

Just clearing VIRTIO_NET_HDR_F_NEEDS_CSUM will cause the stack to drop
packets when validating the checksum.

From [1] we know that after negotiating VIRTIO_NET_F_GUEST_CSUM, the
device can choose to save some work, thus generating packets carrying
VIRTIO_NET_HDR_F_NEEDS_CSUM. The new feature just keeping the device from saving
the work it's supposed to be doing. Of course, this will bring some
device calculating overhead, but if the device has sufficient calculating
resources, it can offer the new feature.

[1] “The converse features are also available: a driver can save the
virtual device some work by negotiating these features. Note: For
example, a network packet transported between two guests on the same
system might not need checksumming at all, nor segmentation , if both
guests are amenable.”

Thanks.

> 
> > So in order for the driver to continue to enjoy the device's ability to
> > validate packets while XDP is loaded, we need a new feature to tell the
> > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > other words, the device can only deliver packets marked as
> > VIRTIO_NET_HDR_F_DATA_VALID).
> > 
> > Thanks.
> 
> 
> 
> 
> > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > >   set: if so, the packet checksum at offset \field{csum_offset}
> > >   from \field{csum_start} and any preceding checksums
> > >   have been validated.  The checksum on the packet is incomplete and
> > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > >   (see Packet Transmission point 1).
> > > 
> > > Did you maybe mean if either feature is negotiated?
> > > 
> > > 
> > > 
> > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > 
> > > > 
> > > > Sure. Will do as you suggested.
> > > > 
> > > > Thanks.
> > > > 
> > > > > 
> > > > > -- 
> > > > > MST
> > > > > 
> > > > > 
> > > > > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > 
> > > 
> > > This publicly archived list offers a means to provide input to the
> > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > 
> > > In order to verify user consent to the Feedback License terms and
> > > to minimize spam in the list archive, subscription is required
> > > before posting.
> > > 
> > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > List help: virtio-comment-help@lists.oasis-open.org
> > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > Committee: https://www.oasis-open.org/committees/virtio/
> > > Join OASIS: https://www.oasis-open.org/join/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
  2023-05-24  7:24                     ` [virtio-comment] " Heng Qi
@ 2023-05-26  7:58                       ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-26  7:58 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo



在 2023/5/24 下午3:24, Heng Qi 写道:
> On Wed, May 24, 2023 at 01:52:30PM +0800, Jason Wang wrote:
>> On Wed, May 24, 2023 at 1:07 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>>> On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
>>>> On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>>>>> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
>>>>>> On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
>>>>>>> On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
>>>>>>>> On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
>>>>>>>>> On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
>>>>>>>>>> On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
>>>>>>>>>>> 1) Add a feature bit to the virtio specification to tell the sender that a fully
>>>>>>>>>>> csumed packet must be sent.
>>>>>>>>>> Who is the sender in this picture? The driver?
>>>>>>>>> The device or the driver.
>>>>>>>>>
>>>>>>>>> When the device is hw, the sender is more likely to be a device.
>>>>>>>>> When the device is sw, the sender can be a device or a driver.
>>>>>>>>>
>>>>>>>>> But in general, this feature is inclined to constrain the behavior of the device and
>>>>>>>>> the driver from the receiving side.
>>>>>>>> Based on above I am guessing you are talking about driver getting
>>>>>>>> packets from device, I wish you used terms from virtio spec.
>>>>>>> Yes, I'm going to use the terminology of the virtio spec.
>>>>>>>
>>>>>>>>> For example:
>>>>>>>>> VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
>>>>>>>>>
>>>>>>>>> Then the specific implementation can be
>>>>>>>>>
>>>>>>>>> (1) the sender sends a fully csumed packet;
>>>>>>>>> (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
>>>>>>>>>      (because the two parties in the communication are located on the same host, the packet is trusted.).
>>>>>>>>>
>>>>>>>>> In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>> This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
>>>>>>> Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
>>>>>>> receive a fully checksummed packet, we can no longer enjoy
>>>>>>> the device's ability to validate the packet checksum. That is, the value
>>>>>>> of \field{flags} in the virtio_net_hdr structure is set to 0, which means
>>>>>>> that the packet received by the driver will not be marked as
>>>>>>> VIRTIO_NET_HDR_F_DATA_VALID.
>>>>>>>
>>>>>>> So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
>>>>>>> If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
>>>>>>> driver a fully checksummed packet, and the packet is validated by the
>>>>>>> device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
>>>>>>>
>>>>>>>> I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
>>>>>>>> disables all offloads but you want to keep some of them?
>>>>>>>>
>>>>>>> No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
>>>>>>> in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
>>>>>>> then the driver may always receive packets marked as
>>>>>>> VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
>>>>>>> same time.
>>>>>> Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
>>>>>> VIRTIO_NET_HDR_F_DATA_VALID:
>>>>> We need to focus on what happens when the XDP program is loaded:
>>>>>
>>>>> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
>>>>> feature when loading XDP. The main reason for doing this is because
>>>>> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
>>>>> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
>>>>> XDP programs, because we cannot guarantee that the csum_{start, offset}
>>>>> fields are correct after XDP modifies the packets.
>>>> We can try to fix or workaround this. A rough idea is for example by
>>>> using a flow dissector?
>>> How can we fix this with a flow dissector? Could you please explain in
>>> detail?
>> I mean you can use a flow dissector to probe the csum_start and csum_offset.
>>
> I think this is a good workaround.
>
> We save virtio-net-hdr first, and after running XDP, if the flag of
> saved virtio-net-hdr contains VIRTIO_NET_HDR_F_NEEDS_CSUM, we'll probe
> the csum_{start, offset}.

Hi, Jason.

Do we choose this option first as an attempt to solve the problem 
described by this proposal?

If so, I'll try to make a patch.

Thanks.

>>>> Anyhow the GSO of virtio-net was marked as
>>>> dodgy which means the csum_start/offset needs to be validated again in
>>>> the xmit path. Or we can monitor if the packet is modified or not, if
>>>> not, we don't need to zero vnet header?
>>> Yes, this is a way, and we've thought about this solution.
>>> A relatively simple solution is to add a new flag to the XDP program
>>> (through XDP core layer), which indicates that the XDP program is a
>>> read-only XDP program (ie, does not modify the packet).
>> XDP used to have something like this. Maybe we can re add them.
> Has XDP core removed the similar flag?
> I'm missing something from the past, can you give me a link to it please?
>
>>> Then to load
>>> such an XDP program we no longer need to filter out the
>>> VIRTIO_NET_F_GUEST_CSUM feature.
>>>
>>> But why we didn't propose this solution in the 'Proposal', because it
>>> seems that only virtio-net has encountered related problems. Virtual
>>> network cards like veth, even if they receive partial csumed packets
>>> (corresponding to virtio-net's packets marked as
>>> VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
>>> (corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
>>> another trade-off: the current virtnet_xdp_set() no longer
>>> filters out VIRTIO_NET_F_GUEST_CSUM.
>>>
>>> The reasons I think are the following:
>>> 1. Referring to veth’s way, the XDP program is more of a
>>> monitoring/firewall, and may not modify data packets.
>> Probably not, XDP could be used for building tunnels.
>>
> Yes, opening VIRTIO_NET_F_GUEST_CSUM directly for XDP programs, is a
> tradeoff and may cause packet loss, but we can also benefit from rx hw
> csum offloading.
>
>>> 2. We can still use XDP for packets marked as
>>> VIRTIO_NET_HDR_F_DATA_VALID.
>> Not sure I get this but who is going to adjust csum_start/offset?
>>
> The information for csum_start/offset may be overwritten or may no
> longer be correct. For example, XDP stores some new data in the packet headroom
> and overwrites csum_{start, offset}; or pushes new data in front of the original header.
>
> Thanks.
>
>>> 3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
>>> (because ip_forward sysctl is disabled by default)
>> That's suboptimal.
>>
>> Thanks
>>
>>> Thanks.
>>>
>>>> Thanks
>>>>
>>>>> So in order for the driver to continue to enjoy the device's ability to
>>>>> validate packets while XDP is loaded, we need a new feature to tell the
>>>>> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
>>>>> other words, the device can only deliver packets marked as
>>>>> VIRTIO_NET_HDR_F_DATA_VALID).
>>>>>
>>>>> Thanks.
>>>>>
>>>>>> \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
>>>>>>    VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
>>>>>>    set: if so, the packet checksum at offset \field{csum_offset}
>>>>>>    from \field{csum_start} and any preceding checksums
>>>>>>    have been validated.  The checksum on the packet is incomplete and
>>>>>>    if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
>>>>>>    then \field{csum_start} and \field{csum_offset} indicate how to calculate it
>>>>>>    (see Packet Transmission point 1).
>>>>>>
>>>>>> Did you maybe mean if either feature is negotiated?
>>>>>>
>>>>>>
>>>>>>
>>>>>>>> Again please use virtio terminology not Linux. to help you out,
>>>>>>>> in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
>>>>>>>> will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
>>>>>>>>
>>>>>>> Sure. Will do as you suggested.
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>>> --
>>>>>>>> MST
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
>>>>>>>> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
>>>>>>
>>>>>> This publicly archived list offers a means to provide input to the
>>>>>> OASIS Virtual I/O Device (VIRTIO) TC.
>>>>>>
>>>>>> In order to verify user consent to the Feedback License terms and
>>>>>> to minimize spam in the list archive, subscription is required
>>>>>> before posting.
>>>>>>
>>>>>> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
>>>>>> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
>>>>>> List help: virtio-comment-help@lists.oasis-open.org
>>>>>> List archive: https://lists.oasis-open.org/archives/virtio-comment/
>>>>>> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
>>>>>> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
>>>>>> Committee: https://www.oasis-open.org/committees/virtio/
>>>>>> Join OASIS: https://www.oasis-open.org/join/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
>> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
>
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
>
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety
@ 2023-05-26  7:58                       ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-26  7:58 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, virtio-dev, virtio-comment, Parav Pandit, Xuan Zhuo



在 2023/5/24 下午3:24, Heng Qi 写道:
> On Wed, May 24, 2023 at 01:52:30PM +0800, Jason Wang wrote:
>> On Wed, May 24, 2023 at 1:07 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>>> On Wed, May 24, 2023 at 12:09:22PM +0800, Jason Wang wrote:
>>>> On Tue, May 23, 2023 at 9:51 PM Heng Qi <hengqi@linux.alibaba.com> wrote:
>>>>> On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
>>>>>> On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
>>>>>>> On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
>>>>>>>> On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
>>>>>>>>> On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
>>>>>>>>>> On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
>>>>>>>>>>> 1) Add a feature bit to the virtio specification to tell the sender that a fully
>>>>>>>>>>> csumed packet must be sent.
>>>>>>>>>> Who is the sender in this picture? The driver?
>>>>>>>>> The device or the driver.
>>>>>>>>>
>>>>>>>>> When the device is hw, the sender is more likely to be a device.
>>>>>>>>> When the device is sw, the sender can be a device or a driver.
>>>>>>>>>
>>>>>>>>> But in general, this feature is inclined to constrain the behavior of the device and
>>>>>>>>> the driver from the receiving side.
>>>>>>>> Based on above I am guessing you are talking about driver getting
>>>>>>>> packets from device, I wish you used terms from virtio spec.
>>>>>>> Yes, I'm going to use the terminology of the virtio spec.
>>>>>>>
>>>>>>>>> For example:
>>>>>>>>> VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
>>>>>>>>>
>>>>>>>>> Then the specific implementation can be
>>>>>>>>>
>>>>>>>>> (1) the sender sends a fully csumed packet;
>>>>>>>>> (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
>>>>>>>>>      (because the two parties in the communication are located on the same host, the packet is trusted.).
>>>>>>>>>
>>>>>>>>> In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>> This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
>>>>>>> Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
>>>>>>> receive a fully checksummed packet, we can no longer enjoy
>>>>>>> the device's ability to validate the packet checksum. That is, the value
>>>>>>> of \field{flags} in the virtio_net_hdr structure is set to 0, which means
>>>>>>> that the packet received by the driver will not be marked as
>>>>>>> VIRTIO_NET_HDR_F_DATA_VALID.
>>>>>>>
>>>>>>> So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
>>>>>>> If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
>>>>>>> driver a fully checksummed packet, and the packet is validated by the
>>>>>>> device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
>>>>>>>
>>>>>>>> I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
>>>>>>>> disables all offloads but you want to keep some of them?
>>>>>>>>
>>>>>>> No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
>>>>>>> in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
>>>>>>> then the driver may always receive packets marked as
>>>>>>> VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
>>>>>>> same time.
>>>>>> Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
>>>>>> VIRTIO_NET_HDR_F_DATA_VALID:
>>>>> We need to focus on what happens when the XDP program is loaded:
>>>>>
>>>>> The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
>>>>> feature when loading XDP. The main reason for doing this is because
>>>>> VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
>>>>> VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
>>>>> XDP programs, because we cannot guarantee that the csum_{start, offset}
>>>>> fields are correct after XDP modifies the packets.
>>>> We can try to fix or workaround this. A rough idea is for example by
>>>> using a flow dissector?
>>> How can we fix this with a flow dissector? Could you please explain in
>>> detail?
>> I mean you can use a flow dissector to probe the csum_start and csum_offset.
>>
> I think this is a good workaround.
>
> We save virtio-net-hdr first, and after running XDP, if the flag of
> saved virtio-net-hdr contains VIRTIO_NET_HDR_F_NEEDS_CSUM, we'll probe
> the csum_{start, offset}.

Hi, Jason.

Do we choose this option first as an attempt to solve the problem 
described by this proposal?

If so, I'll try to make a patch.

Thanks.

>>>> Anyhow the GSO of virtio-net was marked as
>>>> dodgy which means the csum_start/offset needs to be validated again in
>>>> the xmit path. Or we can monitor if the packet is modified or not, if
>>>> not, we don't need to zero vnet header?
>>> Yes, this is a way, and we've thought about this solution.
>>> A relatively simple solution is to add a new flag to the XDP program
>>> (through XDP core layer), which indicates that the XDP program is a
>>> read-only XDP program (ie, does not modify the packet).
>> XDP used to have something like this. Maybe we can re add them.
> Has XDP core removed the similar flag?
> I'm missing something from the past, can you give me a link to it please?
>
>>> Then to load
>>> such an XDP program we no longer need to filter out the
>>> VIRTIO_NET_F_GUEST_CSUM feature.
>>>
>>> But why we didn't propose this solution in the 'Proposal', because it
>>> seems that only virtio-net has encountered related problems. Virtual
>>> network cards like veth, even if they receive partial csumed packets
>>> (corresponding to virtio-net's packets marked as
>>> VIRTIO_NET_HDR_F_NEEDS_CSUM), they still open NETIF_F_RXCSUM
>>> (corresponding to virtio-net's VIRTIO_NET_F_GUEST_CSUM). So there is
>>> another trade-off: the current virtnet_xdp_set() no longer
>>> filters out VIRTIO_NET_F_GUEST_CSUM.
>>>
>>> The reasons I think are the following:
>>> 1. Referring to veth’s way, the XDP program is more of a
>>> monitoring/firewall, and may not modify data packets.
>> Probably not, XDP could be used for building tunnels.
>>
> Yes, opening VIRTIO_NET_F_GUEST_CSUM directly for XDP programs, is a
> tradeoff and may cause packet loss, but we can also benefit from rx hw
> csum offloading.
>
>>> 2. We can still use XDP for packets marked as
>>> VIRTIO_NET_HDR_F_DATA_VALID.
>> Not sure I get this but who is going to adjust csum_start/offset?
>>
> The information for csum_start/offset may be overwritten or may no
> longer be correct. For example, XDP stores some new data in the packet headroom
> and overwrites csum_{start, offset}; or pushes new data in front of the original header.
>
> Thanks.
>
>>> 3. Packets converted from xdp_{buff, frame} may not be ip_forwarded
>>> (because ip_forward sysctl is disabled by default)
>> That's suboptimal.
>>
>> Thanks
>>
>>> Thanks.
>>>
>>>> Thanks
>>>>
>>>>> So in order for the driver to continue to enjoy the device's ability to
>>>>> validate packets while XDP is loaded, we need a new feature to tell the
>>>>> device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
>>>>> other words, the device can only deliver packets marked as
>>>>> VIRTIO_NET_HDR_F_DATA_VALID).
>>>>>
>>>>> Thanks.
>>>>>
>>>>>> \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
>>>>>>    VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
>>>>>>    set: if so, the packet checksum at offset \field{csum_offset}
>>>>>>    from \field{csum_start} and any preceding checksums
>>>>>>    have been validated.  The checksum on the packet is incomplete and
>>>>>>    if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags},
>>>>>>    then \field{csum_start} and \field{csum_offset} indicate how to calculate it
>>>>>>    (see Packet Transmission point 1).
>>>>>>
>>>>>> Did you maybe mean if either feature is negotiated?
>>>>>>
>>>>>>
>>>>>>
>>>>>>>> Again please use virtio terminology not Linux. to help you out,
>>>>>>>> in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
>>>>>>>> will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
>>>>>>>>
>>>>>>> Sure. Will do as you suggested.
>>>>>>>
>>>>>>> Thanks.
>>>>>>>
>>>>>>>> --
>>>>>>>> MST
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
>>>>>>>> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
>>>>>>
>>>>>> This publicly archived list offers a means to provide input to the
>>>>>> OASIS Virtual I/O Device (VIRTIO) TC.
>>>>>>
>>>>>> In order to verify user consent to the Feedback License terms and
>>>>>> to minimize spam in the list archive, subscription is required
>>>>>> before posting.
>>>>>>
>>>>>> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
>>>>>> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
>>>>>> List help: virtio-comment-help@lists.oasis-open.org
>>>>>> List archive: https://lists.oasis-open.org/archives/virtio-comment/
>>>>>> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
>>>>>> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
>>>>>> Committee: https://www.oasis-open.org/committees/virtio/
>>>>>> Join OASIS: https://www.oasis-open.org/join/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
>> For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
>
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
>
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-24  8:12                 ` [virtio-comment] " Heng Qi
@ 2023-05-30 19:33                   ` Michael S. Tsirkin
  -1 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-30 19:33 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 04:12:46PM +0800, Heng Qi wrote:
> On Wed, May 24, 2023 at 02:07:14AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > csumed packet must be sent.
> > > > > > > > 
> > > > > > > > Who is the sender in this picture? The driver?
> > > > > > > 
> > > > > > > The device or the driver.
> > > > > > > 
> > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > >
> > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > the driver from the receiving side.
> > > > > > 
> > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > packets from device, I wish you used terms from virtio spec.
> > > > > 
> > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > > 
> > > > > > 
> > > > > > > For example: 
> > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > > 
> > > > > > > Then the specific implementation can be
> > > > > > > 
> > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > > 
> > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > > 
> > > > > > > Thanks.
> > > > > > 
> > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > > 
> > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > that the packet received by the driver will not be marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > 
> > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > 
> > > > > > 
> > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > disables all offloads but you want to keep some of them?
> > > > > > 
> > > > > 
> > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > then the driver may always receive packets marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > same time.
> > > > 
> > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > > 
> > > We need to focus on what happens when the XDP program is loaded:
> > > 
> > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > feature when loading XDP. The main reason for doing this is because
> > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > fields are correct after XDP modifies the packets.
> > 
> > What do you want the device to do with these packets?
> > Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
> > Then ... why don't you have the driver clear that bit?
> 
> Just clearing VIRTIO_NET_HDR_F_NEEDS_CSUM will cause the stack to drop
> packets when validating the checksum.
> 
> >From [1] we know that after negotiating VIRTIO_NET_F_GUEST_CSUM, the
> device can choose to save some work, thus generating packets carrying
> VIRTIO_NET_HDR_F_NEEDS_CSUM. The new feature just keeping the device from saving
> the work it's supposed to be doing. Of course, this will bring some
> device calculating overhead, but if the device has sufficient calculating
> resources, it can offer the new feature.
> 
> [1] “The converse features are also available: a driver can save the
> virtual device some work by negotiating these features. Note: For
> example, a network packet transported between two guests on the same
> system might not need checksumming at all, nor segmentation , if both
> guests are amenable.”
> 
> Thanks.

Can't say I know exactly what you are trying to do ...
should we look for ways to set CHECKSUM_COMPLETE for some packets?

Or did you decide to forego changing the spec for now
and will just make a driver change?


> > 
> > > So in order for the driver to continue to enjoy the device's ability to
> > > validate packets while XDP is loaded, we need a new feature to tell the
> > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > other words, the device can only deliver packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID).
> > > 
> > > Thanks.
> > 
> > 
> > 
> > 
> > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > >   from \field{csum_start} and any preceding checksums
> > > >   have been validated.  The checksum on the packet is incomplete and
> > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > >   (see Packet Transmission point 1).
> > > > 
> > > > Did you maybe mean if either feature is negotiated?
> > > > 
> > > > 
> > > > 
> > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > > 
> > > > > 
> > > > > Sure. Will do as you suggested.
> > > > > 
> > > > > Thanks.
> > > > > 
> > > > > > 
> > > > > > -- 
> > > > > > MST
> > > > > > 
> > > > > > 
> > > > > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > > 
> > > > 
> > > > This publicly archived list offers a means to provide input to the
> > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > > 
> > > > In order to verify user consent to the Feedback License terms and
> > > > to minimize spam in the list archive, subscription is required
> > > > before posting.
> > > > 
> > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > Join OASIS: https://www.oasis-open.org/join/
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> 
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
> 
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
> 
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-30 19:33                   ` Michael S. Tsirkin
  0 siblings, 0 replies; 34+ messages in thread
From: Michael S. Tsirkin @ 2023-05-30 19:33 UTC (permalink / raw)
  To: Heng Qi; +Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Wed, May 24, 2023 at 04:12:46PM +0800, Heng Qi wrote:
> On Wed, May 24, 2023 at 02:07:14AM -0400, Michael S. Tsirkin wrote:
> > On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > csumed packet must be sent.
> > > > > > > > 
> > > > > > > > Who is the sender in this picture? The driver?
> > > > > > > 
> > > > > > > The device or the driver.
> > > > > > > 
> > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > >
> > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > the driver from the receiving side.
> > > > > > 
> > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > packets from device, I wish you used terms from virtio spec.
> > > > > 
> > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > > 
> > > > > > 
> > > > > > > For example: 
> > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > > 
> > > > > > > Then the specific implementation can be
> > > > > > > 
> > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > > 
> > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > > 
> > > > > > > Thanks.
> > > > > > 
> > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > > 
> > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > that the packet received by the driver will not be marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > 
> > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > 
> > > > > > 
> > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > disables all offloads but you want to keep some of them?
> > > > > > 
> > > > > 
> > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > then the driver may always receive packets marked as
> > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > same time.
> > > > 
> > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > > 
> > > We need to focus on what happens when the XDP program is loaded:
> > > 
> > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > feature when loading XDP. The main reason for doing this is because
> > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > fields are correct after XDP modifies the packets.
> > 
> > What do you want the device to do with these packets?
> > Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
> > Then ... why don't you have the driver clear that bit?
> 
> Just clearing VIRTIO_NET_HDR_F_NEEDS_CSUM will cause the stack to drop
> packets when validating the checksum.
> 
> >From [1] we know that after negotiating VIRTIO_NET_F_GUEST_CSUM, the
> device can choose to save some work, thus generating packets carrying
> VIRTIO_NET_HDR_F_NEEDS_CSUM. The new feature just keeping the device from saving
> the work it's supposed to be doing. Of course, this will bring some
> device calculating overhead, but if the device has sufficient calculating
> resources, it can offer the new feature.
> 
> [1] “The converse features are also available: a driver can save the
> virtual device some work by negotiating these features. Note: For
> example, a network packet transported between two guests on the same
> system might not need checksumming at all, nor segmentation , if both
> guests are amenable.”
> 
> Thanks.

Can't say I know exactly what you are trying to do ...
should we look for ways to set CHECKSUM_COMPLETE for some packets?

Or did you decide to forego changing the spec for now
and will just make a driver change?


> > 
> > > So in order for the driver to continue to enjoy the device's ability to
> > > validate packets while XDP is loaded, we need a new feature to tell the
> > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > other words, the device can only deliver packets marked as
> > > VIRTIO_NET_HDR_F_DATA_VALID).
> > > 
> > > Thanks.
> > 
> > 
> > 
> > 
> > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > >   from \field{csum_start} and any preceding checksums
> > > >   have been validated.  The checksum on the packet is incomplete and
> > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > >   (see Packet Transmission point 1).
> > > > 
> > > > Did you maybe mean if either feature is negotiated?
> > > > 
> > > > 
> > > > 
> > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > > 
> > > > > 
> > > > > Sure. Will do as you suggested.
> > > > > 
> > > > > Thanks.
> > > > > 
> > > > > > 
> > > > > > -- 
> > > > > > MST
> > > > > > 
> > > > > > 
> > > > > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > > 
> > > > 
> > > > This publicly archived list offers a means to provide input to the
> > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > > 
> > > > In order to verify user consent to the Feedback License terms and
> > > > to minimize spam in the list archive, subscription is required
> > > > before posting.
> > > > 
> > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > Join OASIS: https://www.oasis-open.org/join/
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> 
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
> 
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
> 
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/
> 


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
  2023-05-30 19:33                   ` Michael S. Tsirkin
@ 2023-05-31  6:57                     ` Heng Qi
  -1 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-31  6:57 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 30, 2023 at 03:33:22PM -0400, Michael S. Tsirkin wrote:
> On Wed, May 24, 2023 at 04:12:46PM +0800, Heng Qi wrote:
> > On Wed, May 24, 2023 at 02:07:14AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> > > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > > csumed packet must be sent.
> > > > > > > > > 
> > > > > > > > > Who is the sender in this picture? The driver?
> > > > > > > > 
> > > > > > > > The device or the driver.
> > > > > > > > 
> > > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > > >
> > > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > > the driver from the receiving side.
> > > > > > > 
> > > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > > packets from device, I wish you used terms from virtio spec.
> > > > > > 
> > > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > > > 
> > > > > > > 
> > > > > > > > For example: 
> > > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > > > 
> > > > > > > > Then the specific implementation can be
> > > > > > > > 
> > > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > > > 
> > > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > > > 
> > > > > > > > Thanks.
> > > > > > > 
> > > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > > > 
> > > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > > that the packet received by the driver will not be marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > > 
> > > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > > 
> > > > > > > 
> > > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > > disables all offloads but you want to keep some of them?
> > > > > > > 
> > > > > > 
> > > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > > then the driver may always receive packets marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > > same time.
> > > > > 
> > > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > > > 
> > > > We need to focus on what happens when the XDP program is loaded:
> > > > 
> > > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > > feature when loading XDP. The main reason for doing this is because
> > > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > > fields are correct after XDP modifies the packets.
> > > 
> > > What do you want the device to do with these packets?
> > > Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
> > > Then ... why don't you have the driver clear that bit?
> > 
> > Just clearing VIRTIO_NET_HDR_F_NEEDS_CSUM will cause the stack to drop
> > packets when validating the checksum.
> > 
> > >From [1] we know that after negotiating VIRTIO_NET_F_GUEST_CSUM, the
> > device can choose to save some work, thus generating packets carrying
> > VIRTIO_NET_HDR_F_NEEDS_CSUM. The new feature just keeping the device from saving
> > the work it's supposed to be doing. Of course, this will bring some
> > device calculating overhead, but if the device has sufficient calculating
> > resources, it can offer the new feature.
> > 
> > [1] “The converse features are also available: a driver can save the
> > virtual device some work by negotiating these features. Note: For
> > example, a network packet transported between two guests on the same
> > system might not need checksumming at all, nor segmentation , if both
> > guests are amenable.”
> > 
> > Thanks.
> 
> Can't say I know exactly what you are trying to do ...

I want to enable VIRTIO_NET_F_GUEST_CSUM when XDP loads, there are
several possible directions to do so:

1. Avoid letting the driver receive packets marked as
VIRTIO_NET_HDR_F_NEEDS_CSUM, that is, packets that can only be marked as
VIRTIO_NET_HDR_F_DATA_VALID or CHECKSUM_NONE.
    -> We can achieve this by adding a flag.

2. For packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM, re-probe the
correct csum_{start, offset} and re-calculate the pseudo-header checksum.
This way is suggested by Jason. We can use a flow dissector to do this.

3. Enable VIRTIO_NET_F_GUEST_CSUM rudely, based on our assumption that
the virtual environment is safe and the XDP program will not
destroy the packet.

4. Modify the XDP core to add support for an XDP flag, which is used to
identify that the XDP program is a read-only XDP prog. This way we can enable
VIRTIO_NET_F_GUEST_CSUM for loading of read-only XDP programs.

Is this clear please? If you still have questions, I will continue to answer.

> should we look for ways to set CHECKSUM_COMPLETE for some packets?
> 

In fact, we shouldb't, this is the same solution as simply clearing
VIRTIO_NET_HDR_F_NEEDS_CSUM, which will cause the stack to drop packets
due to the incorrect checksum.

rx CHECKSUM_COMPLETE means to validate the packet with the correct
checksum (such as the correct udp_hdr->check field), but the packet
modified by XDP no longer has the correct udp_hdr->check. The driver
helps to validate the packet has not helped (even the driver'll discard
it after validation)

> Or did you decide to forego changing the spec for now
> and will just make a driver change?
> 

Either way might work. I'd try Jason's suggestion first (i.e. reprobe
csum_{start, offset} and compute pseudo-header sums) to make a patch.

Thanks.

> 
> > > 
> > > > So in order for the driver to continue to enjoy the device's ability to
> > > > validate packets while XDP is loaded, we need a new feature to tell the
> > > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > > other words, the device can only deliver packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID).
> > > > 
> > > > Thanks.
> > > 
> > > 
> > > 
> > > 
> > > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > > >   from \field{csum_start} and any preceding checksums
> > > > >   have been validated.  The checksum on the packet is incomplete and
> > > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> > > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > > >   (see Packet Transmission point 1).
> > > > > 
> > > > > Did you maybe mean if either feature is negotiated?
> > > > > 
> > > > > 
> > > > > 
> > > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > > > 
> > > > > > 
> > > > > > Sure. Will do as you suggested.
> > > > > > 
> > > > > > Thanks.
> > > > > > 
> > > > > > > 
> > > > > > > -- 
> > > > > > > MST
> > > > > > > 
> > > > > > > 
> > > > > > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > > > 
> > > > > 
> > > > > This publicly archived list offers a means to provide input to the
> > > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > > > 
> > > > > In order to verify user consent to the Feedback License terms and
> > > > > to minimize spam in the list archive, subscription is required
> > > > > before posting.
> > > > > 
> > > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > > Join OASIS: https://www.oasis-open.org/join/
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > 
> > This publicly archived list offers a means to provide input to the
> > OASIS Virtual I/O Device (VIRTIO) TC.
> > 
> > In order to verify user consent to the Feedback License terms and
> > to minimize spam in the list archive, subscription is required
> > before posting.
> > 
> > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > List help: virtio-comment-help@lists.oasis-open.org
> > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > Committee: https://www.oasis-open.org/committees/virtio/
> > Join OASIS: https://www.oasis-open.org/join/
> > 
> 
> 
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
> 
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
> 
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/

---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [virtio-comment] Re: [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net
@ 2023-05-31  6:57                     ` Heng Qi
  0 siblings, 0 replies; 34+ messages in thread
From: Heng Qi @ 2023-05-31  6:57 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: virtio-dev, virtio-comment, Jason Wang, Parav Pandit, Xuan Zhuo

On Tue, May 30, 2023 at 03:33:22PM -0400, Michael S. Tsirkin wrote:
> On Wed, May 24, 2023 at 04:12:46PM +0800, Heng Qi wrote:
> > On Wed, May 24, 2023 at 02:07:14AM -0400, Michael S. Tsirkin wrote:
> > > On Tue, May 23, 2023 at 09:51:44PM +0800, Heng Qi wrote:
> > > > On Tue, May 23, 2023 at 09:30:28AM -0400, Michael S. Tsirkin wrote:
> > > > > On Tue, May 23, 2023 at 05:18:20PM +0800, Heng Qi wrote:
> > > > > > On Tue, May 23, 2023 at 03:15:37AM -0400, Michael S. Tsirkin wrote:
> > > > > > > On Tue, May 23, 2023 at 10:41:18AM +0800, Heng Qi wrote:
> > > > > > > > On Mon, May 22, 2023 at 03:10:05PM -0400, Michael S. Tsirkin wrote:
> > > > > > > > > On Mon, May 22, 2023 at 08:12:00PM +0800, Heng Qi wrote:
> > > > > > > > > > 1) Add a feature bit to the virtio specification to tell the sender that a fully
> > > > > > > > > > csumed packet must be sent.
> > > > > > > > > 
> > > > > > > > > Who is the sender in this picture? The driver?
> > > > > > > > 
> > > > > > > > The device or the driver.
> > > > > > > > 
> > > > > > > > When the device is hw, the sender is more likely to be a device.
> > > > > > > > When the device is sw, the sender can be a device or a driver.
> > > > > > > >
> > > > > > > > But in general, this feature is inclined to constrain the behavior of the device and
> > > > > > > > the driver from the receiving side.
> > > > > > > 
> > > > > > > Based on above I am guessing you are talking about driver getting
> > > > > > > packets from device, I wish you used terms from virtio spec.
> > > > > > 
> > > > > > Yes, I'm going to use the terminology of the virtio spec.
> > > > > > 
> > > > > > > 
> > > > > > > > For example: 
> > > > > > > > VIRTIO_NET_F_UNNECESSARY_CSUM : The driver tells the device that you must send me a fully csumed packet.
> > > > > > > > 
> > > > > > > > Then the specific implementation can be
> > > > > > > > 
> > > > > > > > (1) the sender sends a fully csumed packet;
> > > > > > > > (2) the receiver receives a CHECKSUM_PARTIAL packet, and the device helps calculate the fully csum
> > > > > > > >     (because the two parties in the communication are located on the same host, the packet is trusted.).
> > > > > > > > 
> > > > > > > > In summary, if VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the driver will no longer receive any packets marked CHECKSUM_PARTIAL.
> > > > > > > > 
> > > > > > > > Thanks.
> > > > > > > 
> > > > > > > This is what clearing VIRTIO_NET_F_GUEST_CSUM does.
> > > > > > 
> > > > > > Yes, but with VIRTIO_NET_F_GUEST_CSUM cleared, although the device can
> > > > > > receive a fully checksummed packet, we can no longer enjoy
> > > > > > the device's ability to validate the packet checksum. That is, the value
> > > > > > of \field{flags} in the virtio_net_hdr structure is set to 0, which means
> > > > > > that the packet received by the driver will not be marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > > 
> > > > > > So, we need a feature bit (let's say VIRTIO_NET_F_UNNECESSARY_CSUM).
> > > > > > If VIRTIO_NET_F_UNNECESSARY_CSUM is negotiated, the device must give the
> > > > > > driver a fully checksummed packet, and the packet is validated by the
> > > > > > device with \field{flags} set to VIRTIO_NET_HDR_F_DATA_VALID.
> > > > > > 
> > > > > > > 
> > > > > > > I feel you are trying to say that clearing VIRTIO_NET_F_GUEST_CSUM
> > > > > > > disables all offloads but you want to keep some of them?
> > > > > > > 
> > > > > > 
> > > > > > No, what I mean is that a feature VIRTIO_NET_F_UNNECESSARY_CSUM is needed
> > > > > > in addition to VIRTIO_NET_F_GUEST_CSUM, if both features are negotiated,
> > > > > > then the driver may always receive packets marked as
> > > > > > VIRTIO_NET_HDR_F_DATA_VALID, which means that we can now load XDP at the
> > > > > > same time.
> > > > > 
> > > > > Makes no sense to me. VIRTIO_NET_F_GUEST_CSUM set already allows
> > > > > VIRTIO_NET_HDR_F_DATA_VALID:
> > > > 
> > > > We need to focus on what happens when the XDP program is loaded:
> > > > 
> > > > The current virtio-net needs to turn off the VIRTIO_NET_F_GUEST_CSUM
> > > > feature when loading XDP. The main reason for doing this is because
> > > > VIRTIO_NET_F_GUEST_CSUM allows to receive packets marked as
> > > > VIRTIO_NET_HDR_F_NEEDS_CSUM. Such packets are not compatible with
> > > > XDP programs, because we cannot guarantee that the csum_{start, offset}
> > > > fields are correct after XDP modifies the packets.
> > > 
> > > What do you want the device to do with these packets?
> > > Just clear VIRTIO_NET_HDR_F_NEEDS_CSUM?
> > > Then ... why don't you have the driver clear that bit?
> > 
> > Just clearing VIRTIO_NET_HDR_F_NEEDS_CSUM will cause the stack to drop
> > packets when validating the checksum.
> > 
> > >From [1] we know that after negotiating VIRTIO_NET_F_GUEST_CSUM, the
> > device can choose to save some work, thus generating packets carrying
> > VIRTIO_NET_HDR_F_NEEDS_CSUM. The new feature just keeping the device from saving
> > the work it's supposed to be doing. Of course, this will bring some
> > device calculating overhead, but if the device has sufficient calculating
> > resources, it can offer the new feature.
> > 
> > [1] “The converse features are also available: a driver can save the
> > virtual device some work by negotiating these features. Note: For
> > example, a network packet transported between two guests on the same
> > system might not need checksumming at all, nor segmentation , if both
> > guests are amenable.”
> > 
> > Thanks.
> 
> Can't say I know exactly what you are trying to do ...

I want to enable VIRTIO_NET_F_GUEST_CSUM when XDP loads, there are
several possible directions to do so:

1. Avoid letting the driver receive packets marked as
VIRTIO_NET_HDR_F_NEEDS_CSUM, that is, packets that can only be marked as
VIRTIO_NET_HDR_F_DATA_VALID or CHECKSUM_NONE.
    -> We can achieve this by adding a flag.

2. For packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM, re-probe the
correct csum_{start, offset} and re-calculate the pseudo-header checksum.
This way is suggested by Jason. We can use a flow dissector to do this.

3. Enable VIRTIO_NET_F_GUEST_CSUM rudely, based on our assumption that
the virtual environment is safe and the XDP program will not
destroy the packet.

4. Modify the XDP core to add support for an XDP flag, which is used to
identify that the XDP program is a read-only XDP prog. This way we can enable
VIRTIO_NET_F_GUEST_CSUM for loading of read-only XDP programs.

Is this clear please? If you still have questions, I will continue to answer.

> should we look for ways to set CHECKSUM_COMPLETE for some packets?
> 

In fact, we shouldb't, this is the same solution as simply clearing
VIRTIO_NET_HDR_F_NEEDS_CSUM, which will cause the stack to drop packets
due to the incorrect checksum.

rx CHECKSUM_COMPLETE means to validate the packet with the correct
checksum (such as the correct udp_hdr->check field), but the packet
modified by XDP no longer has the correct udp_hdr->check. The driver
helps to validate the packet has not helped (even the driver'll discard
it after validation)

> Or did you decide to forego changing the spec for now
> and will just make a driver change?
> 

Either way might work. I'd try Jason's suggestion first (i.e. reprobe
csum_{start, offset} and compute pseudo-header sums) to make a patch.

Thanks.

> 
> > > 
> > > > So in order for the driver to continue to enjoy the device's ability to
> > > > validate packets while XDP is loaded, we need a new feature to tell the
> > > > device not to deliver packets marked as VIRTIO_NET_HDR_F_NEEDS_CSUM (in
> > > > other words, the device can only deliver packets marked as
> > > > VIRTIO_NET_HDR_F_DATA_VALID).
> > > > 
> > > > Thanks.
> > > 
> > > 
> > > 
> > > 
> > > > > \item If the VIRTIO_NET_F_GUEST_CSUM feature was negotiated, the
> > > > >   VIRTIO_NET_HDR_F_NEEDS_CSUM bit in \field{flags} can be
> > > > >   set: if so, the packet checksum at offset \field{csum_offset}
> > > > >   from \field{csum_start} and any preceding checksums
> > > > >   have been validated.  The checksum on the packet is incomplete and
> > > > >   if bit VIRTIO_NET_HDR_F_RSC_INFO is not set in \field{flags}, 
> > > > >   then \field{csum_start} and \field{csum_offset} indicate how to calculate it
> > > > >   (see Packet Transmission point 1).
> > > > > 
> > > > > Did you maybe mean if either feature is negotiated?
> > > > > 
> > > > > 
> > > > > 
> > > > > > > Again please use virtio terminology not Linux. to help you out,
> > > > > > > in current linux, VIRTIO_NET_HDR_F_NEEDS_CSUM and VIRTIO_NET_HDR_F_DATA_VALID
> > > > > > > will set CHECKSUM_PARTIAL and CHECKSUM_UNNECESSARY respectively.
> > > > > > > 
> > > > > > 
> > > > > > Sure. Will do as you suggested.
> > > > > > 
> > > > > > Thanks.
> > > > > > 
> > > > > > > 
> > > > > > > -- 
> > > > > > > MST
> > > > > > > 
> > > > > > > 
> > > > > > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > > > > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > > > > 
> > > > > 
> > > > > This publicly archived list offers a means to provide input to the
> > > > > OASIS Virtual I/O Device (VIRTIO) TC.
> > > > > 
> > > > > In order to verify user consent to the Feedback License terms and
> > > > > to minimize spam in the list archive, subscription is required
> > > > > before posting.
> > > > > 
> > > > > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > > > > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > > > > List help: virtio-comment-help@lists.oasis-open.org
> > > > > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > > > > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > > > > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > > > > Committee: https://www.oasis-open.org/committees/virtio/
> > > > > Join OASIS: https://www.oasis-open.org/join/
> > > 
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
> > > For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
> > 
> > This publicly archived list offers a means to provide input to the
> > OASIS Virtual I/O Device (VIRTIO) TC.
> > 
> > In order to verify user consent to the Feedback License terms and
> > to minimize spam in the list archive, subscription is required
> > before posting.
> > 
> > Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> > Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> > List help: virtio-comment-help@lists.oasis-open.org
> > List archive: https://lists.oasis-open.org/archives/virtio-comment/
> > Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> > List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> > Committee: https://www.oasis-open.org/committees/virtio/
> > Join OASIS: https://www.oasis-open.org/join/
> > 
> 
> 
> This publicly archived list offers a means to provide input to the
> OASIS Virtual I/O Device (VIRTIO) TC.
> 
> In order to verify user consent to the Feedback License terms and
> to minimize spam in the list archive, subscription is required
> before posting.
> 
> Subscribe: virtio-comment-subscribe@lists.oasis-open.org
> Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
> List help: virtio-comment-help@lists.oasis-open.org
> List archive: https://lists.oasis-open.org/archives/virtio-comment/
> Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
> List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
> Committee: https://www.oasis-open.org/committees/virtio/
> Join OASIS: https://www.oasis-open.org/join/

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: virtio-comment-subscribe@lists.oasis-open.org
Unsubscribe: virtio-comment-unsubscribe@lists.oasis-open.org
List help: virtio-comment-help@lists.oasis-open.org
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2023-05-31  6:57 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-22 12:12 [virtio-dev] [Proposal] Relationship between XDP and rx-csum in virtio-net Heng Qi
2023-05-22 12:12 ` [virtio-comment] " Heng Qi
2023-05-22 19:10 ` [virtio-dev] " Michael S. Tsirkin
2023-05-22 19:10   ` [virtio-comment] " Michael S. Tsirkin
2023-05-23  2:41   ` [virtio-dev] " Heng Qi
2023-05-23  2:41     ` [virtio-comment] " Heng Qi
2023-05-23  7:15     ` [virtio-dev] " Michael S. Tsirkin
2023-05-23  7:15       ` [virtio-comment] " Michael S. Tsirkin
2023-05-23  9:18       ` [virtio-dev] " Heng Qi
2023-05-23  9:18         ` [virtio-comment] " Heng Qi
2023-05-23 13:30         ` Michael S. Tsirkin
2023-05-23 13:30           ` [virtio-comment] " Michael S. Tsirkin
2023-05-23 13:51           ` [virtio-dev] " Heng Qi
2023-05-23 13:51             ` Heng Qi
2023-05-24  4:09             ` [virtio-dev] " Jason Wang
2023-05-24  4:09               ` Jason Wang
2023-05-24  5:07               ` [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-nety Heng Qi
2023-05-24  5:07                 ` Heng Qi
2023-05-24  5:52                 ` [virtio-dev] " Jason Wang
2023-05-24  5:52                   ` Jason Wang
2023-05-24  7:24                   ` [virtio-dev] " Heng Qi
2023-05-24  7:24                     ` [virtio-comment] " Heng Qi
2023-05-26  7:58                     ` [virtio-dev] " Heng Qi
2023-05-26  7:58                       ` Heng Qi
2023-05-24  5:17               ` [virtio-dev] Re: [virtio-comment] Re: [virtio-dev] Re: [Proposal] Relationship between XDP and rx-csum in virtio-net Heng Qi
2023-05-24  5:17                 ` [virtio-comment] " Heng Qi
2023-05-24  6:07             ` Michael S. Tsirkin
2023-05-24  6:07               ` Michael S. Tsirkin
2023-05-24  8:12               ` [virtio-dev] " Heng Qi
2023-05-24  8:12                 ` [virtio-comment] " Heng Qi
2023-05-30 19:33                 ` [virtio-dev] " Michael S. Tsirkin
2023-05-30 19:33                   ` Michael S. Tsirkin
2023-05-31  6:57                   ` [virtio-dev] " Heng Qi
2023-05-31  6:57                     ` Heng Qi

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.