X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Favp%2Favp_ethdev.c;h=8f4b78cfd58deae090b7be18a6f79f50ad3dbeeb;hb=9f9fad8f214a8b953b46aea23d7e8d0010731043;hp=989152e075cc1bc14d05a86870e7a08c63c6b55f;hpb=82e140b84995b033f57144b0d9e48f8cd6444833;p=dpdk.git diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c index 989152e075..8f4b78cfd5 100644 --- a/drivers/net/avp/avp_ethdev.c +++ b/drivers/net/avp/avp_ethdev.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -69,9 +71,8 @@ static void avp_dev_stop(struct rte_eth_dev *dev); static void avp_dev_close(struct rte_eth_dev *dev); static void avp_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); -static void avp_vlan_offload_set(struct rte_eth_dev *dev, int mask); -static int avp_dev_link_update(struct rte_eth_dev *dev, - __rte_unused int wait_to_complete); +static int avp_vlan_offload_set(struct rte_eth_dev *dev, int mask); +static int avp_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete); static void avp_dev_promiscuous_enable(struct rte_eth_dev *dev); static void avp_dev_promiscuous_disable(struct rte_eth_dev *dev); @@ -107,14 +108,11 @@ static uint16_t avp_xmit_pkts(void *tx_queue, static void avp_dev_rx_queue_release(void *rxq); static void avp_dev_tx_queue_release(void *txq); -static void avp_dev_stats_get(struct rte_eth_dev *dev, +static int avp_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats); static void avp_dev_stats_reset(struct rte_eth_dev *dev); -#define AVP_DEV_TO_PCI(eth_dev) RTE_DEV_TO_PCI((eth_dev)->device) - - #define AVP_MAX_RX_BURST 64 #define AVP_MAX_TX_BURST 64 #define AVP_MAX_MAC_ADDRS 1 @@ -193,7 +191,7 @@ struct avp_dev { struct rte_eth_dev_data *dev_data; /**< Back pointer to ethernet device data */ volatile uint32_t flags; /**< Device operational flags */ - uint8_t port_id; /**< Ethernet port identifier */ + uint16_t port_id; /**< Ethernet port identifier */ struct rte_mempool *pool; /**< pkt mbuf mempool */ unsigned int guest_mbuf_size; /**< local pool mbuf size */ unsigned int host_mbuf_size; /**< host mbuf size */ @@ -392,7 +390,7 @@ static void * avp_dev_translate_address(struct rte_eth_dev *eth_dev, phys_addr_t host_phys_addr) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_mem_resource *resource; struct rte_avp_memmap_info *info; struct rte_avp_memmap *map; @@ -445,7 +443,7 @@ avp_dev_version_check(uint32_t version) static int avp_dev_check_regions(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct rte_avp_memmap_info *memmap; struct rte_avp_device_info *info; struct rte_mem_resource *resource; @@ -581,7 +579,7 @@ _avp_set_rx_queue_mappings(struct rte_eth_dev *eth_dev, uint16_t rx_queue_id) static void _avp_set_queue_counts(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); struct rte_avp_device_info *host_info; void *addr; @@ -641,7 +639,7 @@ avp_dev_attach(struct rte_eth_dev *eth_dev) * re-run the device create utility which will parse the new host info * and setup the AVP device queue pointers. */ - ret = avp_dev_create(AVP_DEV_TO_PCI(eth_dev), eth_dev); + ret = avp_dev_create(RTE_ETH_DEV_TO_PCI(eth_dev), eth_dev); if (ret < 0) { PMD_DRV_LOG(ERR, "Failed to re-create AVP device, ret=%d\n", ret); @@ -692,11 +690,10 @@ unlock: } static void -avp_dev_interrupt_handler(struct rte_intr_handle *intr_handle, - void *data) +avp_dev_interrupt_handler(void *data) { struct rte_eth_dev *eth_dev = data; - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr; uint32_t status, value; int ret; @@ -712,7 +709,7 @@ avp_dev_interrupt_handler(struct rte_intr_handle *intr_handle, RTE_PTR_ADD(registers, RTE_AVP_INTERRUPT_STATUS_OFFSET)); - if (status | RTE_AVP_MIGRATION_INTERRUPT_MASK) { + if (status & RTE_AVP_MIGRATION_INTERRUPT_MASK) { /* handle interrupt based on current status */ value = AVP_READ32( RTE_PTR_ADD(registers, @@ -744,7 +741,7 @@ avp_dev_interrupt_handler(struct rte_intr_handle *intr_handle, status); /* re-enable UIO interrupt handling */ - ret = rte_intr_enable(intr_handle); + ret = rte_intr_enable(&pci_dev->intr_handle); if (ret < 0) { PMD_DRV_LOG(ERR, "Failed to re-enable UIO interrupts, ret=%d\n", ret); @@ -755,7 +752,7 @@ avp_dev_interrupt_handler(struct rte_intr_handle *intr_handle, static int avp_dev_enable_interrupts(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr; int ret; @@ -780,7 +777,7 @@ avp_dev_enable_interrupts(struct rte_eth_dev *eth_dev) static int avp_dev_disable_interrupts(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr; int ret; @@ -805,7 +802,7 @@ avp_dev_disable_interrupts(struct rte_eth_dev *eth_dev) static int avp_dev_setup_interrupts(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); int ret; /* register a callback handler with UIO for interrupt notifications */ @@ -825,7 +822,7 @@ avp_dev_setup_interrupts(struct rte_eth_dev *eth_dev) static int avp_dev_migration_pending(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); void *registers = pci_dev->mem_resource[RTE_AVP_PCI_MMIO_BAR].addr; uint32_t value; @@ -986,7 +983,7 @@ eth_avp_dev_init(struct rte_eth_dev *eth_dev) struct rte_pci_device *pci_dev; int ret; - pci_dev = AVP_DEV_TO_PCI(eth_dev); + pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); eth_dev->dev_ops = &avp_eth_dev_ops; eth_dev->rx_pkt_burst = &avp_recv_pkts; eth_dev->tx_pkt_burst = &avp_xmit_pkts; @@ -1008,8 +1005,6 @@ eth_avp_dev_init(struct rte_eth_dev *eth_dev) rte_eth_copy_pci_info(eth_dev, pci_dev); - eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE; - /* Check current migration status */ if (avp_dev_migration_pending(eth_dev)) { PMD_DRV_LOG(ERR, "VM live migration operation in progress\n"); @@ -1077,17 +1072,37 @@ eth_avp_dev_uninit(struct rte_eth_dev *eth_dev) return 0; } +static int +eth_avp_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, + struct rte_pci_device *pci_dev) +{ + struct rte_eth_dev *eth_dev; + int ret; -static struct eth_driver rte_avp_pmd = { - { - .id_table = pci_id_avp_map, - .drv_flags = RTE_PCI_DRV_NEED_MAPPING, - .probe = rte_eth_dev_pci_probe, - .remove = rte_eth_dev_pci_remove, - }, - .eth_dev_init = eth_avp_dev_init, - .eth_dev_uninit = eth_avp_dev_uninit, - .dev_private_size = sizeof(struct avp_adapter), + eth_dev = rte_eth_dev_pci_allocate(pci_dev, + sizeof(struct avp_adapter)); + if (eth_dev == NULL) + return -ENOMEM; + + ret = eth_avp_dev_init(eth_dev); + if (ret) + rte_eth_dev_pci_release(eth_dev); + + return ret; +} + +static int +eth_avp_pci_remove(struct rte_pci_device *pci_dev) +{ + return rte_eth_dev_pci_generic_remove(pci_dev, + eth_avp_dev_uninit); +} + +static struct rte_pci_driver rte_avp_pmd = { + .id_table = pci_id_avp_map, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, + .probe = eth_avp_pci_probe, + .remove = eth_avp_pci_remove, }; static int @@ -1345,7 +1360,7 @@ avp_dev_copy_from_buffers(struct avp_dev *avp, src_offset = 0; if (pkt_buf->ol_flags & RTE_AVP_RX_VLAN_PKT) { - ol_flags = PKT_RX_VLAN_PKT; + ol_flags = PKT_RX_VLAN; vlan_tci = pkt_buf->vlan_tci; } else { ol_flags = 0; @@ -1603,7 +1618,7 @@ avp_recv_pkts(void *rx_queue, m->port = avp->port_id; if (pkt_buf->ol_flags & RTE_AVP_RX_VLAN_PKT) { - m->ol_flags = PKT_RX_VLAN_PKT; + m->ol_flags = PKT_RX_VLAN; m->vlan_tci = pkt_buf->vlan_tci; } @@ -1991,7 +2006,7 @@ avp_dev_tx_queue_release(void *tx_queue) static int avp_dev_configure(struct rte_eth_dev *eth_dev) { - struct rte_pci_device *pci_dev = AVP_DEV_TO_PCI(eth_dev); + struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); struct rte_avp_device_info *host_info; struct rte_avp_device_config config; @@ -2015,7 +2030,12 @@ avp_dev_configure(struct rte_eth_dev *eth_dev) mask = (ETH_VLAN_STRIP_MASK | ETH_VLAN_FILTER_MASK | ETH_VLAN_EXTEND_MASK); - avp_vlan_offload_set(eth_dev, mask); + ret = avp_vlan_offload_set(eth_dev, mask); + if (ret < 0) { + PMD_DRV_LOG(ERR, "VLAN offload set failed by host, ret=%d\n", + ret); + goto unlock; + } /* update device config */ memset(&config, 0, sizeof(config)); @@ -2186,8 +2206,7 @@ avp_dev_info_get(struct rte_eth_dev *eth_dev, { struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); - dev_info->driver_name = "rte_avp_pmd"; - dev_info->pci_dev = RTE_DEV_TO_PCI(eth_dev->device); + dev_info->pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); dev_info->max_rx_queues = avp->max_rx_queues; dev_info->max_tx_queues = avp->max_tx_queues; dev_info->min_rx_bufsize = AVP_MIN_RX_BUFSIZE; @@ -2199,7 +2218,7 @@ avp_dev_info_get(struct rte_eth_dev *eth_dev, } } -static void +static int avp_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) { struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); @@ -2224,9 +2243,11 @@ avp_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask) if (eth_dev->data->dev_conf.rxmode.hw_vlan_extend) PMD_DRV_LOG(ERR, "VLAN extend offload not supported\n"); } + + return 0; } -static void +static int avp_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) { struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private); @@ -2259,6 +2280,8 @@ avp_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats) stats->q_errors[i] += txq->errors; } } + + return 0; } static void @@ -2288,5 +2311,5 @@ avp_dev_stats_reset(struct rte_eth_dev *eth_dev) } } -RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd.pci_drv); +RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);