Date: Sun, 29 Jun 2014 00:38:00 +0000 (UTC) From: Bryan Venteicher <bryanv@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r268010 - in stable/10/sys/dev/virtio: . network pci Message-ID: <201406290038.s5T0c0TM072768@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bryanv Date: Sun Jun 29 00:37:59 2014 New Revision: 268010 URL: http://svnweb.freebsd.org/changeset/base/268010 Log: MFC r267520, r267521, r267522, r267523, r267524: - Remove two write-only local variables - Remove unused element in the vtnet_rxq structure - Remove kernel specific macro out of the VirtIO PCI header file - Move the VIRTIO_RING_F_* defines out of virtqueue.h into virtio_config.h - Make the feature negotiation code easier to follow - Force two byte alignment for all control message headers Modified: stable/10/sys/dev/virtio/network/if_vtnet.c stable/10/sys/dev/virtio/network/if_vtnetvar.h stable/10/sys/dev/virtio/pci/virtio_pci.c stable/10/sys/dev/virtio/pci/virtio_pci.h stable/10/sys/dev/virtio/virtio.h stable/10/sys/dev/virtio/virtio_config.h stable/10/sys/dev/virtio/virtqueue.c stable/10/sys/dev/virtio/virtqueue.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/virtio/network/if_vtnet.c ============================================================================== --- stable/10/sys/dev/virtio/network/if_vtnet.c Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/network/if_vtnet.c Sun Jun 29 00:37:59 2014 (r268010) @@ -550,37 +550,38 @@ vtnet_negotiate_features(struct vtnet_so mask |= VTNET_TSO_FEATURES; if (vtnet_tunable_int(sc, "lro_disable", vtnet_lro_disable)) mask |= VTNET_LRO_FEATURES; +#ifndef VTNET_LEGACY_TX if (vtnet_tunable_int(sc, "mq_disable", vtnet_mq_disable)) mask |= VIRTIO_NET_F_MQ; -#ifdef VTNET_LEGACY_TX +#else mask |= VIRTIO_NET_F_MQ; #endif features = VTNET_FEATURES & ~mask; sc->vtnet_features = virtio_negotiate_features(dev, features); - if (virtio_with_feature(dev, VTNET_LRO_FEATURES) == 0) - return; - if (virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF)) - return; - - /* - * LRO without mergeable buffers requires special care. This is not - * ideal because every receive buffer must be large enough to hold - * the maximum TCP packet, the Ethernet header, and the header. This - * requires up to 34 descriptors with MCLBYTES clusters. If we do - * not have indirect descriptors, LRO is disabled since the virtqueue - * will not contain very many receive buffers. - */ - if (virtio_with_feature(dev, VIRTIO_RING_F_INDIRECT_DESC) == 0) { - device_printf(dev, - "LRO disabled due to both mergeable buffers and indirect " - "descriptors not negotiated\n"); + if (virtio_with_feature(dev, VTNET_LRO_FEATURES) && + virtio_with_feature(dev, VIRTIO_NET_F_MRG_RXBUF) == 0) { + /* + * LRO without mergeable buffers requires special care. This + * is not ideal because every receive buffer must be large + * enough to hold the maximum TCP packet, the Ethernet header, + * and the header. This requires up to 34 descriptors with + * MCLBYTES clusters. If we do not have indirect descriptors, + * LRO is disabled since the virtqueue will not contain very + * many receive buffers. + */ + if (!virtio_with_feature(dev, VIRTIO_RING_F_INDIRECT_DESC)) { + device_printf(dev, + "LRO disabled due to both mergeable buffers and " + "indirect descriptors not negotiated\n"); - features &= ~VTNET_LRO_FEATURES; - sc->vtnet_features = virtio_negotiate_features(dev, features); - } else - sc->vtnet_flags |= VTNET_FLAG_LRO_NOMRG; + features &= ~VTNET_LRO_FEATURES; + sc->vtnet_features = + virtio_negotiate_features(dev, features); + } else + sc->vtnet_flags |= VTNET_FLAG_LRO_NOMRG; + } } static void @@ -2111,13 +2112,11 @@ fail: static int vtnet_txq_encap(struct vtnet_txq *txq, struct mbuf **m_head) { - struct vtnet_softc *sc; struct vtnet_tx_header *txhdr; struct virtio_net_hdr *hdr; struct mbuf *m; int error; - sc = txq->vtntx_sc; m = *m_head; M_ASSERTPKTHDR(m); @@ -2944,11 +2943,9 @@ vtnet_set_active_vq_pairs(struct vtnet_s static int vtnet_reinit(struct vtnet_softc *sc) { - device_t dev; struct ifnet *ifp; int error; - dev = sc->vtnet_dev; ifp = sc->vtnet_ifp; /* Use the current MAC address. */ @@ -3069,7 +3066,7 @@ vtnet_exec_ctrl_cmd(struct vtnet_softc * static int vtnet_ctrl_mac_cmd(struct vtnet_softc *sc, uint8_t *hwaddr) { - struct virtio_net_ctrl_hdr hdr; + struct virtio_net_ctrl_hdr hdr __aligned(2); struct sglist_seg segs[3]; struct sglist sg; uint8_t ack; @@ -3103,7 +3100,7 @@ vtnet_ctrl_mq_cmd(struct vtnet_softc *sc struct virtio_net_ctrl_mq mq; uint8_t pad2; uint8_t ack; - } s; + } s __aligned(2); int error; s.hdr.class = VIRTIO_NET_CTRL_MQ; @@ -3135,7 +3132,7 @@ vtnet_ctrl_rx_cmd(struct vtnet_softc *sc uint8_t onoff; uint8_t pad2; uint8_t ack; - } s; + } s __aligned(2); int error; KASSERT(sc->vtnet_flags & VTNET_FLAG_CTRL_RX, @@ -3218,7 +3215,7 @@ vtnet_rx_filter(struct vtnet_softc *sc) static void vtnet_rx_filter_mac(struct vtnet_softc *sc) { - struct virtio_net_ctrl_hdr hdr; + struct virtio_net_ctrl_hdr hdr __aligned(2); struct vtnet_mac_filter *filter; struct sglist_seg segs[4]; struct sglist sg; @@ -3331,7 +3328,7 @@ vtnet_exec_vlan_filter(struct vtnet_soft uint16_t tag; uint8_t pad2; uint8_t ack; - } s; + } s __aligned(2); int error; s.hdr.class = VIRTIO_NET_CTRL_VLAN; Modified: stable/10/sys/dev/virtio/network/if_vtnetvar.h ============================================================================== --- stable/10/sys/dev/virtio/network/if_vtnetvar.h Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/network/if_vtnetvar.h Sun Jun 29 00:37:59 2014 (r268010) @@ -74,7 +74,6 @@ struct vtnet_rxq { struct virtqueue *vtnrx_vq; struct sglist *vtnrx_sg; int vtnrx_id; - int vtnrx_process_limit; struct vtnet_rxq_stats vtnrx_stats; struct taskqueue *vtnrx_tq; struct task vtnrx_intrtask; Modified: stable/10/sys/dev/virtio/pci/virtio_pci.c ============================================================================== --- stable/10/sys/dev/virtio/pci/virtio_pci.c Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/pci/virtio_pci.c Sun Jun 29 00:37:59 2014 (r268010) @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include <dev/pci/pcireg.h> #include <dev/virtio/virtio.h> -#include <dev/virtio/virtio_config.h> #include <dev/virtio/virtqueue.h> #include <dev/virtio/pci/virtio_pci.h> @@ -170,6 +169,9 @@ static void vtpci_config_intr(void *); #define vtpci_setup_msi_interrupt vtpci_setup_legacy_interrupt +#define VIRTIO_PCI_CONFIG(_sc) \ + VIRTIO_PCI_CONFIG_OFF((((_sc)->vtpci_flags & VTPCI_FLAG_MSIX)) != 0) + /* * I/O port read/write wrappers. */ Modified: stable/10/sys/dev/virtio/pci/virtio_pci.h ============================================================================== --- stable/10/sys/dev/virtio/pci/virtio_pci.h Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/pci/virtio_pci.h Sun Jun 29 00:37:59 2014 (r268010) @@ -72,8 +72,7 @@ * The remaining space is defined by each driver as the per-driver * configuration space. */ -#define VIRTIO_PCI_CONFIG(sc) \ - (((sc)->vtpci_flags & VTPCI_FLAG_MSIX) ? 24 : 20) +#define VIRTIO_PCI_CONFIG_OFF(msix_enabled) ((msix_enabled) ? 24 : 20) /* * How many bits to shift physical queue address written to QUEUE_PFN. Modified: stable/10/sys/dev/virtio/virtio.h ============================================================================== --- stable/10/sys/dev/virtio/virtio.h Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/virtio.h Sun Jun 29 00:37:59 2014 (r268010) @@ -30,6 +30,7 @@ #define _VIRTIO_H_ #include <dev/virtio/virtio_ids.h> +#include <dev/virtio/virtio_config.h> struct vq_alloc_info; Modified: stable/10/sys/dev/virtio/virtio_config.h ============================================================================== --- stable/10/sys/dev/virtio/virtio_config.h Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/virtio_config.h Sun Jun 29 00:37:59 2014 (r268010) @@ -44,6 +44,12 @@ */ #define VIRTIO_F_NOTIFY_ON_EMPTY (1 << 24) +/* Support for indirect buffer descriptors. */ +#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28) + +/* Support to suppress interrupt until specific index is reached. */ +#define VIRTIO_RING_F_EVENT_IDX (1 << 29) + /* * The guest should never negotiate this feature; it * is used to detect faulty drivers. Modified: stable/10/sys/dev/virtio/virtqueue.c ============================================================================== --- stable/10/sys/dev/virtio/virtqueue.c Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/virtqueue.c Sun Jun 29 00:37:59 2014 (r268010) @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include <sys/rman.h> #include <dev/virtio/virtio.h> -#include <dev/virtio/virtio_config.h> #include <dev/virtio/virtqueue.h> #include <dev/virtio/virtio_ring.h> Modified: stable/10/sys/dev/virtio/virtqueue.h ============================================================================== --- stable/10/sys/dev/virtio/virtqueue.h Sat Jun 28 23:20:24 2014 (r268009) +++ stable/10/sys/dev/virtio/virtqueue.h Sun Jun 29 00:37:59 2014 (r268010) @@ -32,12 +32,6 @@ struct virtqueue; struct sglist; -/* Support for indirect buffer descriptors. */ -#define VIRTIO_RING_F_INDIRECT_DESC (1 << 28) - -/* Support to suppress interrupt until specific index is reached. */ -#define VIRTIO_RING_F_EVENT_IDX (1 << 29) - /* Device callback for a virtqueue interrupt. */ typedef void virtqueue_intr_t(void *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406290038.s5T0c0TM072768>