Thread (85 messages) 85 messages, 6 authors, 2016-03-14

Re: [PATCH v2 4/7] vhost: do not use rte_memcpy for virtio_hdr copy

From: Xie, Huawei <hidden>
Date: 2016-03-07 05:24:55

On 3/7/2016 12:20 PM, Stephen Hemminger wrote:
On Thu, 18 Feb 2016 21:49:09 +0800
Yuanhan Liu [off-list ref] wrote:
quoted
+static inline void
+copy_virtio_net_hdr(struct vhost_virtqueue *vq, uint64_t desc_addr,
+		    struct virtio_net_hdr_mrg_rxbuf hdr)
+{
+	if (vq->vhost_hlen == sizeof(struct virtio_net_hdr_mrg_rxbuf)) {
+		*(struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr = hdr;
+	} else {
+		*(struct virtio_net_hdr *)(uintptr_t)desc_addr = hdr.hdr;
+	}
+}
+
Don't use {} around single statements.
There are other cs issues, like
     used_idx = vq->last_used_idx & (vq->size -1);
                                               ^ space needed
Please run checkpatch against your patch.
Since you are doing all this casting, why not just use regular old memcpy
which will be inlined by Gcc  into same instructions anyway.
And since are always casting the desc_addr, why not pass a type that
doesn't need the additional cast (like void *)
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help