Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
[deliverable/linux.git] / drivers / net / virtio_net.c
index c68808336c8c4d84e90e03a8d0649592b72c1626..fe576e75a538ba20f320ae80101bc6377cf50107 100644 (file)
@@ -43,6 +43,7 @@ struct virtnet_info
        struct virtqueue *rvq, *svq;
        struct net_device *dev;
        struct napi_struct napi;
+       unsigned int status;
 
        /* The skb we couldn't send because buffers were full. */
        struct sk_buff *last_xmit_skb;
@@ -375,9 +376,9 @@ static void skb_recv_done(struct virtqueue *rvq)
 {
        struct virtnet_info *vi = rvq->vdev->priv;
        /* Schedule NAPI, Suppress further interrupts if successful. */
-       if (netif_rx_schedule_prep(&vi->napi)) {
+       if (napi_schedule_prep(&vi->napi)) {
                rvq->vq_ops->disable_cb(rvq);
-               __netif_rx_schedule(&vi->napi);
+               __napi_schedule(&vi->napi);
        }
 }
 
@@ -403,11 +404,11 @@ again:
 
        /* Out of packets? */
        if (received < budget) {
-               netif_rx_complete(napi);
+               napi_complete(napi);
                if (unlikely(!vi->rvq->vq_ops->enable_cb(vi->rvq))
                    && napi_schedule_prep(napi)) {
                        vi->rvq->vq_ops->disable_cb(vi->rvq);
-                       __netif_rx_schedule(napi);
+                       __napi_schedule(napi);
                        goto again;
                }
        }
@@ -581,9 +582,9 @@ static int virtnet_open(struct net_device *dev)
         * won't get another interrupt, so process any outstanding packets
         * now.  virtnet_poll wants re-enable the queue, so we disable here.
         * We synchronize against interrupts via NAPI_STATE_SCHED */
-       if (netif_rx_schedule_prep(&vi->napi)) {
+       if (napi_schedule_prep(&vi->napi)) {
                vi->rvq->vq_ops->disable_cb(vi->rvq);
-               __netif_rx_schedule(&vi->napi);
+               __napi_schedule(&vi->napi);
        }
        return 0;
 }
@@ -612,6 +613,7 @@ static struct ethtool_ops virtnet_ethtool_ops = {
        .set_tx_csum = virtnet_set_tx_csum,
        .set_sg = ethtool_op_set_sg,
        .set_tso = ethtool_op_set_tso,
+       .get_link = ethtool_op_get_link,
 };
 
 #define MIN_MTU 68
@@ -637,6 +639,41 @@ static const struct net_device_ops virtnet_netdev = {
 #endif
 };
 
+static void virtnet_update_status(struct virtnet_info *vi)
+{
+       u16 v;
+
+       if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS))
+               return;
+
+       vi->vdev->config->get(vi->vdev,
+                             offsetof(struct virtio_net_config, status),
+                             &v, sizeof(v));
+
+       /* Ignore unknown (future) status bits */
+       v &= VIRTIO_NET_S_LINK_UP;
+
+       if (vi->status == v)
+               return;
+
+       vi->status = v;
+
+       if (vi->status & VIRTIO_NET_S_LINK_UP) {
+               netif_carrier_on(vi->dev);
+               netif_wake_queue(vi->dev);
+       } else {
+               netif_carrier_off(vi->dev);
+               netif_stop_queue(vi->dev);
+       }
+}
+
+static void virtnet_config_changed(struct virtio_device *vdev)
+{
+       struct virtnet_info *vi = vdev->priv;
+
+       virtnet_update_status(vi);
+}
+
 static int virtnet_probe(struct virtio_device *vdev)
 {
        int err;
@@ -739,6 +776,9 @@ static int virtnet_probe(struct virtio_device *vdev)
                goto unregister;
        }
 
+       vi->status = VIRTIO_NET_S_LINK_UP;
+       virtnet_update_status(vi);
+
        pr_debug("virtnet: registered device %s\n", dev->name);
        return 0;
 
@@ -794,7 +834,7 @@ static unsigned int features[] = {
        VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
        VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
        VIRTIO_NET_F_GUEST_ECN, /* We don't yet handle UFO input. */
-       VIRTIO_NET_F_MRG_RXBUF,
+       VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS,
        VIRTIO_F_NOTIFY_ON_EMPTY,
 };
 
@@ -806,6 +846,7 @@ static struct virtio_driver virtio_net = {
        .id_table =     id_table,
        .probe =        virtnet_probe,
        .remove =       __devexit_p(virtnet_remove),
+       .config_changed = virtnet_config_changed,
 };
 
 static int __init init(void)
This page took 0.03068 seconds and 5 git commands to generate.