Thread (9 messages) 9 messages, 3 authors, 2014-10-28

Re: [PATCH RFC 1/4] virtio_net: pass vi around

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: 2014-10-24 14:07:02
Also in: lkml, netdev

On Fri, Oct 24, 2014 at 10:02:15AM +0000, David Laight wrote:
From: Michael S. Tsirkin
 
quoted
Too many places poke at [rs]q->vq->vdev->priv just to get
the the vi structure.  Let's just pass the pointer around: seems
cleaner, and might even be faster.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/net/virtio_net.c | 36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 57cbc7d..36f3dfc 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
...
quoted
 static struct sk_buff *receive_big(struct net_device *dev,
+				   struct virtnet_info *vi,
Do you need to pass 'dev' here?
Looks like it is obtainable from vi->dev (as below).

	David
quoted
 				   struct receive_queue *rq,
 				   void *buf,
 				   unsigned int len)
 {
 	struct page *page = buf;
-	struct sk_buff *skb = page_to_skb(rq, page, 0, len, PAGE_SIZE);
+	struct sk_buff *skb = page_to_skb(vi, rq, page, 0, len, PAGE_SIZE);
...
quoted
-static void receive_buf(struct receive_queue *rq, void *buf, unsigned int len)
+static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
+			void *buf, unsigned int len)
 {
-	struct virtnet_info *vi = rq->vq->vdev->priv;
 	struct net_device *dev = vi->dev;
...
It's a matter of style, isn't it?
We have dev to hand, it seems cleaner to just pass it around.

-- 
MST
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help