aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2008-02-04 23:49:56 -0500
committerRusty Russell <rusty@rustcorp.com.au>2008-02-04 07:49:57 -0500
commita586d4f6016f7139d8c26df0e6927131168d3b5b (patch)
tree1c47e1a6b6b8fb18baa42f32980f29c4ae9cbbdc /drivers/net
parentf35d9d8aae08940b7fdd1bb8110619da2ece6b28 (diff)
virtio: simplify config mechanism.
Previously we used a type/len pair within the config space, but this seems overkill. We now simply define a structure which represents the layout in the config space: the config space can now only be extended at the end. The main driver-visible changes: 1) We indicate what fields are present with an explicit feature bit. 2) Virtqueues are explicitly numbered, and not in the config space. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/virtio_net.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a60505c8f82a..4b8138312750 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -311,10 +311,8 @@ static int virtnet_close(struct net_device *dev)
311static int virtnet_probe(struct virtio_device *vdev) 311static int virtnet_probe(struct virtio_device *vdev)
312{ 312{
313 int err; 313 int err;
314 unsigned int len;
315 struct net_device *dev; 314 struct net_device *dev;
316 struct virtnet_info *vi; 315 struct virtnet_info *vi;
317 void *token;
318 316
319 /* Allocate ourselves a network device with room for our info */ 317 /* Allocate ourselves a network device with room for our info */
320 dev = alloc_etherdev(sizeof(struct virtnet_info)); 318 dev = alloc_etherdev(sizeof(struct virtnet_info));
@@ -330,25 +328,24 @@ static int virtnet_probe(struct virtio_device *vdev)
330 SET_NETDEV_DEV(dev, &vdev->dev); 328 SET_NETDEV_DEV(dev, &vdev->dev);
331 329
332 /* Do we support "hardware" checksums? */ 330 /* Do we support "hardware" checksums? */
333 token = vdev->config->find(vdev, VIRTIO_CONFIG_NET_F, &len); 331 if (vdev->config->feature(vdev, VIRTIO_NET_F_NO_CSUM)) {
334 if (virtio_use_bit(vdev, token, len, VIRTIO_NET_F_NO_CSUM)) {
335 /* This opens up the world of extra features. */ 332 /* This opens up the world of extra features. */
336 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST; 333 dev->features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
337 if (virtio_use_bit(vdev, token, len, VIRTIO_NET_F_TSO4)) 334 if (vdev->config->feature(vdev, VIRTIO_NET_F_TSO4))
338 dev->features |= NETIF_F_TSO; 335 dev->features |= NETIF_F_TSO;
339 if (virtio_use_bit(vdev, token, len, VIRTIO_NET_F_UFO)) 336 if (vdev->config->feature(vdev, VIRTIO_NET_F_UFO))
340 dev->features |= NETIF_F_UFO; 337 dev->features |= NETIF_F_UFO;
341 if (virtio_use_bit(vdev, token, len, VIRTIO_NET_F_TSO4_ECN)) 338 if (vdev->config->feature(vdev, VIRTIO_NET_F_TSO4_ECN))
342 dev->features |= NETIF_F_TSO_ECN; 339 dev->features |= NETIF_F_TSO_ECN;
343 if (virtio_use_bit(vdev, token, len, VIRTIO_NET_F_TSO6)) 340 if (vdev->config->feature(vdev, VIRTIO_NET_F_TSO6))
344 dev->features |= NETIF_F_TSO6; 341 dev->features |= NETIF_F_TSO6;
345 } 342 }
346 343
347 /* Configuration may specify what MAC to use. Otherwise random. */ 344 /* Configuration may specify what MAC to use. Otherwise random. */
348 token = vdev->config->find(vdev, VIRTIO_CONFIG_NET_MAC_F, &len); 345 if (vdev->config->feature(vdev, VIRTIO_NET_F_MAC)) {
349 if (token) { 346 vdev->config->get(vdev,
350 dev->addr_len = len; 347 offsetof(struct virtio_net_config, mac),
351 vdev->config->get(vdev, token, dev->dev_addr, len); 348 dev->dev_addr, dev->addr_len);
352 } else 349 } else
353 random_ether_addr(dev->dev_addr); 350 random_ether_addr(dev->dev_addr);
354 351
@@ -359,13 +356,13 @@ static int virtnet_probe(struct virtio_device *vdev)
359 vi->vdev = vdev; 356 vi->vdev = vdev;
360 357
361 /* We expect two virtqueues, receive then send. */ 358 /* We expect two virtqueues, receive then send. */
362 vi->rvq = vdev->config->find_vq(vdev, skb_recv_done); 359 vi->rvq = vdev->config->find_vq(vdev, 0, skb_recv_done);
363 if (IS_ERR(vi->rvq)) { 360 if (IS_ERR(vi->rvq)) {
364 err = PTR_ERR(vi->rvq); 361 err = PTR_ERR(vi->rvq);
365 goto free; 362 goto free;
366 } 363 }
367 364
368 vi->svq = vdev->config->find_vq(vdev, skb_xmit_done); 365 vi->svq = vdev->config->find_vq(vdev, 1, skb_xmit_done);
369 if (IS_ERR(vi->svq)) { 366 if (IS_ERR(vi->svq)) {
370 err = PTR_ERR(vi->svq); 367 err = PTR_ERR(vi->svq);
371 goto free_recv; 368 goto free_recv;