From: Jerin Jacob Date: Tue, 5 Jul 2016 12:49:23 +0000 (+0530) Subject: net/virtio: cleanup conditional compilation X-Git-Tag: spdx-start~5915 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=17483cb210fd9a3dc90fbffb4d5cec67e9e130c9;p=dpdk.git net/virtio: cleanup conditional compilation Removed unnecessary compile time dependency on "use_simple_rxtx". Signed-off-by: Jerin Jacob Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile index 3020b6880b..b9b0d8dd45 100644 --- a/drivers/net/virtio/Makefile +++ b/drivers/net/virtio/Makefile @@ -50,10 +50,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtqueue.c SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_pci.c SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_rxtx.c SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_ethdev.c - -ifeq ($(findstring RTE_MACHINE_CPUFLAG_SSSE3,$(CFLAGS)),RTE_MACHINE_CPUFLAG_SSSE3) SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_rxtx_simple.c -endif ifeq ($(CONFIG_RTE_VIRTIO_USER),y) SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/vhost_user.c diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index dd7693fec4..b8295a788b 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -253,6 +253,7 @@ struct virtio_hw { uint8_t use_msix; uint8_t started; uint8_t modern; + uint8_t use_simple_rxtx; uint8_t mac_addr[ETHER_ADDR_LEN]; uint32_t notify_off_multiplier; uint8_t *isr; diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index 724517e2b1..55532a275a 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -67,10 +67,6 @@ #define VIRTIO_SIMPLE_FLAGS ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \ ETH_TXQ_FLAGS_NOOFFLOADS) -#ifdef RTE_MACHINE_CPUFLAG_SSSE3 -static int use_simple_rxtx; -#endif - static void vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx) { @@ -334,6 +330,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) */ uint16_t i; uint16_t desc_idx; + struct virtio_hw *hw = dev->data->dev_private; PMD_INIT_FUNC_TRACE(); @@ -354,8 +351,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) nbufs = 0; error = ENOSPC; -#ifdef RTE_MACHINE_CPUFLAG_SSSE3 - if (use_simple_rxtx) { + if (hw->use_simple_rxtx) { for (desc_idx = 0; desc_idx < vq->vq_nentries; desc_idx++) { vq->vq_ring.avail->ring[desc_idx] = desc_idx; @@ -363,7 +359,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) VRING_DESC_F_WRITE; } } -#endif + memset(&rxvq->fake_mbuf, 0, sizeof(rxvq->fake_mbuf)); for (desc_idx = 0; desc_idx < RTE_PMD_VIRTIO_RX_MAX_BURST; desc_idx++) { @@ -379,12 +375,11 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) /****************************************** * Enqueue allocated buffers * *******************************************/ -#ifdef RTE_MACHINE_CPUFLAG_SSSE3 - if (use_simple_rxtx) + if (hw->use_simple_rxtx) error = virtqueue_enqueue_recv_refill_simple(vq, m); else -#endif error = virtqueue_enqueue_recv_refill(vq, m); + if (error) { rte_pktmbuf_free(m); break; @@ -405,8 +400,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) struct virtqueue *vq = txvq->vq; virtio_dev_vring_start(vq); -#ifdef RTE_MACHINE_CPUFLAG_SSSE3 - if (use_simple_rxtx) { + if (hw->use_simple_rxtx) { uint16_t mid_idx = vq->vq_nentries >> 1; for (desc_idx = 0; desc_idx < mid_idx; desc_idx++) { @@ -427,7 +421,7 @@ virtio_dev_rxtx_start(struct rte_eth_dev *dev) desc_idx++) vq->vq_ring.avail->ring[desc_idx] = desc_idx; } -#endif + VIRTQUEUE_DUMP(vq); } } @@ -457,9 +451,7 @@ virtio_dev_rx_queue_setup(struct rte_eth_dev *dev, dev->data->rx_queues[queue_idx] = rxvq; -#ifdef RTE_MACHINE_CPUFLAG_SSSE3 virtio_rxq_vec_setup(rxvq); -#endif return 0; } @@ -524,7 +516,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, PMD_INIT_LOG(INFO, "Using simple rx/tx path"); dev->tx_pkt_burst = virtio_xmit_pkts_simple; dev->rx_pkt_burst = virtio_recv_pkts_vec; - use_simple_rxtx = 1; + hw->use_simple_rxtx = 1; } #endif diff --git a/drivers/net/virtio/virtio_rxtx.h b/drivers/net/virtio/virtio_rxtx.h index 058b56a170..28f82d6a8f 100644 --- a/drivers/net/virtio/virtio_rxtx.h +++ b/drivers/net/virtio/virtio_rxtx.h @@ -86,10 +86,9 @@ struct virtnet_ctl { const struct rte_memzone *mz; /**< mem zone to populate RX ring. */ }; -#ifdef RTE_MACHINE_CPUFLAG_SSSE3 int virtio_rxq_vec_setup(struct virtnet_rx *rxvq); int virtqueue_enqueue_recv_refill_simple(struct virtqueue *vq, struct rte_mbuf *m); -#endif + #endif /* _VIRTIO_RXTX_H_ */ diff --git a/drivers/net/virtio/virtio_rxtx_simple.c b/drivers/net/virtio/virtio_rxtx_simple.c index d8dd17c477..b7f460d572 100644 --- a/drivers/net/virtio/virtio_rxtx_simple.c +++ b/drivers/net/virtio/virtio_rxtx_simple.c @@ -37,8 +37,6 @@ #include #include -#include - #include #include #include @@ -132,6 +130,10 @@ virtio_rxq_rearm_vec(struct virtnet_rx *rxvq) vq_update_avail_idx(vq); } +#ifdef RTE_MACHINE_CPUFLAG_SSSE3 + +#include + /* virtio vPMD receive routine, only accept(nb_pkts >= RTE_VIRTIO_DESC_PER_LOOP) * * This routine is for non-mergeable RX, one desc for each guest buffer. @@ -294,6 +296,8 @@ virtio_recv_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, return nb_pkts_received; } +#endif + #define VIRTIO_TX_FREE_THRESH 32 #define VIRTIO_TX_MAX_FREE_BUF_SZ 32 #define VIRTIO_TX_FREE_NR 32 diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 43268249af..a52a140432 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -304,6 +304,7 @@ virtio_user_eth_dev_alloc(const char *name) hw->vtpci_ops = &virtio_user_ops; hw->use_msix = 0; hw->modern = 0; + hw->use_simple_rxtx = 0; hw->virtio_user_dev = dev; data->dev_private = hw; data->numa_node = SOCKET_ID_ANY;