X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_pmd_virtio%2Fvirtio_ethdev.c;h=e63dbfb9705b26da59d02155f1089991cfda5aba;hb=7ada00cb0dcfe402651c2b361f7f34d0ec648556;hp=88ecd571d0421a8757815d2f367f32cb6bd4a9b8;hpb=a8e3219a92660929a18547f5f70cc3928c9fc865;p=dpdk.git diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c b/lib/librte_pmd_virtio/virtio_ethdev.c index 88ecd571d0..e63dbfb970 100644 --- a/lib/librte_pmd_virtio/virtio_ethdev.c +++ b/lib/librte_pmd_virtio/virtio_ethdev.c @@ -62,8 +62,7 @@ #include "virtqueue.h" -static int eth_virtio_dev_init(struct eth_driver *eth_drv, - struct rte_eth_dev *eth_dev); +static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev); static int virtio_dev_configure(struct rte_eth_dev *dev); static int virtio_dev_start(struct rte_eth_dev *dev); static void virtio_dev_stop(struct rte_eth_dev *dev); @@ -103,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" @@ -115,7 +114,7 @@ static int virtio_send_command(struct virtqueue *vq, struct virtio_pmd_ctrl *ctrl, int *dlen, int pkt_num) { - uint32_t head = vq->vq_desc_head_idx, i; + uint16_t head = vq->vq_desc_head_idx, i; int k, sum = 0; virtio_net_ctrl_ack status = ~0; struct virtio_pmd_ctrl result; @@ -242,7 +241,7 @@ virtio_set_multiple_queues(struct rte_eth_dev *dev, uint16_t nb_queues) int virtio_dev_queue_setup(struct rte_eth_dev *dev, int queue_type, uint16_t queue_idx, - uint8_t vtpci_queue_idx, + uint16_t vtpci_queue_idx, uint16_t nb_desc, unsigned int socket_id, struct virtqueue **pvq) @@ -500,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, @@ -938,8 +937,6 @@ static int virtio_resource_init_by_uio(struct rte_pci_device *pci_dev) char filename[PATH_MAX]; unsigned long start, size; unsigned int uio_num; - struct rte_pci_driver *pci_drv = - (struct rte_pci_driver *)pci_dev->driver; if (get_uio_dev(&pci_dev->addr, dirname, sizeof(dirname), &uio_num) < 0) return -1; @@ -973,12 +970,12 @@ static int virtio_resource_init_by_uio(struct rte_pci_device *pci_dev) pci_dev->intr_handle.fd = open(dirname, O_RDWR); if (pci_dev->intr_handle.fd < 0) { PMD_INIT_LOG(ERR, "Cannot open %s: %s\n", - devname, strerror(errno)); + dirname, strerror(errno)); return -1; } pci_dev->intr_handle.type = RTE_INTR_HANDLE_UIO; - pci_drv->drv_flags |= RTE_PCI_DRV_INTR_LSC; + pci_dev->driver->drv_flags |= RTE_PCI_DRV_INTR_LSC; return 0; } @@ -993,8 +990,6 @@ static int virtio_resource_init_by_ioports(struct rte_pci_device *pci_dev) char pci_id[16]; int found = 0; size_t linesz; - struct rte_pci_driver *pci_drv = - (struct rte_pci_driver *)pci_dev->driver; snprintf(pci_id, sizeof(pci_id), PCI_PRI_FMT, pci_dev->addr.domain, @@ -1046,7 +1041,7 @@ static int virtio_resource_init_by_ioports(struct rte_pci_device *pci_dev) start, size); /* can't support lsc interrupt without uio */ - pci_drv->drv_flags &= ~RTE_PCI_DRV_INTR_LSC; + pci_dev->driver->drv_flags &= ~RTE_PCI_DRV_INTR_LSC; return 0; } @@ -1102,13 +1097,22 @@ 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. */ static int -eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv, - struct rte_eth_dev *eth_dev) +eth_virtio_dev_init(struct rte_eth_dev *eth_dev) { struct virtio_hw *hw = eth_dev->data->dev_private; struct virtio_net_config *config; @@ -1121,8 +1125,10 @@ eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv, 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); @@ -1150,14 +1156,13 @@ eth_virtio_dev_init(__rte_unused struct eth_driver *eth_drv, 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); @@ -1475,6 +1480,9 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->min_rx_bufsize = VIRTIO_MIN_RX_BUFSIZE; dev_info->max_rx_pktlen = VIRTIO_MAX_RX_PKTLEN; dev_info->max_mac_addrs = VIRTIO_MAX_MAC_ADDRS; + dev_info->default_txconf = (struct rte_eth_txconf) { + .txq_flags = ETH_TXQ_FLAGS_NOOFFLOADS + }; } /*