Deleted Added
full compact
if_vtnet.c (239472) if_vtnet.c (246582)
1/*-
2 * Copyright (c) 2011, Bryan Venteicher <bryanv@daemoninthecloset.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/* Driver for VirtIO network devices. */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2011, Bryan Venteicher <bryanv@daemoninthecloset.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/* Driver for VirtIO network devices. */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: stable/9/sys/dev/virtio/network/if_vtnet.c 239472 2012-08-21 00:03:04Z emaste $");
30__FBSDID("$FreeBSD: stable/9/sys/dev/virtio/network/if_vtnet.c 246582 2013-02-09 06:11:45Z bryanv $");
31
32#ifdef HAVE_KERNEL_OPTION_HEADERS
33#include "opt_device_polling.h"
34#endif
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>

--- 395 unchanged lines hidden (view full) ---

434 sc->vtnet_tq = taskqueue_create_fast("vtnet_taskq", M_NOWAIT,
435 taskqueue_thread_enqueue, &sc->vtnet_tq);
436 if (sc->vtnet_tq == NULL) {
437 error = ENOMEM;
438 device_printf(dev, "cannot allocate taskqueue\n");
439 ether_ifdetach(ifp);
440 goto fail;
441 }
31
32#ifdef HAVE_KERNEL_OPTION_HEADERS
33#include "opt_device_polling.h"
34#endif
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/kernel.h>

--- 395 unchanged lines hidden (view full) ---

434 sc->vtnet_tq = taskqueue_create_fast("vtnet_taskq", M_NOWAIT,
435 taskqueue_thread_enqueue, &sc->vtnet_tq);
436 if (sc->vtnet_tq == NULL) {
437 error = ENOMEM;
438 device_printf(dev, "cannot allocate taskqueue\n");
439 ether_ifdetach(ifp);
440 goto fail;
441 }
442 taskqueue_start_threads(&sc->vtnet_tq, 1, PI_NET, "%s taskq",
443 device_get_nameunit(dev));
444
445 error = virtio_setup_intr(dev, INTR_TYPE_NET);
446 if (error) {
447 device_printf(dev, "cannot setup virtqueue interrupts\n");
442
443 error = virtio_setup_intr(dev, INTR_TYPE_NET);
444 if (error) {
445 device_printf(dev, "cannot setup virtqueue interrupts\n");
448 taskqueue_free(sc->vtnet_tq);
449 sc->vtnet_tq = NULL;
450 ether_ifdetach(ifp);
451 goto fail;
452 }
453
446 ether_ifdetach(ifp);
447 goto fail;
448 }
449
450 taskqueue_start_threads(&sc->vtnet_tq, 1, PI_NET, "%s taskq",
451 device_get_nameunit(dev));
452
454 /*
455 * Device defaults to promiscuous mode for backwards
456 * compatibility. Turn it off if possible.
457 */
458 if (sc->vtnet_flags & VTNET_FLAG_CTRL_RX) {
459 VTNET_LOCK(sc);
460 if (vtnet_set_promisc(sc, 0) != 0) {
461 ifp->if_flags |= IFF_PROMISC;

--- 281 unchanged lines hidden (view full) ---

743 offsetof(struct virtio_net_config, status));
744
745 return ((status & VIRTIO_NET_S_LINK_UP) != 0);
746}
747
748static void
749vtnet_update_link_status(struct vtnet_softc *sc)
750{
453 /*
454 * Device defaults to promiscuous mode for backwards
455 * compatibility. Turn it off if possible.
456 */
457 if (sc->vtnet_flags & VTNET_FLAG_CTRL_RX) {
458 VTNET_LOCK(sc);
459 if (vtnet_set_promisc(sc, 0) != 0) {
460 ifp->if_flags |= IFF_PROMISC;

--- 281 unchanged lines hidden (view full) ---

742 offsetof(struct virtio_net_config, status));
743
744 return ((status & VIRTIO_NET_S_LINK_UP) != 0);
745}
746
747static void
748vtnet_update_link_status(struct vtnet_softc *sc)
749{
751 device_t dev;
752 struct ifnet *ifp;
753 int link;
754
750 struct ifnet *ifp;
751 int link;
752
755 dev = sc->vtnet_dev;
756 ifp = sc->vtnet_ifp;
757
758 link = vtnet_is_link_up(sc);
759
760 if (link && ((sc->vtnet_flags & VTNET_FLAG_LINK) == 0)) {
761 sc->vtnet_flags |= VTNET_FLAG_LINK;
762 if_link_state_change(ifp, LINK_STATE_UP);
763 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))

--- 1986 unchanged lines hidden ---
753 ifp = sc->vtnet_ifp;
754
755 link = vtnet_is_link_up(sc);
756
757 if (link && ((sc->vtnet_flags & VTNET_FLAG_LINK) == 0)) {
758 sc->vtnet_flags |= VTNET_FLAG_LINK;
759 if_link_state_change(ifp, LINK_STATE_UP);
760 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))

--- 1986 unchanged lines hidden ---