| 2677 | } |
| 2678 | |
| 2679 | static int |
| 2680 | iavf_dev_init(struct rte_eth_dev *eth_dev) |
| 2681 | { |
| 2682 | struct iavf_adapter *adapter = |
| 2683 | IAVF_DEV_PRIVATE_TO_ADAPTER(eth_dev->data->dev_private); |
| 2684 | struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(adapter); |
| 2685 | struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter); |
| 2686 | struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); |
| 2687 | int ret = 0; |
| 2688 | |
| 2689 | PMD_INIT_FUNC_TRACE(); |
| 2690 | |
| 2691 | /* assign ops func pointer */ |
| 2692 | eth_dev->dev_ops = &iavf_eth_dev_ops; |
| 2693 | eth_dev->rx_queue_count = iavf_dev_rxq_count; |
| 2694 | eth_dev->rx_descriptor_status = iavf_dev_rx_desc_status; |
| 2695 | eth_dev->tx_descriptor_status = iavf_dev_tx_desc_status; |
| 2696 | eth_dev->rx_pkt_burst = &iavf_recv_pkts; |
| 2697 | eth_dev->tx_pkt_burst = &iavf_xmit_pkts; |
| 2698 | eth_dev->tx_pkt_prepare = &iavf_prep_pkts; |
| 2699 | |
| 2700 | /* For secondary processes, we don't initialise any further as primary |
| 2701 | * has already done this work. Only check if we need a different RX |
| 2702 | * and TX function. |
| 2703 | */ |
| 2704 | if (rte_eal_process_type() != RTE_PROC_PRIMARY) { |
| 2705 | iavf_set_rx_function(eth_dev); |
| 2706 | iavf_set_tx_function(eth_dev); |
| 2707 | return 0; |
| 2708 | } |
| 2709 | rte_eth_copy_pci_info(eth_dev, pci_dev); |
| 2710 | |
| 2711 | hw->vendor_id = pci_dev->id.vendor_id; |
| 2712 | hw->device_id = pci_dev->id.device_id; |
| 2713 | hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id; |
| 2714 | hw->subsystem_device_id = pci_dev->id.subsystem_device_id; |
| 2715 | hw->bus.bus_id = pci_dev->addr.bus; |
| 2716 | hw->bus.device = pci_dev->addr.devid; |
| 2717 | hw->bus.func = pci_dev->addr.function; |
| 2718 | hw->hw_addr = (void *)pci_dev->mem_resource[0].addr; |
| 2719 | hw->back = IAVF_DEV_PRIVATE_TO_ADAPTER(eth_dev->data->dev_private); |
| 2720 | adapter->dev_data = eth_dev->data; |
| 2721 | adapter->stopped = 1; |
| 2722 | |
| 2723 | if (iavf_dev_event_handler_init()) |
| 2724 | goto init_vf_err; |
| 2725 | |
| 2726 | if (iavf_init_vf(eth_dev) != 0) { |
| 2727 | PMD_INIT_LOG(ERR, "Init vf failed"); |
| 2728 | return -1; |
| 2729 | } |
| 2730 | |
| 2731 | /* set default ptype table */ |
| 2732 | iavf_set_default_ptype_table(eth_dev); |
| 2733 | |
| 2734 | /* copy mac addr */ |
| 2735 | eth_dev->data->mac_addrs = rte_zmalloc( |
| 2736 | "iavf_mac", RTE_ETHER_ADDR_LEN * IAVF_NUM_MACADDR_MAX, 0); |
no test coverage detected