Select simplified rx/tx when mergable isn't enabled and there is no
offload flags specified.

Signed-off-by: Huawei Xie <huawei.xie at intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 3b7b841..a08529c 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -369,6 +369,8 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
        vq->virtio_net_hdr_mz  = NULL;
        vq->virtio_net_hdr_mem = 0;

+       vq->use_simple_rxtx = (dev->rx_pkt_burst == virtio_recv_pkts_vec);
+
        if (queue_type == VTNET_TQ) {
                /*
                 * For each xmit packet, allocate a virtio_net_hdr
@@ -1156,13 +1158,21 @@ virtio_interrupt_handler(__rte_unused struct 
rte_intr_handle *handle,
 }

 static void
-rx_func_get(struct rte_eth_dev *eth_dev)
+rxtx_func_get(struct rte_eth_dev *eth_dev)
 {
        struct virtio_hw *hw = eth_dev->data->dev_private;
+
        if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF))
                eth_dev->rx_pkt_burst = &virtio_recv_mergeable_pkts;
        else
                eth_dev->rx_pkt_burst = &virtio_recv_pkts;
+
+#ifdef RTE_LIBRTE_VIRTIO_SIMPLE
+       if (!vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) {
+               eth_dev->rx_pkt_burst = &virtio_recv_pkts_vec;
+               eth_dev->tx_pkt_burst = &virtio_xmit_pkts_simple;
+       }
+#endif
 }

 /*
@@ -1184,7 +1194,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->tx_pkt_burst = &virtio_xmit_pkts;

        if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
-               rx_func_get(eth_dev);
+               rxtx_func_get(eth_dev);
                return 0;
        }

@@ -1214,7 +1224,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
        vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
        virtio_negotiate_features(hw);

-       rx_func_get(eth_dev);
+       rxtx_func_get(eth_dev);

        /* Setting up rx_header size for the device */
        if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF))
-- 
1.8.1.4

Reply via email to