ring: move to drivers/net/
[dpdk.git] / lib / librte_pmd_virtio / virtio_ethdev.c
index 346948f..f74e413 100644 (file)
@@ -102,7 +102,7 @@ static int virtio_dev_queue_stats_mapping_set(
 /*
  * The set of PCI devices this driver supports
  */
-static struct rte_pci_id pci_id_virtio_map[] = {
+static const struct rte_pci_id pci_id_virtio_map[] = {
 
 #define RTE_PCI_DEV_ID_DECL_VIRTIO(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
 #include "rte_pci_dev_ids.h"
@@ -336,7 +336,7 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
        vq->vq_ring_mem = mz->phys_addr;
        vq->vq_ring_virt_mem = mz->addr;
        PMD_INIT_LOG(DEBUG, "vq->vq_ring_mem:      0x%"PRIx64, (uint64_t)mz->phys_addr);
-       PMD_INIT_LOG(DEBUG, "vq->vq_ring_virt_mem: 0x%"PRIx64, (uint64_t)mz->addr);
+       PMD_INIT_LOG(DEBUG, "vq->vq_ring_virt_mem: 0x%"PRIx64, (uint64_t)(uintptr_t)mz->addr);
        vq->virtio_net_hdr_mz  = NULL;
        vq->virtio_net_hdr_mem = 0;
 
@@ -499,7 +499,7 @@ virtio_dev_allmulticast_disable(struct rte_eth_dev *dev)
 /*
  * dev_ops for virtio, bare necessities for basic operation
  */
-static struct eth_dev_ops virtio_eth_dev_ops = {
+static const struct eth_dev_ops virtio_eth_dev_ops = {
        .dev_configure           = virtio_dev_configure,
        .dev_start               = virtio_dev_start,
        .dev_stop                = virtio_dev_stop,
@@ -1097,6 +1097,16 @@ virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
 
 }
 
+static void
+rx_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;
+}
+
 /*
  * This function is based on probe() function in virtio_pci.c
  * It returns 0 on success.
@@ -1115,8 +1125,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
        eth_dev->dev_ops = &virtio_eth_dev_ops;
        eth_dev->tx_pkt_burst = &virtio_xmit_pkts;
 
-       if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+       if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+               rx_func_get(eth_dev);
                return 0;
+       }
 
        /* Allocate memory for storing MAC addresses */
        eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0);
@@ -1144,14 +1156,13 @@ 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);
+
        /* Setting up rx_header size for the device */
-       if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) {
-               eth_dev->rx_pkt_burst = &virtio_recv_mergeable_pkts;
+       if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF))
                hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr_mrg_rxbuf);
-       } else {
-               eth_dev->rx_pkt_burst = &virtio_recv_pkts;
+       else
                hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr);
-       }
 
        /* Copy the permanent MAC address to: virtio_hw */
        virtio_get_hwaddr(hw);