ethdev: remove detachable device flag
[dpdk.git] / drivers / net / virtio / virtio_ethdev.c
index f310c97..d4354f9 100644 (file)
@@ -77,7 +77,7 @@ static int virtio_dev_link_update(struct rte_eth_dev *dev,
 static void virtio_set_hwaddr(struct virtio_hw *hw);
 static void virtio_get_hwaddr(struct virtio_hw *hw);
 
-static void virtio_dev_stats_get(struct rte_eth_dev *dev,
+static int virtio_dev_stats_get(struct rte_eth_dev *dev,
                                 struct rte_eth_stats *stats);
 static int virtio_dev_xstats_get(struct rte_eth_dev *dev,
                                 struct rte_eth_xstat *xstats, unsigned n);
@@ -163,7 +163,7 @@ virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl,
        uint32_t head, i;
        int k, sum = 0;
        virtio_net_ctrl_ack status = ~0;
-       struct virtio_pmd_ctrl result;
+       struct virtio_pmd_ctrl *result;
        struct virtqueue *vq;
 
        ctrl->status = status;
@@ -254,10 +254,9 @@ virtio_send_command(struct virtnet_ctl *cvq, struct virtio_pmd_ctrl *ctrl,
        PMD_INIT_LOG(DEBUG, "vq->vq_free_cnt=%d\nvq->vq_desc_head_idx=%d",
                        vq->vq_free_cnt, vq->vq_desc_head_idx);
 
-       memcpy(&result, cvq->virtio_net_hdr_mz->addr,
-                       sizeof(struct virtio_pmd_ctrl));
+       result = cvq->virtio_net_hdr_mz->addr;
 
-       return result.status;
+       return result->status;
 }
 
 static int
@@ -965,10 +964,12 @@ virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
        return count;
 }
 
-static void
+static int
 virtio_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
        virtio_update_stats(dev, stats);
+
+       return 0;
 }
 
 static void
@@ -1242,7 +1243,7 @@ set_rxtx_funcs(struct rte_eth_dev *eth_dev)
 {
        struct virtio_hw *hw = eth_dev->data->dev_private;
 
-       if (hw->use_simple_rxtx) {
+       if (hw->use_simple_rx) {
                PMD_INIT_LOG(INFO, "virtio: using simple Rx path on port %u",
                        eth_dev->data->port_id);
                eth_dev->rx_pkt_burst = virtio_recv_pkts_vec;
@@ -1257,7 +1258,7 @@ set_rxtx_funcs(struct rte_eth_dev *eth_dev)
                eth_dev->rx_pkt_burst = &virtio_recv_pkts;
        }
 
-       if (hw->use_simple_rxtx) {
+       if (hw->use_simple_tx) {
                PMD_INIT_LOG(INFO, "virtio: using simple Tx path on port %u",
                        eth_dev->data->port_id);
                eth_dev->tx_pkt_burst = virtio_xmit_pkts_simple;
@@ -1383,7 +1384,6 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
                rte_eth_copy_pci_info(eth_dev, pci_dev);
        }
 
-       eth_dev->data->dev_flags = RTE_ETH_DEV_DETACHABLE;
        /* If host does not support both status and MSI-X then disable LSC */
        if (vtpci_with_feature(hw, VIRTIO_NET_F_STATUS) && hw->use_msix)
                eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
@@ -1742,14 +1742,22 @@ virtio_dev_configure(struct rte_eth_dev *dev)
                        return -EBUSY;
                }
 
-       hw->use_simple_rxtx = 1;
+       hw->use_simple_rx = 1;
+       hw->use_simple_tx = 1;
 
 #if defined RTE_ARCH_ARM64 || defined CONFIG_RTE_ARCH_ARM
-       if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON))
-               hw->use_simple_rxtx = 0;
+       if (!rte_cpu_get_flag_enabled(RTE_CPUFLAG_NEON)) {
+               hw->use_simple_rx = 0;
+               hw->use_simple_tx = 0;
+       }
 #endif
-       if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF))
-               hw->use_simple_rxtx = 0;
+       if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) {
+               hw->use_simple_rx = 0;
+               hw->use_simple_tx = 0;
+       }
+
+       if (rxmode->hw_ip_checksum)
+               hw->use_simple_rx = 0;
 
        return 0;
 }
@@ -1812,6 +1820,8 @@ virtio_dev_start(struct rte_eth_dev *dev)
 
        for (i = 0; i < dev->data->nb_rx_queues; i++) {
                rxvq = dev->data->rx_queues[i];
+               /* Flush the old packets */
+               virtqueue_flush(rxvq->vq);
                virtqueue_notify(rxvq->vq);
        }