From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 72E8CA0A0A;
	Sat,  8 May 2021 08:24:43 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id E82BA40140;
	Sat,  8 May 2021 08:24:42 +0200 (CEST)
Received: from mga07.intel.com (mga07.intel.com [134.134.136.100])
 by mails.dpdk.org (Postfix) with ESMTP id F37AC4013F;
 Sat,  8 May 2021 08:24:40 +0200 (CEST)
IronPort-SDR: FoH+XBwKpSO6GhCfF2blawNvUICA8vM7x17IMxEzT2+xqxsmHha/zWzcR7J3Ot7nAahduBYscx
 ZhJg3jVCiCOw==
X-IronPort-AV: E=McAfee;i="6200,9189,9977"; a="262810528"
X-IronPort-AV: E=Sophos;i="5.82,282,1613462400"; d="scan'208";a="262810528"
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 07 May 2021 23:24:39 -0700
IronPort-SDR: f1HzNEGj2hRBt10c29VvR5y85mjm7/grPGJgDXUxRfcdSsQbhi4wksZD055bklBEpneslbGi2r
 W8Zd6FajZ2KQ==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.82,282,1613462400"; d="scan'208";a="470147632"
Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81])
 by orsmga001.jf.intel.com with ESMTP; 07 May 2021 23:24:34 -0700
Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by
 fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2106.2; Fri, 7 May 2021 23:24:32 -0700
Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by
 fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id
 15.1.2106.2; Fri, 7 May 2021 23:24:32 -0700
Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by
 fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2
 via Frontend Transport; Fri, 7 May 2021 23:24:32 -0700
Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.45) by
 edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server
 (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 15.1.2106.2; Fri, 7 May 2021 23:24:31 -0700
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=NBSCBgMRBBUAgsCX/xy/f7+8+xJrqYt0bARa2ea44EXBLCsaGWzlySNGdg6elOFLk3V/jsXQFvqCIQtEL/+3dtqLL8P89P8DPZohWihtn6HUvTXX3m0GP8k7G9tGRyc06gOj3y7LDFWA2fitIzN2ni/IrxQEecOcrnRjO4/Wiq8ruttP49iI/w8EfIplBKa0HMnVxVVH9ZmIsq6FZK1yKSjXX7DArHu215LXKMl8Sw9xm/yLlOdi5rqN5rl317HZhWyTQBxbriiSSMAGwCLFziN8xkNGj7NiZL0SyGJ/ogIJU/1cbld304morGD7O3Ps0gVNC+7Wag63NnkRKqTIzQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=w8ZIwGPvrag6gq5s4BU8Uu7U/C2ghMkXns87fJs2Kss=;
 b=N77Xoyb6K39rRmnfheUUxwRYsfSeaFQgi9gBrfdX+0UEiv0ieAu+w0grVUDGICATeEL2L1nCScb7UWjQioAX0iu10UiShPHcv6O+4uUWXtG0WsGd5BjD3e9ONl5E0x+frXsJlwsZFjCDuue6tYWq9B2XhRJSD3OKPu+D3zpUVb4gbXVF5RP+Oe1+AOlCYFcF8TAzZidHwzFIdrp/+udgq15BU/GGbbI3bFBLraC0lK+Qet3Ko21EBP1F4qUqXuFABnEiQyP15Ig/cjRsWyceg6nnvbYg8MuC+a2E73/uhkivx5DKIzLTSSoG3oF/nnKREHYfoysnU2L8/WLBM6NlOA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com;
 dkim=pass header.d=intel.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; 
 s=selector2-intel-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=w8ZIwGPvrag6gq5s4BU8Uu7U/C2ghMkXns87fJs2Kss=;
 b=x9KGhDbi4hN4AgjTOjDijil6IInXnTVyN6X6M1cD0+aN/fQ4zDLa8BHHABqliADySkeSuLsMMrlLUQ6GUvWfeTQXrjVj/SpcjPbJcciNCKFW5owGYYA2nLfpopT+mBWwC0lX3nZN/JPpmbS3N1UtHtJTNozgfQwiLRIv4IaNej4=
Received: from BYAPR11MB2648.namprd11.prod.outlook.com (2603:10b6:a02:c7::10)
 by BYAPR11MB3093.namprd11.prod.outlook.com (2603:10b6:a03:88::28)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.30; Sat, 8 May
 2021 06:24:29 +0000
Received: from BYAPR11MB2648.namprd11.prod.outlook.com
 ([fe80::f4a4:3591:faa3:9668]) by BYAPR11MB2648.namprd11.prod.outlook.com
 ([fe80::f4a4:3591:faa3:9668%3]) with mapi id 15.20.4108.029; Sat, 8 May 2021
 06:24:29 +0000
From: "Wang, Yinan" <yinan.wang@intel.com>
To: David Marchand <david.marchand@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
CC: "maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>,
 "olivier.matz@6wind.com" <olivier.matz@6wind.com>, "fbl@sysclose.org"
 <fbl@sysclose.org>, "i.maximets@ovn.org" <i.maximets@ovn.org>, "Xia, Chenbo"
 <chenbo.xia@intel.com>, "Stokes, Ian" <ian.stokes@intel.com>,
 "stable@dpdk.org" <stable@dpdk.org>, Jijiang Liu <jijiang.liu@intel.com>,
 Yuanhan Liu <yuanhan.liu@linux.intel.com>
Thread-Topic: [dpdk-dev] [PATCH v4 3/3] vhost: fix offload flags in Rx path
Thread-Index: AQHXQDulapoCk2qKMky163ry0DYlIqrZIvcA
Date: Sat, 8 May 2021 06:24:29 +0000
Message-ID: <BYAPR11MB264891FD6862DC3936D4EACB8F569@BYAPR11MB2648.namprd11.prod.outlook.com>
References: <20210401095243.18211-1-david.marchand@redhat.com>
 <20210503164344.27916-1-david.marchand@redhat.com>
 <20210503164344.27916-4-david.marchand@redhat.com>
In-Reply-To: <20210503164344.27916-4-david.marchand@redhat.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
dlp-reaction: no-action
dlp-version: 11.5.1.3
dlp-product: dlpe-windows
authentication-results: redhat.com; dkim=none (message not signed)
 header.d=none;redhat.com; dmarc=none action=none header.from=intel.com;
x-originating-ip: [192.102.204.53]
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: 300b9a65-a729-448d-2198-08d911e9efa9
x-ms-traffictypediagnostic: BYAPR11MB3093:
x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr
x-ms-exchange-transport-forked: True
x-microsoft-antispam-prvs: <BYAPR11MB3093A71F5570C9ABDA5D01818F569@BYAPR11MB3093.namprd11.prod.outlook.com>
x-ms-oob-tlc-oobclassifiers: OLM:8882;
x-ms-exchange-senderadcheck: 1
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: swfT7MAf8vJeS9c69h8KEsPt5Y2AjM2/JIG34Uq/6hi/vpfAvDG6YUaFD7hs9g72AWXiCEVrrQBneEWhZK11T5sexziNp72eB79zzrBUX2cv7gj5HD/wWruYIo5b/cjGfz8La+zJRDiSbh30pzXhgmneW/umqOXXIilflq/dasNMFjV3fCKEaiMAS+X0PUiyCXurHQCMpXdq432/Gk4ehaCr4Ac9QkZ9+GdsjgkAuMkx/xRNtBtLpyhpIimHGxPHxuKxcPoFEMKikkX5G25280iS+Xb/EOFB/YpNcprkBrXwwQhV6tPEBMCeugt+GDarOEg7lBi3haGI3mwBISy1FVMlnTiW0i5kbZqRZBaE74mKVPcw1egHx1EjyWOxf+H5QKYcU78ooMRqbvwpxT1ydtsU19DyoMhMtZi0sHKTSAfVTGXEFSGu367jG/FM7yP2pXtIJXx2syzAWBP/XaQo4Hc3yMqmhMM/KXHKYKFu3eKNzKjd2FKinfDSQI4UZL6BznpPdSrzumb5nldmn5I1K+ZjBZUDeGp8EvfYMJJZ5qPOWWM5Kc22jQJJrB3Q6fbBIXeW2TMvLVC/kieRtyp8eXk0LTIhPNd01d7QJK/OWwQ=
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:BYAPR11MB2648.namprd11.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(376002)(366004)(136003)(346002)(39840400004)(396003)(38100700002)(33656002)(122000001)(66946007)(66476007)(66556008)(66446008)(64756008)(83380400001)(478600001)(2906002)(8676002)(76116006)(86362001)(53546011)(30864003)(186003)(5660300002)(54906003)(110136005)(9686003)(52536014)(316002)(71200400001)(7696005)(8936002)(55016002)(6506007)(26005)(4326008)(579004)(559001);
 DIR:OUT; SFP:1102; 
x-ms-exchange-antispam-messagedata: =?Windows-1252?Q?Ucw6Ud9VWhFE7fZGV284cIo5SWUPHD3hbfzngjk+EhYCd1rcg8ziVT1m?=
 =?Windows-1252?Q?jiuB5oqsWlE58CqPo/NUvlu+VfacBrK+TYLF8AzPGeAz+NyKxEu+24eP?=
 =?Windows-1252?Q?dJNV0MievfHzgLGFmllJIffdw6nziQTxVbYrZtn6ICn7p84nj5R31y7L?=
 =?Windows-1252?Q?miACupRQdGfpTCk4+dvTWiy/B9bmB1gY1IBRbAPDj0ZfByWf14vFdCL8?=
 =?Windows-1252?Q?rH4hInl3j3UstIOxaVp9t1uVxPBT1njlGnGKi1VWKWDu277vDjJqEFtn?=
 =?Windows-1252?Q?Jffpo0jMjpJWHltIJ749IshZtYzF5rU1UZLEKfyW8VicBlpL/vOjw0dt?=
 =?Windows-1252?Q?8AEkC01lDD/IgsK5eldJIxMtiCTOHeYWM2Iym413xjUeaACcV6ndPFSP?=
 =?Windows-1252?Q?tOqraq09sS6++r3mSuWoXAtEPL7o0tQNz+CbQKwXJSl/t2vRkISV2GrM?=
 =?Windows-1252?Q?FyT+3IhV9iPPf9Pc1gqkC/83TlvyFNa2QMrora/T4HHUcthPLHgfKaaC?=
 =?Windows-1252?Q?606aadUx8uDG6bhuqds5mtO6j3f3tDxgLWqBv7gA2L3nT78HZD93Y0rC?=
 =?Windows-1252?Q?yoAhndRGYjzVkZUYM9+m20OVuqSCh/S4UqQkdjwp5LUNIwpK2F/pzAvS?=
 =?Windows-1252?Q?3BWanJ8Q/sKs9wkcC27XD3NXHigKWj0EzzoTWUJBo1eozefx4rxcjSa9?=
 =?Windows-1252?Q?fccDFviiK/KQyaC/tr2lkPEXQX0cfBqZ/VY3WvwbpaI0TEO3wZnQPvem?=
 =?Windows-1252?Q?E5EYFftkO+yrdvyOB39R83C7o2t7wA3WhCBb4IgO+cJGjwMWFOJUGsco?=
 =?Windows-1252?Q?M6Xjh0REqVs7NMQZn3SCOFSp0OnsY8n5CEssdr8Y1M4bUUYYr6pazw+0?=
 =?Windows-1252?Q?9jRXtI/RZIErxTzRICimUu+zajYsfuoOiPR04iZw9sjuOh1TuOwk8/iA?=
 =?Windows-1252?Q?dlS7P0QrX+IUfYfxKqZhHDRurbOD8cciXIwCJNz86x7uelWfUH39LH5O?=
 =?Windows-1252?Q?hP30uF6A1yPXDqb4sWSBBxW6zjTnnOzIRXwjS6zEFMPAI5Gl6kBTtnfK?=
 =?Windows-1252?Q?HylCy8mzb6DRXmnK8ojoFD1HK5FeYaIUfHStarCHiPh3id+EF6nzR0qI?=
 =?Windows-1252?Q?wa1DQjnUMGyekH0VIFU2rVUHcj40N+fuNB7YuBX9HJodbgmiiSe6/JvP?=
 =?Windows-1252?Q?6eaOgd8RrJZJWKrj0341afPFRNa/O2jbsiZ8nc4s0b+g/43BpSnYcXOC?=
 =?Windows-1252?Q?XVvh2jQURsA0tJG4+41JtIqVJ/VBvRk8lsSFqUEJfHFK7Cn/GH5cXTo2?=
 =?Windows-1252?Q?IcLTp/3FR9yfOTqw882J+SUNiIQ+0ssLLI0UkkJY8w1mKlz0jVjf3dz0?=
 =?Windows-1252?Q?4YaCM7GvJ/IgzUGyBPxNuzepXPsz3MrgWTe0auK8DzkDu4GKQyRBcWIW?=
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB2648.namprd11.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 300b9a65-a729-448d-2198-08d911e9efa9
X-MS-Exchange-CrossTenant-originalarrivaltime: 08 May 2021 06:24:29.3877 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: Z9RP46MiFJ1rU20x0iBAY404PbmsRVxwmVwBTrTwwBJOSNEgNL2rCJJhO/FugVEWdw3Rv1bZHEQ6j/Ucb2zcHg==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3093
X-OriginatorOrg: intel.com
Subject: Re: [dpdk-dev] [PATCH v4 3/3] vhost: fix offload flags in Rx path
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

Hi David,

May I know how to configures Tx offloading by testpmd, could you help to pr=
ovide an example case?
I add a case which need vhost tx offload (TSO/cksum) function, this case ca=
n't work with the patch, could you use this case as the example if possible=
?

For example: VM2VM split ring vhost-user/virtio-net test with tcp traffic=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

1. Launch the Vhost sample on socket 0 by below commands::

    rm -rf vhost-net*
    ./dpdk-testpmd -l 2-4 -n 4 --no-pci --file-prefix=3Dvhost --vdev 'net_v=
host0,iface=3Dvhost-net0,queues=3D1' \
    --vdev 'net_vhost1,iface=3Dvhost-net1,queues=3D1'  -- -i --nb-cores=3D2=
 --txd=3D1024 --rxd=3D1024
    testpmd>start

2. Launch VM1 and VM2 on socket 1::

    taskset -c 32 qemu-system-x86_64 -name vm1 -enable-kvm -cpu host -smp 1=
 -m 4096 \
    -object memory-backend-file,id=3Dmem,size=3D4096M,mem-path=3D/mnt/huge,=
share=3Don \
    -numa node,memdev=3Dmem -mem-prealloc -drive file=3D/home/osimg/ubuntu2=
0-04.img  \
    -chardev socket,path=3D/tmp/vm2_qga0.sock,server,nowait,id=3Dvm2_qga0 -=
device virtio-serial \
    -device virtserialport,chardev=3Dvm2_qga0,name=3Dorg.qemu.guest_agent.2=
 -daemonize \
    -monitor unix:/tmp/vm2_monitor.sock,server,nowait -device e1000,netdev=
=3Dnttsip1 \
    -netdev user,id=3Dnttsip1,hostfwd=3Dtcp:127.0.0.1:6002-:22 \
    -chardev socket,id=3Dchar0,path=3D./vhost-net0 \
    -netdev type=3Dvhost-user,id=3Dnetdev0,chardev=3Dchar0,vhostforce \
    -device virtio-net-pci,netdev=3Dnetdev0,mac=3D52:54:00:00:00:01,disable=
-modern=3Dfalse,mrg_rxbuf=3Don,csum=3Don,guest_csum=3Don,host_tso4=3Don,gue=
st_tso4=3Don,guest_ecn=3Don -vnc :10

   taskset -c 33 qemu-system-x86_64 -name vm2 -enable-kvm -cpu host -smp 1 =
-m 4096 \
    -object memory-backend-file,id=3Dmem,size=3D4096M,mem-path=3D/mnt/huge,=
share=3Don \
    -numa node,memdev=3Dmem -mem-prealloc -drive file=3D/home/osimg/ubuntu2=
0-04-2.img  \
    -chardev socket,path=3D/tmp/vm2_qga0.sock,server,nowait,id=3Dvm2_qga0 -=
device virtio-serial \
    -device virtserialport,chardev=3Dvm2_qga0,name=3Dorg.qemu.guest_agent.2=
 -daemonize \
    -monitor unix:/tmp/vm2_monitor.sock,server,nowait -device e1000,netdev=
=3Dnttsip1 \
    -netdev user,id=3Dnttsip1,hostfwd=3Dtcp:127.0.0.1:6003-:22 \
    -chardev socket,id=3Dchar0,path=3D./vhost-net1 \
    -netdev type=3Dvhost-user,id=3Dnetdev0,chardev=3Dchar0,vhostforce \
    -device virtio-net-pci,netdev=3Dnetdev0,mac=3D52:54:00:00:00:02,disable=
-modern=3Dfalse,mrg_rxbuf=3Don,csum=3Don,guest_csum=3Don,host_tso4=3Don,gue=
st_tso4=3Don,guest_ecn=3Don -vnc :12

3. On VM1, set virtio device IP and run arp protocal::

    ifconfig ens5 1.1.1.2
    arp -s 1.1.1.8 52:54:00:00:00:02

4. On VM2, set virtio device IP and run arp protocal::

    ifconfig ens5 1.1.1.8
    arp -s 1.1.1.2 52:54:00:00:00:01

5. Check the iperf performance with different packet size between two VMs b=
y below commands::

    Under VM1, run: `iperf -s -i 1`
    Under VM2, run: `iperf -c 1.1.1.2 -i 1 -t 60`

BR,
Yinan

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of David Marchand
> Sent: 2021?5?4? 0:44
> To: dev@dpdk.org
> Cc: maxime.coquelin@redhat.com; olivier.matz@6wind.com;
> fbl@sysclose.org; i.maximets@ovn.org; Xia, Chenbo
> <chenbo.xia@intel.com>; Stokes, Ian <ian.stokes@intel.com>;
> stable@dpdk.org; Jijiang Liu <jijiang.liu@intel.com>; Yuanhan Liu
> <yuanhan.liu@linux.intel.com>
> Subject: [dpdk-dev] [PATCH v4 3/3] vhost: fix offload flags in Rx path
>=20
> The vhost library currently configures Tx offloading (PKT_TX_*) on any
> packet received from a guest virtio device which asks for some offloading=
.
>=20
> This is problematic, as Tx offloading is something that the application
> must ask for: the application needs to configure devices
> to support every used offloads (ip, tcp checksumming, tso..), and the
> various l2/l3/l4 lengths must be set following any processing that
> happened in the application itself.
>=20
> On the other hand, the received packets are not marked wrt current
> packet l3/l4 checksumming info.
>=20
> Copy virtio rx processing to fix those offload flags with some
> differences:
> - accept VIRTIO_NET_HDR_GSO_ECN and VIRTIO_NET_HDR_GSO_UDP,
> - ignore anything but the VIRTIO_NET_HDR_F_NEEDS_CSUM flag (to comply
> with
>   the virtio spec),
>=20
> Some applications might rely on the current behavior, so it is left
> untouched by default.
> A new RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS flag is added to
> enable the
> new behavior.
>=20
> The vhost example has been updated for the new behavior: TSO is applied
> to
> any packet marked LRO.
>=20
> Fixes: 859b480d5afd ("vhost: add guest offload setting")
> Cc: stable@dpdk.org
>=20
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
> Changes since v3:
> - rebased on next-virtio,
>=20
> Changes since v2:
> - introduced a new flag to keep existing behavior as the default,
> - packets with unrecognised offload are passed to the application with no
>   offload metadata rather than dropped,
> - ignored VIRTIO_NET_HDR_F_DATA_VALID since the virtio spec states that
>   the virtio driver is not allowed to use this flag when transmitting
>   packets,
>=20
> Changes since v1:
> - updated vhost example,
> - restored VIRTIO_NET_HDR_GSO_ECN and VIRTIO_NET_HDR_GSO_UDP
> support,
> - restored log on buggy offload request,
>=20
> ---
>  doc/guides/prog_guide/vhost_lib.rst    |  12 ++
>  doc/guides/rel_notes/release_21_05.rst |   6 +
>  drivers/net/vhost/rte_eth_vhost.c      |   2 +-
>  examples/vhost/main.c                  |  44 +++---
>  lib/vhost/rte_vhost.h                  |   1 +
>  lib/vhost/socket.c                     |   5 +-
>  lib/vhost/vhost.c                      |   6 +-
>  lib/vhost/vhost.h                      |  14 +-
>  lib/vhost/virtio_net.c                 | 185 ++++++++++++++++++++++---
>  9 files changed, 222 insertions(+), 53 deletions(-)
>=20
> diff --git a/doc/guides/prog_guide/vhost_lib.rst
> b/doc/guides/prog_guide/vhost_lib.rst
> index 7afa351675..d18fb98910 100644
> --- a/doc/guides/prog_guide/vhost_lib.rst
> +++ b/doc/guides/prog_guide/vhost_lib.rst
> @@ -118,6 +118,18 @@ The following is an overview of some key Vhost
> API functions:
>=20
>      It is disabled by default.
>=20
> +  - ``RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS``
> +
> +    Since v16.04, the vhost library forwards checksum and gso requests f=
or
> +    packets received from a virtio driver by filling Tx offload metadata=
 in
> +    the mbuf. This behavior is inconsistent with other drivers but it is=
 left
> +    untouched for existing applications that might rely on it.
> +
> +    This flag disables the legacy behavior and instead ask vhost to simp=
ly
> +    populate Rx offload metadata in the mbuf.
> +
> +    It is disabled by default.
> +
>  * ``rte_vhost_driver_set_features(path, features)``
>=20
>    This function sets the feature bits the vhost-user driver supports. Th=
e
> diff --git a/doc/guides/rel_notes/release_21_05.rst
> b/doc/guides/rel_notes/release_21_05.rst
> index a5f21f8425..6b7b0810a5 100644
> --- a/doc/guides/rel_notes/release_21_05.rst
> +++ b/doc/guides/rel_notes/release_21_05.rst
> @@ -337,6 +337,12 @@ API Changes
>    ``policer_action_recolor_supported`` and
> ``policer_action_drop_supported``
>    have been removed.
>=20
> +* vhost: The vhost library currently populates received mbufs from a vir=
tio
> +  driver with Tx offload flags while not filling Rx offload flags.
> +  While this behavior is arguable, it is kept untouched.
> +  A new flag ``RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS`` has been
> added to ask
> +  for a behavior compliant with to the mbuf offload API.
> +
>=20
>  ABI Changes
>  -----------
> diff --git a/drivers/net/vhost/rte_eth_vhost.c
> b/drivers/net/vhost/rte_eth_vhost.c
> index d198fc8a8e..281379d6a3 100644
> --- a/drivers/net/vhost/rte_eth_vhost.c
> +++ b/drivers/net/vhost/rte_eth_vhost.c
> @@ -1505,7 +1505,7 @@ rte_pmd_vhost_probe(struct rte_vdev_device
> *dev)
>  	int ret =3D 0;
>  	char *iface_name;
>  	uint16_t queues;
> -	uint64_t flags =3D 0;
> +	uint64_t flags =3D RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
>  	uint64_t disable_flags =3D 0;
>  	int client_mode =3D 0;
>  	int iommu_support =3D 0;
> diff --git a/examples/vhost/main.c b/examples/vhost/main.c
> index 0bee1f3321..d2179eadb9 100644
> --- a/examples/vhost/main.c
> +++ b/examples/vhost/main.c
> @@ -19,6 +19,7 @@
>  #include <rte_log.h>
>  #include <rte_string_fns.h>
>  #include <rte_malloc.h>
> +#include <rte_net.h>
>  #include <rte_vhost.h>
>  #include <rte_ip.h>
>  #include <rte_tcp.h>
> @@ -1029,33 +1030,34 @@ find_local_dest(struct vhost_dev *vdev,
> struct rte_mbuf *m,
>  	return 0;
>  }
>=20
> -static uint16_t
> -get_psd_sum(void *l3_hdr, uint64_t ol_flags)
> -{
> -	if (ol_flags & PKT_TX_IPV4)
> -		return rte_ipv4_phdr_cksum(l3_hdr, ol_flags);
> -	else /* assume ethertype =3D=3D RTE_ETHER_TYPE_IPV6 */
> -		return rte_ipv6_phdr_cksum(l3_hdr, ol_flags);
> -}
> -
>  static void virtio_tx_offload(struct rte_mbuf *m)
>  {
> +	struct rte_net_hdr_lens hdr_lens;
> +	struct rte_ipv4_hdr *ipv4_hdr;
> +	struct rte_tcp_hdr *tcp_hdr;
> +	uint32_t ptype;
>  	void *l3_hdr;
> -	struct rte_ipv4_hdr *ipv4_hdr =3D NULL;
> -	struct rte_tcp_hdr *tcp_hdr =3D NULL;
> -	struct rte_ether_hdr *eth_hdr =3D
> -		rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
>=20
> -	l3_hdr =3D (char *)eth_hdr + m->l2_len;
> +	ptype =3D rte_net_get_ptype(m, &hdr_lens, RTE_PTYPE_ALL_MASK);
> +	m->l2_len =3D hdr_lens.l2_len;
> +	m->l3_len =3D hdr_lens.l3_len;
> +	m->l4_len =3D hdr_lens.l4_len;
>=20
> -	if (m->ol_flags & PKT_TX_IPV4) {
> +	l3_hdr =3D rte_pktmbuf_mtod_offset(m, void *, m->l2_len);
> +	tcp_hdr =3D rte_pktmbuf_mtod_offset(m, struct rte_tcp_hdr *,
> +		m->l2_len + m->l3_len);
> +
> +	m->ol_flags |=3D PKT_TX_TCP_SEG;
> +	if ((ptype & RTE_PTYPE_L3_MASK) =3D=3D RTE_PTYPE_L3_IPV4) {
> +		m->ol_flags |=3D PKT_TX_IPV4;
> +		m->ol_flags |=3D PKT_TX_IP_CKSUM;
>  		ipv4_hdr =3D l3_hdr;
>  		ipv4_hdr->hdr_checksum =3D 0;
> -		m->ol_flags |=3D PKT_TX_IP_CKSUM;
> +		tcp_hdr->cksum =3D rte_ipv4_phdr_cksum(l3_hdr, m-
> >ol_flags);
> +	} else { /* assume ethertype =3D=3D RTE_ETHER_TYPE_IPV6 */
> +		m->ol_flags |=3D PKT_TX_IPV6;
> +		tcp_hdr->cksum =3D rte_ipv6_phdr_cksum(l3_hdr, m-
> >ol_flags);
>  	}
> -
> -	tcp_hdr =3D (struct rte_tcp_hdr *)((char *)l3_hdr + m->l3_len);
> -	tcp_hdr->cksum =3D get_psd_sum(l3_hdr, m->ol_flags);
>  }
>=20
>  static __rte_always_inline void
> @@ -1148,7 +1150,7 @@ virtio_tx_route(struct vhost_dev *vdev, struct
> rte_mbuf *m, uint16_t vlan_tag)
>  		m->vlan_tci =3D vlan_tag;
>  	}
>=20
> -	if (m->ol_flags & PKT_TX_TCP_SEG)
> +	if (m->ol_flags & PKT_RX_LRO)
>  		virtio_tx_offload(m);
>=20
>  	tx_q->m_table[tx_q->len++] =3D m;
> @@ -1633,7 +1635,7 @@ main(int argc, char *argv[])
>  	int ret, i;
>  	uint16_t portid;
>  	static pthread_t tid;
> -	uint64_t flags =3D 0;
> +	uint64_t flags =3D RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
>=20
>  	signal(SIGINT, sigint_handler);
>=20
> diff --git a/lib/vhost/rte_vhost.h b/lib/vhost/rte_vhost.h
> index d0a8ae31f2..8d875e9322 100644
> --- a/lib/vhost/rte_vhost.h
> +++ b/lib/vhost/rte_vhost.h
> @@ -36,6 +36,7 @@ extern "C" {
>  /* support only linear buffers (no chained mbufs) */
>  #define RTE_VHOST_USER_LINEARBUF_SUPPORT	(1ULL << 6)
>  #define RTE_VHOST_USER_ASYNC_COPY	(1ULL << 7)
> +#define RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS	(1ULL << 8)
>=20
>  /* Features. */
>  #ifndef VIRTIO_NET_F_GUEST_ANNOUNCE
> diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
> index 0169d36481..5d0d728d52 100644
> --- a/lib/vhost/socket.c
> +++ b/lib/vhost/socket.c
> @@ -42,6 +42,7 @@ struct vhost_user_socket {
>  	bool extbuf;
>  	bool linearbuf;
>  	bool async_copy;
> +	bool net_compliant_ol_flags;
>=20
>  	/*
>  	 * The "supported_features" indicates the feature bits the
> @@ -224,7 +225,8 @@ vhost_user_add_connection(int fd, struct
> vhost_user_socket *vsocket)
>  	size =3D strnlen(vsocket->path, PATH_MAX);
>  	vhost_set_ifname(vid, vsocket->path, size);
>=20
> -	vhost_set_builtin_virtio_net(vid, vsocket->use_builtin_virtio_net);
> +	vhost_setup_virtio_net(vid, vsocket->use_builtin_virtio_net,
> +		vsocket->net_compliant_ol_flags);
>=20
>  	vhost_attach_vdpa_device(vid, vsocket->vdpa_dev);
>=20
> @@ -877,6 +879,7 @@ rte_vhost_driver_register(const char *path,
> uint64_t flags)
>  	vsocket->extbuf =3D flags & RTE_VHOST_USER_EXTBUF_SUPPORT;
>  	vsocket->linearbuf =3D flags &
> RTE_VHOST_USER_LINEARBUF_SUPPORT;
>  	vsocket->async_copy =3D flags & RTE_VHOST_USER_ASYNC_COPY;
> +	vsocket->net_compliant_ol_flags =3D flags &
> RTE_VHOST_USER_NET_COMPLIANT_OL_FLAGS;
>=20
>  	if (vsocket->async_copy &&
>  		(flags & (RTE_VHOST_USER_IOMMU_SUPPORT |
> diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
> index c9b6379f73..9abfc0bfe7 100644
> --- a/lib/vhost/vhost.c
> +++ b/lib/vhost/vhost.c
> @@ -752,7 +752,7 @@ vhost_set_ifname(int vid, const char *if_name,
> unsigned int if_len)
>  }
>=20
>  void
> -vhost_set_builtin_virtio_net(int vid, bool enable)
> +vhost_setup_virtio_net(int vid, bool enable, bool compliant_ol_flags)
>  {
>  	struct virtio_net *dev =3D get_device(vid);
>=20
> @@ -763,6 +763,10 @@ vhost_set_builtin_virtio_net(int vid, bool enable)
>  		dev->flags |=3D VIRTIO_DEV_BUILTIN_VIRTIO_NET;
>  	else
>  		dev->flags &=3D ~VIRTIO_DEV_BUILTIN_VIRTIO_NET;
> +	if (!compliant_ol_flags)
> +		dev->flags |=3D VIRTIO_DEV_LEGACY_OL_FLAGS;
> +	else
> +		dev->flags &=3D ~VIRTIO_DEV_LEGACY_OL_FLAGS;
>  }
>=20
>  void
> diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h
> index b303635645..8078ddff79 100644
> --- a/lib/vhost/vhost.h
> +++ b/lib/vhost/vhost.h
> @@ -27,15 +27,17 @@
>  #include "rte_vhost_async.h"
>=20
>  /* Used to indicate that the device is running on a data core */
> -#define VIRTIO_DEV_RUNNING 1
> +#define VIRTIO_DEV_RUNNING ((uint32_t)1 << 0)
>  /* Used to indicate that the device is ready to operate */
> -#define VIRTIO_DEV_READY 2
> +#define VIRTIO_DEV_READY ((uint32_t)1 << 1)
>  /* Used to indicate that the built-in vhost net device backend is enable=
d */
> -#define VIRTIO_DEV_BUILTIN_VIRTIO_NET 4
> +#define VIRTIO_DEV_BUILTIN_VIRTIO_NET ((uint32_t)1 << 2)
>  /* Used to indicate that the device has its own data path and configured=
 */
> -#define VIRTIO_DEV_VDPA_CONFIGURED 8
> +#define VIRTIO_DEV_VDPA_CONFIGURED ((uint32_t)1 << 3)
>  /* Used to indicate that the feature negotiation failed */
> -#define VIRTIO_DEV_FEATURES_FAILED 16
> +#define VIRTIO_DEV_FEATURES_FAILED ((uint32_t)1 << 4)
> +/* Used to indicate that the virtio_net tx code should fill TX ol_flags =
*/
> +#define VIRTIO_DEV_LEGACY_OL_FLAGS ((uint32_t)1 << 5)
>=20
>  /* Backend value set by guest. */
>  #define VIRTIO_DEV_STOPPED -1
> @@ -683,7 +685,7 @@ int alloc_vring_queue(struct virtio_net *dev,
> uint32_t vring_idx);
>  void vhost_attach_vdpa_device(int vid, struct rte_vdpa_device *dev);
>=20
>  void vhost_set_ifname(int, const char *if_name, unsigned int if_len);
> -void vhost_set_builtin_virtio_net(int vid, bool enable);
> +void vhost_setup_virtio_net(int vid, bool enable, bool legacy_ol_flags);
>  void vhost_enable_extbuf(int vid);
>  void vhost_enable_linearbuf(int vid);
>  int vhost_enable_guest_notification(struct virtio_net *dev,
> diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c
> index 1a34867f3c..8e36f4c340 100644
> --- a/lib/vhost/virtio_net.c
> +++ b/lib/vhost/virtio_net.c
> @@ -8,6 +8,7 @@
>=20
>  #include <rte_mbuf.h>
>  #include <rte_memcpy.h>
> +#include <rte_net.h>
>  #include <rte_ether.h>
>  #include <rte_ip.h>
>  #include <rte_vhost.h>
> @@ -2303,15 +2304,12 @@ parse_ethernet(struct rte_mbuf *m, uint16_t
> *l4_proto, void **l4_hdr)
>  }
>=20
>  static __rte_always_inline void
> -vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m)
> +vhost_dequeue_offload_legacy(struct virtio_net_hdr *hdr, struct
> rte_mbuf *m)
>  {
>  	uint16_t l4_proto =3D 0;
>  	void *l4_hdr =3D NULL;
>  	struct rte_tcp_hdr *tcp_hdr =3D NULL;
>=20
> -	if (hdr->flags =3D=3D 0 && hdr->gso_type =3D=3D
> VIRTIO_NET_HDR_GSO_NONE)
> -		return;
> -
>  	parse_ethernet(m, &l4_proto, &l4_hdr);
>  	if (hdr->flags =3D=3D VIRTIO_NET_HDR_F_NEEDS_CSUM) {
>  		if (hdr->csum_start =3D=3D (m->l2_len + m->l3_len)) {
> @@ -2356,6 +2354,94 @@ vhost_dequeue_offload(struct virtio_net_hdr
> *hdr, struct rte_mbuf *m)
>  	}
>  }
>=20
> +static __rte_always_inline void
> +vhost_dequeue_offload(struct virtio_net_hdr *hdr, struct rte_mbuf *m,
> +	bool legacy_ol_flags)
> +{
> +	struct rte_net_hdr_lens hdr_lens;
> +	int l4_supported =3D 0;
> +	uint32_t ptype;
> +
> +	if (hdr->flags =3D=3D 0 && hdr->gso_type =3D=3D
> VIRTIO_NET_HDR_GSO_NONE)
> +		return;
> +
> +	if (legacy_ol_flags) {
> +		vhost_dequeue_offload_legacy(hdr, m);
> +		return;
> +	}
> +
> +	m->ol_flags |=3D PKT_RX_IP_CKSUM_UNKNOWN;
> +
> +	ptype =3D rte_net_get_ptype(m, &hdr_lens, RTE_PTYPE_ALL_MASK);
> +	m->packet_type =3D ptype;
> +	if ((ptype & RTE_PTYPE_L4_MASK) =3D=3D RTE_PTYPE_L4_TCP ||
> +	    (ptype & RTE_PTYPE_L4_MASK) =3D=3D RTE_PTYPE_L4_UDP ||
> +	    (ptype & RTE_PTYPE_L4_MASK) =3D=3D RTE_PTYPE_L4_SCTP)
> +		l4_supported =3D 1;
> +
> +	/* According to Virtio 1.1 spec, the device only needs to look at
> +	 * VIRTIO_NET_HDR_F_NEEDS_CSUM in the packet transmission
> path.
> +	 * This differs from the processing incoming packets path where the
> +	 * driver could rely on VIRTIO_NET_HDR_F_DATA_VALID flag set by
> the
> +	 * device.
> +	 *
> +	 * 5.1.6.2.1 Driver Requirements: Packet Transmission
> +	 * The driver MUST NOT set the VIRTIO_NET_HDR_F_DATA_VALID
> and
> +	 * VIRTIO_NET_HDR_F_RSC_INFO bits in flags.
> +	 *
> +	 * 5.1.6.2.2 Device Requirements: Packet Transmission
> +	 * The device MUST ignore flag bits that it does not recognize.
> +	 */
> +	if (hdr->flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
> +		uint32_t hdrlen;
> +
> +		hdrlen =3D hdr_lens.l2_len + hdr_lens.l3_len + hdr_lens.l4_len;
> +		if (hdr->csum_start <=3D hdrlen && l4_supported !=3D 0) {
> +			m->ol_flags |=3D PKT_RX_L4_CKSUM_NONE;
> +		} else {
> +			/* Unknown proto or tunnel, do sw cksum. We can
> assume
> +			 * the cksum field is in the first segment since the
> +			 * buffers we provided to the host are large enough.
> +			 * In case of SCTP, this will be wrong since it's a CRC
> +			 * but there's nothing we can do.
> +			 */
> +			uint16_t csum =3D 0, off;
> +
> +			if (rte_raw_cksum_mbuf(m, hdr->csum_start,
> +					rte_pktmbuf_pkt_len(m) - hdr-
> >csum_start, &csum) < 0)
> +				return;
> +			if (likely(csum !=3D 0xffff))
> +				csum =3D ~csum;
> +			off =3D hdr->csum_offset + hdr->csum_start;
> +			if (rte_pktmbuf_data_len(m) >=3D off + 1)
> +				*rte_pktmbuf_mtod_offset(m, uint16_t *,
> off) =3D csum;
> +		}
> +	}
> +
> +	if (hdr->gso_type !=3D VIRTIO_NET_HDR_GSO_NONE) {
> +		if (hdr->gso_size =3D=3D 0)
> +			return;
> +
> +		switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
> +		case VIRTIO_NET_HDR_GSO_TCPV4:
> +		case VIRTIO_NET_HDR_GSO_TCPV6:
> +			if ((ptype & RTE_PTYPE_L4_MASK) !=3D
> RTE_PTYPE_L4_TCP)
> +				break;
> +			m->ol_flags |=3D PKT_RX_LRO |
> PKT_RX_L4_CKSUM_NONE;
> +			m->tso_segsz =3D hdr->gso_size;
> +			break;
> +		case VIRTIO_NET_HDR_GSO_UDP:
> +			if ((ptype & RTE_PTYPE_L4_MASK) !=3D
> RTE_PTYPE_L4_UDP)
> +				break;
> +			m->ol_flags |=3D PKT_RX_LRO |
> PKT_RX_L4_CKSUM_NONE;
> +			m->tso_segsz =3D hdr->gso_size;
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +}
> +
>  static __rte_noinline void
>  copy_vnet_hdr_from_desc(struct virtio_net_hdr *hdr,
>  		struct buf_vector *buf_vec)
> @@ -2380,7 +2466,8 @@ copy_vnet_hdr_from_desc(struct virtio_net_hdr
> *hdr,
>  static __rte_always_inline int
>  copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
>  		  struct buf_vector *buf_vec, uint16_t nr_vec,
> -		  struct rte_mbuf *m, struct rte_mempool *mbuf_pool)
> +		  struct rte_mbuf *m, struct rte_mempool *mbuf_pool,
> +		  bool legacy_ol_flags)
>  {
>  	uint32_t buf_avail, buf_offset;
>  	uint64_t buf_addr, buf_len;
> @@ -2513,7 +2600,7 @@ copy_desc_to_mbuf(struct virtio_net *dev,
> struct vhost_virtqueue *vq,
>  	m->pkt_len    +=3D mbuf_offset;
>=20
>  	if (hdr)
> -		vhost_dequeue_offload(hdr, m);
> +		vhost_dequeue_offload(hdr, m, legacy_ol_flags);
>=20
>  out:
>=20
> @@ -2606,9 +2693,11 @@ virtio_dev_pktmbuf_alloc(struct virtio_net
> *dev, struct rte_mempool *mp,
>  	return pkt;
>  }
>=20
> -static __rte_noinline uint16_t
> +__rte_always_inline
> +static uint16_t
>  virtio_dev_tx_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
> -	struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t
> count)
> +	struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t
> count,
> +	bool legacy_ol_flags)
>  {
>  	uint16_t i;
>  	uint16_t free_entries;
> @@ -2668,7 +2757,7 @@ virtio_dev_tx_split(struct virtio_net *dev, struct
> vhost_virtqueue *vq,
>  		}
>=20
>  		err =3D copy_desc_to_mbuf(dev, vq, buf_vec, nr_vec, pkts[i],
> -				mbuf_pool);
> +				mbuf_pool, legacy_ol_flags);
>  		if (unlikely(err)) {
>  			rte_pktmbuf_free(pkts[i]);
>  			if (!allocerr_warned) {
> @@ -2696,6 +2785,24 @@ virtio_dev_tx_split(struct virtio_net *dev,
> struct vhost_virtqueue *vq,
>  	return (i - dropped);
>  }
>=20
> +__rte_noinline
> +static uint16_t
> +virtio_dev_tx_split_legacy(struct virtio_net *dev,
> +	struct vhost_virtqueue *vq, struct rte_mempool *mbuf_pool,
> +	struct rte_mbuf **pkts, uint16_t count)
> +{
> +	return virtio_dev_tx_split(dev, vq, mbuf_pool, pkts, count, true);
> +}
> +
> +__rte_noinline
> +static uint16_t
> +virtio_dev_tx_split_compliant(struct virtio_net *dev,
> +	struct vhost_virtqueue *vq, struct rte_mempool *mbuf_pool,
> +	struct rte_mbuf **pkts, uint16_t count)
> +{
> +	return virtio_dev_tx_split(dev, vq, mbuf_pool, pkts, count, false);
> +}
> +
>  static __rte_always_inline int
>  vhost_reserve_avail_batch_packed(struct virtio_net *dev,
>  				 struct vhost_virtqueue *vq,
> @@ -2770,7 +2877,8 @@ vhost_reserve_avail_batch_packed(struct
> virtio_net *dev,
>  static __rte_always_inline int
>  virtio_dev_tx_batch_packed(struct virtio_net *dev,
>  			   struct vhost_virtqueue *vq,
> -			   struct rte_mbuf **pkts)
> +			   struct rte_mbuf **pkts,
> +			   bool legacy_ol_flags)
>  {
>  	uint16_t avail_idx =3D vq->last_avail_idx;
>  	uint32_t buf_offset =3D sizeof(struct virtio_net_hdr_mrg_rxbuf);
> @@ -2794,7 +2902,7 @@ virtio_dev_tx_batch_packed(struct virtio_net
> *dev,
>  	if (virtio_net_with_host_offload(dev)) {
>  		vhost_for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) {
>  			hdr =3D (struct virtio_net_hdr *)(desc_addrs[i]);
> -			vhost_dequeue_offload(hdr, pkts[i]);
> +			vhost_dequeue_offload(hdr, pkts[i], legacy_ol_flags);
>  		}
>  	}
>=20
> @@ -2815,7 +2923,8 @@ vhost_dequeue_single_packed(struct virtio_net
> *dev,
>  			    struct rte_mempool *mbuf_pool,
>  			    struct rte_mbuf *pkts,
>  			    uint16_t *buf_id,
> -			    uint16_t *desc_count)
> +			    uint16_t *desc_count,
> +			    bool legacy_ol_flags)
>  {
>  	struct buf_vector buf_vec[BUF_VECTOR_MAX];
>  	uint32_t buf_len;
> @@ -2841,7 +2950,7 @@ vhost_dequeue_single_packed(struct virtio_net
> *dev,
>  	}
>=20
>  	err =3D copy_desc_to_mbuf(dev, vq, buf_vec, nr_vec, pkts,
> -				mbuf_pool);
> +				mbuf_pool, legacy_ol_flags);
>  	if (unlikely(err)) {
>  		if (!allocerr_warned) {
>  			VHOST_LOG_DATA(ERR,
> @@ -2859,14 +2968,15 @@ static __rte_always_inline int
>  virtio_dev_tx_single_packed(struct virtio_net *dev,
>  			    struct vhost_virtqueue *vq,
>  			    struct rte_mempool *mbuf_pool,
> -			    struct rte_mbuf *pkts)
> +			    struct rte_mbuf *pkts,
> +			    bool legacy_ol_flags)
>  {
>=20
>  	uint16_t buf_id, desc_count =3D 0;
>  	int ret;
>=20
>  	ret =3D vhost_dequeue_single_packed(dev, vq, mbuf_pool, pkts,
> &buf_id,
> -					&desc_count);
> +					&desc_count, legacy_ol_flags);
>=20
>  	if (likely(desc_count > 0)) {
>  		if (virtio_net_is_inorder(dev))
> @@ -2882,12 +2992,14 @@ virtio_dev_tx_single_packed(struct virtio_net
> *dev,
>  	return ret;
>  }
>=20
> -static __rte_noinline uint16_t
> +__rte_always_inline
> +static uint16_t
>  virtio_dev_tx_packed(struct virtio_net *dev,
>  		     struct vhost_virtqueue *__rte_restrict vq,
>  		     struct rte_mempool *mbuf_pool,
>  		     struct rte_mbuf **__rte_restrict pkts,
> -		     uint32_t count)
> +		     uint32_t count,
> +		     bool legacy_ol_flags)
>  {
>  	uint32_t pkt_idx =3D 0;
>=20
> @@ -2899,14 +3011,16 @@ virtio_dev_tx_packed(struct virtio_net *dev,
>=20
>  		if (count - pkt_idx >=3D PACKED_BATCH_SIZE) {
>  			if (!virtio_dev_tx_batch_packed(dev, vq,
> -							&pkts[pkt_idx])) {
> +							&pkts[pkt_idx],
> +							legacy_ol_flags)) {
>  				pkt_idx +=3D PACKED_BATCH_SIZE;
>  				continue;
>  			}
>  		}
>=20
>  		if (virtio_dev_tx_single_packed(dev, vq, mbuf_pool,
> -						pkts[pkt_idx]))
> +						pkts[pkt_idx],
> +						legacy_ol_flags))
>  			break;
>  		pkt_idx++;
>  	} while (pkt_idx < count);
> @@ -2924,6 +3038,24 @@ virtio_dev_tx_packed(struct virtio_net *dev,
>  	return pkt_idx;
>  }
>=20
> +__rte_noinline
> +static uint16_t
> +virtio_dev_tx_packed_legacy(struct virtio_net *dev,
> +	struct vhost_virtqueue *__rte_restrict vq, struct rte_mempool
> *mbuf_pool,
> +	struct rte_mbuf **__rte_restrict pkts, uint32_t count)
> +{
> +	return virtio_dev_tx_packed(dev, vq, mbuf_pool, pkts, count, true);
> +}
> +
> +__rte_noinline
> +static uint16_t
> +virtio_dev_tx_packed_compliant(struct virtio_net *dev,
> +	struct vhost_virtqueue *__rte_restrict vq, struct rte_mempool
> *mbuf_pool,
> +	struct rte_mbuf **__rte_restrict pkts, uint32_t count)
> +{
> +	return virtio_dev_tx_packed(dev, vq, mbuf_pool, pkts, count, false);
> +}
> +
>  uint16_t
>  rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
>  	struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t
> count)
> @@ -2999,10 +3131,17 @@ rte_vhost_dequeue_burst(int vid, uint16_t
> queue_id,
>  		count -=3D 1;
>  	}
>=20
> -	if (vq_is_packed(dev))
> -		count =3D virtio_dev_tx_packed(dev, vq, mbuf_pool, pkts,
> count);
> -	else
> -		count =3D virtio_dev_tx_split(dev, vq, mbuf_pool, pkts, count);
> +	if (vq_is_packed(dev)) {
> +		if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS)
> +			count =3D virtio_dev_tx_packed_legacy(dev, vq,
> mbuf_pool, pkts, count);
> +		else
> +			count =3D virtio_dev_tx_packed_compliant(dev, vq,
> mbuf_pool, pkts, count);
> +	} else {
> +		if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS)
> +			count =3D virtio_dev_tx_split_legacy(dev, vq,
> mbuf_pool, pkts, count);
> +		else
> +			count =3D virtio_dev_tx_split_compliant(dev, vq,
> mbuf_pool, pkts, count);
> +	}
>=20
>  out:
>  	if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM))
> --
> 2.23.0