[dpdk-dev] [PATCH 2/4] net/vhost: setup vrings for DMA-accelerated datapath

Hu, Jiayu jiayu.hu at intel.com
Tue Mar 17 10:35:52 CET 2020


Hi Marvin,

> -----Original Message-----
> From: Liu, Yong <yong.liu at intel.com>
> Sent: Tuesday, March 17, 2020 2:30 PM
> To: Hu, Jiayu <jiayu.hu at intel.com>; dev at dpdk.org
> Cc: maxime.coquelin at redhat.com; Ye, Xiaolong <xiaolong.ye at intel.com>;
> Wang, Zhihong <zhihong.wang at intel.com>; Hu, Jiayu <jiayu.hu at intel.com>
> Subject: RE: [dpdk-dev] [PATCH 2/4] net/vhost: setup vrings for DMA-
> accelerated datapath
> 
> 
> 
> > +
> > +struct guest_page {
> > +	uint64_t guest_phys_addr;
> > +	uint64_t host_phys_addr;
> > +	uint64_t size;
> > +};
> > +
> > +struct dma_vring {
> > +	struct rte_vhost_vring  vr;
> > +
> > +	uint16_t last_avail_idx;
> > +	uint16_t last_used_idx;
> > +
> > +	/* the last used index that front end can consume */
> > +	uint16_t copy_done_used;
> > +
> > +	uint16_t signalled_used;
> > +	bool signalled_used_valid;
> > +
> > +	struct vring_used_elem *shadow_used_split;
> > +	uint16_t shadow_used_idx;
> > +
> > +	struct batch_copy_elem  *batch_copy_elems;
> > +	uint16_t batch_copy_nb_elems;
> > +
> > +	bool dma_enabled;
> > +	/**
> > +	 * DMA ID. Currently, we only support I/OAT,
> > +	 * so it's I/OAT rawdev ID.
> > +	 */
> > +	uint16_t dev_id;
> > +	/* DMA address */
> > +	struct rte_pci_addr dma_addr;
> > +	/**
> > +	 * the number of copy jobs that are submitted to the DMA
> > +	 * but may not be completed.
> > +	 */
> > +	uint64_t nr_inflight;
> > +	int nr_batching;
> 
> Look like nr_batching can't be negative value, please changed to uint16_t or
> uint32_t.

Thanks, will change it later.

> > diff --git a/drivers/net/vhost/virtio_net.h b/drivers/net/vhost/virtio_net.h
> > new file mode 100644
> > index 0000000..7f99f1d
> > --- /dev/null
> > +++ b/drivers/net/vhost/virtio_net.h
> > @@ -0,0 +1,168 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright(c) 2020 Intel Corporation
> > + */
> > +#ifndef _VIRTIO_NET_H_
> > +#define _VIRTIO_NET_H_
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#include <sys/types.h>
> > +#include <sys/stat.h>
> > +#include <unistd.h>
> > +
> > +#include "internal.h"
> > +
> > +static uint64_t
> > +get_blk_size(int fd)
> > +{
> > +	struct stat stat;
> > +	int ret;
> > +
> > +	ret = fstat(fd, &stat);
> > +	return ret == -1 ? (uint64_t)-1 : (uint64_t)stat.st_blksize;
> > +}
> > +
> > +static __rte_always_inline int
> > +add_one_guest_page(struct pmd_internal *dev, uint64_t
> guest_phys_addr,
> > +		   uint64_t host_phys_addr, uint64_t size)
> 
> Jiayu,
> We have same set of functions for gpa to hpa translation in vhost library. Can
> those functions be shared here?

Do you think it's necessary to provide a API for translating GPA to HPA?

> 
> Thanks,
> Marvin
> 


More information about the dev mailing list