[3/5] net/virtio: do not touch Tx offload flags

Message ID 20210401095243.18211-4-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Offload flags fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand April 1, 2021, 9:52 a.m. UTC
  Tx offload flags are of the application responsibility.
Leave the mbuf alone and use a local storage for implicit tcp checksum
offloading in case of TSO.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/virtio/virtqueue.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Maxime Coquelin April 13, 2021, 2:17 p.m. UTC | #1
On 4/1/21 11:52 AM, David Marchand wrote:
> Tx offload flags are of the application responsibility.
> Leave the mbuf alone and use a local storage for implicit tcp checksum
> offloading in case of TSO.
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
>  drivers/net/virtio/virtqueue.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
> index 71b66f3208..2e8826bc28 100644
> --- a/drivers/net/virtio/virtqueue.h
> +++ b/drivers/net/virtio/virtqueue.h
> @@ -618,10 +618,12 @@ virtqueue_xmit_offload(struct virtio_net_hdr *hdr,
>  			uint8_t offload)
>  {
>  	if (offload) {
> +		uint64_t csum_l4 = cookie->ol_flags & PKT_TX_L4_MASK;
> +
>  		if (cookie->ol_flags & PKT_TX_TCP_SEG)
> -			cookie->ol_flags |= PKT_TX_TCP_CKSUM;
> +			csum_l4 |= PKT_TX_TCP_CKSUM;
>  
> -		switch (cookie->ol_flags & PKT_TX_L4_MASK) {
> +		switch (csum_l4) {
>  		case PKT_TX_UDP_CKSUM:
>  			hdr->csum_start = cookie->l2_len + cookie->l3_len;
>  			hdr->csum_offset = offsetof(struct rte_udp_hdr,
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h
index 71b66f3208..2e8826bc28 100644
--- a/drivers/net/virtio/virtqueue.h
+++ b/drivers/net/virtio/virtqueue.h
@@ -618,10 +618,12 @@  virtqueue_xmit_offload(struct virtio_net_hdr *hdr,
 			uint8_t offload)
 {
 	if (offload) {
+		uint64_t csum_l4 = cookie->ol_flags & PKT_TX_L4_MASK;
+
 		if (cookie->ol_flags & PKT_TX_TCP_SEG)
-			cookie->ol_flags |= PKT_TX_TCP_CKSUM;
+			csum_l4 |= PKT_TX_TCP_CKSUM;
 
-		switch (cookie->ol_flags & PKT_TX_L4_MASK) {
+		switch (csum_l4) {
 		case PKT_TX_UDP_CKSUM:
 			hdr->csum_start = cookie->l2_len + cookie->l3_len;
 			hdr->csum_offset = offsetof(struct rte_udp_hdr,