[dpdk-dev] [PATCH v6 10/15] vhost: create descriptor mapping function
Maxime Coquelin
maxime.coquelin at redhat.com
Wed Jul 4 18:18:51 CEST 2018
On 07/04/2018 07:56 AM, Tiwei Bie wrote:
> On Mon, Jul 02, 2018 at 10:16:24AM +0200, Maxime Coquelin wrote:
>> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
>> ---
>> lib/librte_vhost/virtio_net.c | 61 ++++++++++++++++++++++++++-----------------
>> 1 file changed, 37 insertions(+), 24 deletions(-)
>>
>> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
>> index f0e2e6a1f..64664b7de 100644
>> --- a/lib/librte_vhost/virtio_net.c
>> +++ b/lib/librte_vhost/virtio_net.c
>> @@ -292,6 +292,37 @@ virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr)
>> }
>> }
>>
>> +static __rte_always_inline int
>> +map_one_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
>> + struct buf_vector *buf_vec, uint16_t *vec_idx,
>> + uint64_t desc_iova, uint64_t desc_len, uint8_t perm)
>> +{
>> + uint16_t vec_id = *vec_idx;
>> +
>> + while (desc_len) {
>> + uint64_t desc_addr;
>> + uint64_t desc_chunck_len = desc_len;
>> +
>> + desc_addr = vhost_iova_to_vva(dev, vq,
>> + desc_iova,
>> + &desc_chunck_len,
>> + perm);
>> + if (unlikely(!desc_addr))
>> + return -1;
>> +
>> + buf_vec[vec_id].buf_iova = desc_iova;
>> + buf_vec[vec_id].buf_addr = desc_addr;
>> + buf_vec[vec_id].buf_len = desc_chunck_len;
>> +
>> + desc_len -= desc_chunck_len;
>> + desc_iova += desc_chunck_len;
>> + vec_id++;
>
> FYI, a rebase on top of the latest "vhost: generalize
> buffer vectors" series is needed to make sure that
> access buf_vec[vec_id] won't cause overflow.
Right, this is fixed now that I rebased.
Thanks,
Maxime
>> + }
>> + *vec_idx = vec_id;
>> +
>> + return 0;
>> +}
>> +
> [...]
>
More information about the dev
mailing list