diff options
author | bryanv <bryanv@FreeBSD.org> | 2014-06-29 00:37:59 +0000 |
---|---|---|
committer | bryanv <bryanv@FreeBSD.org> | 2014-06-29 00:37:59 +0000 |
commit | a672dfd83f7fd03be3300440ee58815eb6427161 (patch) | |
tree | ffbd817301281a871c52dc9c4eaa78ef0d972b24 /sys/dev/virtio | |
parent | 7a51d5500789f348ee8a2418972c6b0780236682 (diff) | |
download | FreeBSD-src-a672dfd83f7fd03be3300440ee58815eb6427161.zip FreeBSD-src-a672dfd83f7fd03be3300440ee58815eb6427161.tar.gz |
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
Diffstat (limited to 'sys/dev/virtio')
-rw-r--r-- | sys/dev/virtio/network/if_vtnet.c | 59 | ||||
-rw-r--r-- | sys/dev/virtio/network/if_vtnetvar.h | 1 | ||||
-rw-r--r-- | sys/dev/virtio/pci/virtio_pci.c | 4 | ||||
-rw-r--r-- | sys/dev/virtio/pci/virtio_pci.h | 3 | ||||
-rw-r--r-- | sys/dev/virtio/virtio.h | 1 | ||||
-rw-r--r-- | sys/dev/virtio/virtio_config.h | 6 | ||||
-rw-r--r-- | sys/dev/virtio/virtqueue.c | 1 | ||||
-rw-r--r-- | sys/dev/virtio/virtqueue.h | 6 |
8 files changed, 39 insertions, 42 deletions
diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c index 9e1ad26..17630b9 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -550,37 +550,38 @@ vtnet_negotiate_features(struct vtnet_softc *sc) 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_softc *sc) 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 *sc, void *cookie, 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, uint16_t npairs) 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, int cmd, int on) 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_softc *sc, int add, uint16_t tag) uint16_t tag; uint8_t pad2; uint8_t ack; - } s; + } s __aligned(2); int error; s.hdr.class = VIRTIO_NET_CTRL_VLAN; diff --git a/sys/dev/virtio/network/if_vtnetvar.h b/sys/dev/virtio/network/if_vtnetvar.h index aa6d634..23c31f4 100644 --- a/sys/dev/virtio/network/if_vtnetvar.h +++ b/sys/dev/virtio/network/if_vtnetvar.h @@ -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; diff --git a/sys/dev/virtio/pci/virtio_pci.c b/sys/dev/virtio/pci/virtio_pci.c index 497abc8..e5a0332 100644 --- a/sys/dev/virtio/pci/virtio_pci.c +++ b/sys/dev/virtio/pci/virtio_pci.c @@ -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. */ diff --git a/sys/dev/virtio/pci/virtio_pci.h b/sys/dev/virtio/pci/virtio_pci.h index 485cf4f..f071ad6 100644 --- a/sys/dev/virtio/pci/virtio_pci.h +++ b/sys/dev/virtio/pci/virtio_pci.h @@ -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. diff --git a/sys/dev/virtio/virtio.h b/sys/dev/virtio/virtio.h index f4586e2..05fb0c6 100644 --- a/sys/dev/virtio/virtio.h +++ b/sys/dev/virtio/virtio.h @@ -30,6 +30,7 @@ #define _VIRTIO_H_ #include <dev/virtio/virtio_ids.h> +#include <dev/virtio/virtio_config.h> struct vq_alloc_info; diff --git a/sys/dev/virtio/virtio_config.h b/sys/dev/virtio/virtio_config.h index 379b011..88cdb8b 100644 --- a/sys/dev/virtio/virtio_config.h +++ b/sys/dev/virtio/virtio_config.h @@ -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. diff --git a/sys/dev/virtio/virtqueue.c b/sys/dev/virtio/virtqueue.c index 1ccb363..5eda6cd 100644 --- a/sys/dev/virtio/virtqueue.c +++ b/sys/dev/virtio/virtqueue.c @@ -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> diff --git a/sys/dev/virtio/virtqueue.h b/sys/dev/virtio/virtqueue.h index 0d4ed94..3f507a8 100644 --- a/sys/dev/virtio/virtqueue.h +++ b/sys/dev/virtio/virtqueue.h @@ -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 *); |