diff options
author | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-06-16 20:24:53 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-06-16 20:24:53 -0400 |
commit | 492b057c426e4aa747484958e18e9da29003985d (patch) | |
tree | 34e08c24618688d8bcc190523028b5f94cce0c0b /drivers/net/virtio_net.c | |
parent | 313485175da221c388f6a8ecf4c30062ba9bea17 (diff) | |
parent | 300df7dc89cc276377fc020704e34875d5c473b6 (diff) |
Merge commit 'origin/master' into next
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r-- | drivers/net/virtio_net.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 7fa620ddeb21..52198f6797a4 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
@@ -283,10 +283,11 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi) | |||
283 | for (;;) { | 283 | for (;;) { |
284 | struct virtio_net_hdr *hdr; | 284 | struct virtio_net_hdr *hdr; |
285 | 285 | ||
286 | skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN); | 286 | skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN); |
287 | if (unlikely(!skb)) | 287 | if (unlikely(!skb)) |
288 | break; | 288 | break; |
289 | 289 | ||
290 | skb_reserve(skb, NET_IP_ALIGN); | ||
290 | skb_put(skb, MAX_PACKET_LEN); | 291 | skb_put(skb, MAX_PACKET_LEN); |
291 | 292 | ||
292 | hdr = skb_vnet_hdr(skb); | 293 | hdr = skb_vnet_hdr(skb); |
@@ -470,7 +471,7 @@ static int xmit_skb(struct virtnet_info *vi, struct sk_buff *skb) | |||
470 | } | 471 | } |
471 | 472 | ||
472 | if (skb_is_gso(skb)) { | 473 | if (skb_is_gso(skb)) { |
473 | hdr->hdr_len = skb_transport_header(skb) - skb->data; | 474 | hdr->hdr_len = skb_headlen(skb); |
474 | hdr->gso_size = skb_shinfo(skb)->gso_size; | 475 | hdr->gso_size = skb_shinfo(skb)->gso_size; |
475 | if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) | 476 | if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) |
476 | hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4; | 477 | hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4; |
@@ -622,12 +623,9 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, | |||
622 | unsigned int tmp; | 623 | unsigned int tmp; |
623 | int i; | 624 | int i; |
624 | 625 | ||
625 | if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) { | 626 | /* Caller should know better */ |
626 | BUG(); /* Caller should know better */ | 627 | BUG_ON(!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ) || |
627 | return false; | 628 | (out + in > VIRTNET_SEND_COMMAND_SG_MAX)); |
628 | } | ||
629 | |||
630 | BUG_ON(out + in > VIRTNET_SEND_COMMAND_SG_MAX); | ||
631 | 629 | ||
632 | out++; /* Add header */ | 630 | out++; /* Add header */ |
633 | in++; /* Add return status */ | 631 | in++; /* Add return status */ |
@@ -642,8 +640,7 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, | |||
642 | sg_set_buf(&sg[i + 1], sg_virt(s), s->length); | 640 | sg_set_buf(&sg[i + 1], sg_virt(s), s->length); |
643 | sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); | 641 | sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); |
644 | 642 | ||
645 | if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0) | 643 | BUG_ON(vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi)); |
646 | BUG(); | ||
647 | 644 | ||
648 | vi->cvq->vq_ops->kick(vi->cvq); | 645 | vi->cvq->vq_ops->kick(vi->cvq); |
649 | 646 | ||
@@ -684,6 +681,7 @@ static void virtnet_set_rx_mode(struct net_device *dev) | |||
684 | u8 promisc, allmulti; | 681 | u8 promisc, allmulti; |
685 | struct virtio_net_ctrl_mac *mac_data; | 682 | struct virtio_net_ctrl_mac *mac_data; |
686 | struct dev_addr_list *addr; | 683 | struct dev_addr_list *addr; |
684 | struct netdev_hw_addr *ha; | ||
687 | void *buf; | 685 | void *buf; |
688 | int i; | 686 | int i; |
689 | 687 | ||
@@ -722,9 +720,9 @@ static void virtnet_set_rx_mode(struct net_device *dev) | |||
722 | 720 | ||
723 | /* Store the unicast list and count in the front of the buffer */ | 721 | /* Store the unicast list and count in the front of the buffer */ |
724 | mac_data->entries = dev->uc_count; | 722 | mac_data->entries = dev->uc_count; |
725 | addr = dev->uc_list; | 723 | i = 0; |
726 | for (i = 0; i < dev->uc_count; i++, addr = addr->next) | 724 | list_for_each_entry(ha, &dev->uc_list, list) |
727 | memcpy(&mac_data->macs[i][0], addr->da_addr, ETH_ALEN); | 725 | memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN); |
728 | 726 | ||
729 | sg_set_buf(&sg[0], mac_data, | 727 | sg_set_buf(&sg[0], mac_data, |
730 | sizeof(mac_data->entries) + (dev->uc_count * ETH_ALEN)); | 728 | sizeof(mac_data->entries) + (dev->uc_count * ETH_ALEN)); |