[RFC,25/27] vhost: add support for VDUSE IOTLB update event

Message ID 20230331154259.1447831-26-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series Add VDUSE support to Vhost library |

Commit Message

Maxime Coquelin March 31, 2023, 3:42 p.m. UTC
  This patch adds support for VDUSE_UPDATE_IOTLB event
handling, which consists in invaliding IOTLB entries for
the range specified in the request.

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/vhost/vduse.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Chenbo Xia May 9, 2023, 5:35 a.m. UTC | #1
Hi Maxime,

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Friday, March 31, 2023 11:43 PM
> To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo
> <chenbo.xia@intel.com>; mkp@redhat.com; fbl@redhat.com;
> jasowang@redhat.com; Liang, Cunming <cunming.liang@intel.com>; Xie, Yongji
> <xieyongji@bytedance.com>; echaudro@redhat.com; eperezma@redhat.com;
> amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [RFC 25/27] vhost: add support for VDUSE IOTLB update event
> 
> This patch adds support for VDUSE_UPDATE_IOTLB event
> handling, which consists in invaliding IOTLB entries for
> the range specified in the request.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  lib/vhost/vduse.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
> index 7d59a5f709..b5b9fa2eb1 100644
> --- a/lib/vhost/vduse.c
> +++ b/lib/vhost/vduse.c
> @@ -169,6 +169,12 @@ vduse_events_handler(int fd, void *arg, int *remove
> __rte_unused)
>  		dev->status = req.s.status;
>  		resp.result = VDUSE_REQ_RESULT_OK;
>  		break;
> +	case VDUSE_UPDATE_IOTLB:
> +		VHOST_LOG_CONFIG(dev->ifname, INFO, "\tIOVA range: %" PRIx64 "
> - %" PRIx64 "\n",
> +				(uint64_t)req.iova.start, (uint64_t)req.iova.last);
> +		vhost_user_iotlb_cache_remove(dev, req.iova.start,
> +				req.iova.last - req.iova.start + 1);
> +		break;

We don't need to set the response result here?

Thanks,
Chenbo

>  	default:
>  		resp.result = VDUSE_REQ_RESULT_FAILED;
>  		break;
> --
> 2.39.2
  
Maxime Coquelin May 25, 2023, 11:43 a.m. UTC | #2
On 5/9/23 07:35, Xia, Chenbo wrote:
> Hi Maxime,
> 
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Friday, March 31, 2023 11:43 PM
>> To: dev@dpdk.org; david.marchand@redhat.com; Xia, Chenbo
>> <chenbo.xia@intel.com>; mkp@redhat.com; fbl@redhat.com;
>> jasowang@redhat.com; Liang, Cunming <cunming.liang@intel.com>; Xie, Yongji
>> <xieyongji@bytedance.com>; echaudro@redhat.com; eperezma@redhat.com;
>> amorenoz@redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Subject: [RFC 25/27] vhost: add support for VDUSE IOTLB update event
>>
>> This patch adds support for VDUSE_UPDATE_IOTLB event
>> handling, which consists in invaliding IOTLB entries for
>> the range specified in the request.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> ---
>>   lib/vhost/vduse.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
>> index 7d59a5f709..b5b9fa2eb1 100644
>> --- a/lib/vhost/vduse.c
>> +++ b/lib/vhost/vduse.c
>> @@ -169,6 +169,12 @@ vduse_events_handler(int fd, void *arg, int *remove
>> __rte_unused)
>>   		dev->status = req.s.status;
>>   		resp.result = VDUSE_REQ_RESULT_OK;
>>   		break;
>> +	case VDUSE_UPDATE_IOTLB:
>> +		VHOST_LOG_CONFIG(dev->ifname, INFO, "\tIOVA range: %" PRIx64 "
>> - %" PRIx64 "\n",
>> +				(uint64_t)req.iova.start, (uint64_t)req.iova.last);
>> +		vhost_user_iotlb_cache_remove(dev, req.iova.start,
>> +				req.iova.last - req.iova.start + 1);
>> +		break;
> 
> We don't need to set the response result here?

Good catch! We indeed need to send the reply for this message.
I'm fixing it now.

Thanks,
Maxime

> Thanks,
> Chenbo
> 
>>   	default:
>>   		resp.result = VDUSE_REQ_RESULT_FAILED;
>>   		break;
>> --
>> 2.39.2
>
  

Patch

diff --git a/lib/vhost/vduse.c b/lib/vhost/vduse.c
index 7d59a5f709..b5b9fa2eb1 100644
--- a/lib/vhost/vduse.c
+++ b/lib/vhost/vduse.c
@@ -169,6 +169,12 @@  vduse_events_handler(int fd, void *arg, int *remove __rte_unused)
 		dev->status = req.s.status;
 		resp.result = VDUSE_REQ_RESULT_OK;
 		break;
+	case VDUSE_UPDATE_IOTLB:
+		VHOST_LOG_CONFIG(dev->ifname, INFO, "\tIOVA range: %" PRIx64 " - %" PRIx64 "\n",
+				(uint64_t)req.iova.start, (uint64_t)req.iova.last);
+		vhost_user_iotlb_cache_remove(dev, req.iova.start,
+				req.iova.last - req.iova.start + 1);
+		break;
 	default:
 		resp.result = VDUSE_REQ_RESULT_FAILED;
 		break;