diff options
Diffstat (limited to 'drivers/net/virtio_net.c')
-rw-r--r-- | drivers/net/virtio_net.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 9c82a39497e5..23eb282dc61f 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) | |||
616 | static bool virtnet_send_command(struct virtnet_info *vi, u8 class, u8 cmd, | 616 | static 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; |
@@ -749,7 +753,7 @@ static void virnet_vlan_rx_add_vid(struct net_device *dev, u16 vid) | |||
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)) |
@@ -761,7 +765,7 @@ static void virnet_vlan_rx_kill_vid(struct net_device *dev, u16 vid) | |||
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)) |