aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/virtio_net.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-05-22 14:25:34 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-05-22 14:25:34 -0400
commite4b636366c00738b9609cda307014d71b1225b7f (patch)
tree760b67b3624eda62e943e48ce93635c30a5b47bf /drivers/net/virtio_net.c
parentb9ed7252d219c1c663944bf03846eabb515dbe75 (diff)
parent279e677faa775ad16e75c32e1bf4a37f8158bc61 (diff)
Merge branch 'master' into for-2.6.31
Conflicts: drivers/block/hd.c drivers/block/mg_disk.c Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r--drivers/net/virtio_net.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 9c82a39497e5..4d1d47953fc6 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -616,10 +616,11 @@ static int virtnet_open(struct net_device *dev)
616static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, 616static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
617 struct scatterlist *data, int out, int in) 617 struct scatterlist *data, int out, int in)
618{ 618{
619 struct scatterlist sg[VIRTNET_SEND_COMMAND_SG_MAX + 2]; 619 struct scatterlist *s, sg[VIRTNET_SEND_COMMAND_SG_MAX + 2];
620 struct virtio_net_ctrl_hdr ctrl; 620 struct virtio_net_ctrl_hdr ctrl;
621 virtio_net_ctrl_ack status = ~0; 621 virtio_net_ctrl_ack status = ~0;
622 unsigned int tmp; 622 unsigned int tmp;
623 int i;
623 624
624 if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) { 625 if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ)) {
625 BUG(); /* Caller should know better */ 626 BUG(); /* Caller should know better */
@@ -637,7 +638,8 @@ static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd,
637 sg_init_table(sg, out + in); 638 sg_init_table(sg, out + in);
638 639
639 sg_set_buf(&sg[0], &ctrl, sizeof(ctrl)); 640 sg_set_buf(&sg[0], &ctrl, sizeof(ctrl));
640 memcpy(&sg[1], data, sizeof(struct scatterlist) * (out + in - 2)); 641 for_each_sg(data, s, out + in - 2, i)
642 sg_set_buf(&sg[i + 1], sg_virt(s), s->length);
641 sg_set_buf(&sg[out + in - 1], &status, sizeof(status)); 643 sg_set_buf(&sg[out + in - 1], &status, sizeof(status));
642 644
643 if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0) 645 if (vi->cvq->vq_ops->add_buf(vi->cvq, sg, out, in, vi) != 0)
@@ -692,7 +694,7 @@ static void virtnet_set_rx_mode(struct net_device *dev)
692 promisc = ((dev->flags & IFF_PROMISC) != 0); 694 promisc = ((dev->flags & IFF_PROMISC) != 0);
693 allmulti = ((dev->flags & IFF_ALLMULTI) != 0); 695 allmulti = ((dev->flags & IFF_ALLMULTI) != 0);
694 696
695 sg_set_buf(sg, &promisc, sizeof(promisc)); 697 sg_init_one(sg, &promisc, sizeof(promisc));
696 698
697 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, 699 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX,
698 VIRTIO_NET_CTRL_RX_PROMISC, 700 VIRTIO_NET_CTRL_RX_PROMISC,
@@ -700,7 +702,7 @@ static void virtnet_set_rx_mode(struct net_device *dev)
700 dev_warn(&dev->dev, "Failed to %sable promisc mode.\n", 702 dev_warn(&dev->dev, "Failed to %sable promisc mode.\n",
701 promisc ? "en" : "dis"); 703 promisc ? "en" : "dis");
702 704
703 sg_set_buf(sg, &allmulti, sizeof(allmulti)); 705 sg_init_one(sg, &allmulti, sizeof(allmulti));
704 706
705 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX, 707 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_RX,
706 VIRTIO_NET_CTRL_RX_ALLMULTI, 708 VIRTIO_NET_CTRL_RX_ALLMULTI,
@@ -716,6 +718,8 @@ static void virtnet_set_rx_mode(struct net_device *dev)
716 return; 718 return;
717 } 719 }
718 720
721 sg_init_table(sg, 2);
722
719 /* Store the unicast list and count in the front of the buffer */ 723 /* Store the unicast list and count in the front of the buffer */
720 mac_data->entries = dev->uc_count; 724 mac_data->entries = dev->uc_count;
721 addr = dev->uc_list; 725 addr = dev->uc_list;
@@ -744,24 +748,24 @@ static void virtnet_set_rx_mode(struct net_device *dev)
744 kfree(buf); 748 kfree(buf);
745} 749}
746 750
747static void virnet_vlan_rx_add_vid(struct net_device *dev, u16 vid) 751static void virtnet_vlan_rx_add_vid(struct net_device *dev, u16 vid)
748{ 752{
749 struct virtnet_info *vi = netdev_priv(dev); 753 struct virtnet_info *vi = netdev_priv(dev);
750 struct scatterlist sg; 754 struct scatterlist sg;
751 755
752 sg_set_buf(&sg, &vid, sizeof(vid)); 756 sg_init_one(&sg, &vid, sizeof(vid));
753 757
754 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, 758 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
755 VIRTIO_NET_CTRL_VLAN_ADD, &sg, 1, 0)) 759 VIRTIO_NET_CTRL_VLAN_ADD, &sg, 1, 0))
756 dev_warn(&dev->dev, "Failed to add VLAN ID %d.\n", vid); 760 dev_warn(&dev->dev, "Failed to add VLAN ID %d.\n", vid);
757} 761}
758 762
759static void virnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid) 763static void virtnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid)
760{ 764{
761 struct virtnet_info *vi = netdev_priv(dev); 765 struct virtnet_info *vi = netdev_priv(dev);
762 struct scatterlist sg; 766 struct scatterlist sg;
763 767
764 sg_set_buf(&sg, &vid, sizeof(vid)); 768 sg_init_one(&sg, &vid, sizeof(vid));
765 769
766 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN, 770 if (!virtnet_send_command(vi, VIRTIO_NET_CTRL_VLAN,
767 VIRTIO_NET_CTRL_VLAN_DEL, &sg, 1, 0)) 771 VIRTIO_NET_CTRL_VLAN_DEL, &sg, 1, 0))
@@ -794,8 +798,8 @@ static const struct net_device_ops virtnet_netdev = {
794 .ndo_set_mac_address = virtnet_set_mac_address, 798 .ndo_set_mac_address = virtnet_set_mac_address,
795 .ndo_set_rx_mode = virtnet_set_rx_mode, 799 .ndo_set_rx_mode = virtnet_set_rx_mode,
796 .ndo_change_mtu = virtnet_change_mtu, 800 .ndo_change_mtu = virtnet_change_mtu,
797 .ndo_vlan_rx_add_vid = virnet_vlan_rx_add_vid, 801 .ndo_vlan_rx_add_vid = virtnet_vlan_rx_add_vid,
798 .ndo_vlan_rx_kill_vid = virnet_vlan_rx_kill_vid, 802 .ndo_vlan_rx_kill_vid = virtnet_vlan_rx_kill_vid,
799#ifdef CONFIG_NET_POLL_CONTROLLER 803#ifdef CONFIG_NET_POLL_CONTROLLER
800 .ndo_poll_controller = virtnet_netpoll, 804 .ndo_poll_controller = virtnet_netpoll,
801#endif 805#endif