[dpdk-dev] [PATCH v2 3/5] vhost: do not inline unlikely fragmented buffers code

Maxime Coquelin maxime.coquelin at redhat.com
Fri May 24 15:50:21 CEST 2019



On 5/20/19 7:51 AM, Tiwei Bie wrote:
> On Fri, May 17, 2019 at 05:06:11PM +0200, Maxime Coquelin wrote:
> [...]
>>   
>> +static void
>> +copy_vnet_hdr_from_desc(struct virtio_net_hdr *hdr,
>> +		struct buf_vector *buf_vec)
>> +{
>> +	uint64_t len;
>> +	uint64_t remain = sizeof(struct virtio_net_hdr);
>> +	uint64_t src;
>> +	uint64_t dst = (uint64_t)(uintptr_t)&hdr;
> 
> typo: s/&hdr/hdr/

Nice catch! It wasn't spotted at build time due to the cast.

>> +
>> +	/*
>> +	 * No luck, the virtio-net header doesn't fit
>> +	 * in a contiguous virtual area.
>> +	 */
>> +	while (remain) {
>> +		len = RTE_MIN(remain, buf_vec->buf_len);
>> +		src = buf_vec->buf_addr;
>> +		rte_memcpy((void *)(uintptr_t)dst,
>> +				(void *)(uintptr_t)src, len);
>> +
>> +		remain -= len;
>> +		dst += len;
>> +		buf_vec++;
>> +	}
>> +}
>> +
>>   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,
>> @@ -1094,28 +1126,7 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
>>   
>>   	if (virtio_net_with_host_offload(dev)) {
>>   		if (unlikely(buf_len < sizeof(struct virtio_net_hdr))) {
>> -			uint64_t len;
>> -			uint64_t remain = sizeof(struct virtio_net_hdr);
>> -			uint64_t src;
>> -			uint64_t dst = (uint64_t)(uintptr_t)&tmp_hdr;
>> -			uint16_t hdr_vec_idx = 0;
>> -
>> -			/*
>> -			 * No luck, the virtio-net header doesn't fit
>> -			 * in a contiguous virtual area.
>> -			 */
> 
> It's better to not move above comments.

Right, I will revert it back here.

> 
> For the rest,
> Reviewed-by: Tiwei Bie <tiwei.bie at intel.com>


Thanks,
Maxime

> 
>> -			while (remain) {
>> -				len = RTE_MIN(remain,
>> -					buf_vec[hdr_vec_idx].buf_len);
>> -				src = buf_vec[hdr_vec_idx].buf_addr;
>> -				rte_memcpy((void *)(uintptr_t)dst,
>> -						   (void *)(uintptr_t)src, len);
>> -
>> -				remain -= len;
>> -				dst += len;
>> -				hdr_vec_idx++;
>> -			}
>> -
>> +			copy_vnet_hdr_from_desc(&tmp_hdr, buf_vec);
>>   			hdr = &tmp_hdr;
>>   		} else {
>>   			hdr = (struct virtio_net_hdr *)((uintptr_t)buf_addr);
>> -- 
>> 2.21.0
>>


More information about the dev mailing list