[dpdk-dev] [PATCH v2 09/14] vhost: use linked-list for vDPA devices

Maxime Coquelin maxime.coquelin at redhat.com
Fri Jun 26 13:20:54 CEST 2020



On 6/26/20 1:03 PM, Adrian Moreno wrote:
> 
> On 6/24/20 2:26 PM, Maxime Coquelin wrote:
>> There is no more notion of device ID outside of vdpa.c.
>> We can now move from array to linked-list model for keeping
>> track of the vDPA devices.
>>
>> There is no point in using array here, as all vDPA API are
>> used from the control path, so no performance concerns.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
>> ---
>>  lib/librte_vhost/rte_vdpa.h |   1 +
>>  lib/librte_vhost/vdpa.c     | 134 +++++++++++++++++++-----------------
>>  2 files changed, 70 insertions(+), 65 deletions(-)
>>
>> diff --git a/lib/librte_vhost/rte_vdpa.h b/lib/librte_vhost/rte_vdpa.h
>> index da8ee33ab1..dbdc273702 100644
>> --- a/lib/librte_vhost/rte_vdpa.h
>> +++ b/lib/librte_vhost/rte_vdpa.h
>> @@ -105,6 +105,7 @@ struct rte_vdpa_dev_ops {
>>   * vdpa device structure includes device address and device operations.
>>   */
>>  struct rte_vdpa_device {
>> +	TAILQ_ENTRY(rte_vdpa_device) next;
>>  	/** Generic device information */
>>  	struct rte_device *device;
>>  	/** vdpa device operations */
>> diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c
>> index d7965b8854..dc2a138009 100644
>> --- a/lib/librte_vhost/vdpa.c
>> +++ b/lib/librte_vhost/vdpa.c
>> @@ -9,35 +9,54 @@
>>   */
>>  
>>  #include <stdbool.h>
>> +#include <sys/queue.h>
>>  
>>  #include <rte_class.h>
>>  #include <rte_malloc.h>
>> +#include <rte_spinlock.h>
>> +#include <rte_tailq.h>
>> +
> I'm curious why we need both sys/queue.h and rte_tailq.h

That's because I use TAILQ_FOREACH_SAFE, the TAILQ_FOREACH variant that
is safe against removal. This one is not part of sys/queue.h

>>  #include "rte_vdpa.h"
>>  #include "vhost.h"
>>  

Thanks,
Maxime



More information about the dev mailing list