X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fi40e%2Fi40e_ethdev_vf.c;h=dc076ae5522a4892f2e5171c3fafcac2bd2ad5c2;hb=ecf1474a618ba77ef3c4471fdc004a8c5f3b4d11;hp=61aad8c41592ea98360beb8ed719a7242603d66f;hpb=b142387b07600c320683255d237b9109299883d5;p=dpdk.git diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 61aad8c415..dc076ae552 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -74,7 +74,7 @@ enum i40evf_aq_result { static int i40evf_dev_configure(struct rte_eth_dev *dev); static int i40evf_dev_start(struct rte_eth_dev *dev); -static void i40evf_dev_stop(struct rte_eth_dev *dev); +static int i40evf_dev_stop(struct rte_eth_dev *dev); static int i40evf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); static int i40evf_dev_link_update(struct rte_eth_dev *dev, @@ -260,7 +260,7 @@ i40evf_read_pfmsg(struct rte_eth_dev *dev, struct i40evf_arq_msg_info *data) case VIRTCHNL_EVENT_RESET_IMPENDING: vf->vf_reset = true; vf->pend_msg |= PFMSG_RESET_IMPENDING; - PMD_DRV_LOG(INFO, "vf is reseting"); + PMD_DRV_LOG(INFO, "VF is resetting"); break; case VIRTCHNL_EVENT_PF_DRIVER_CLOSE: vf->dev_closed = true; @@ -314,7 +314,7 @@ _atomic_set_cmd(struct i40e_vf *vf, enum virtchnl_ops ops) #define ASQ_DELAY_MS 10 static int -i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) +_i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) { struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); @@ -405,6 +405,19 @@ i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) return err | vf->cmd_retval; } +static int +i40evf_execute_vf_cmd(struct rte_eth_dev *dev, struct vf_cmd_info *args) +{ + struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + int err; + + while (!rte_spinlock_trylock(&vf->cmd_send_lock)) + rte_delay_us_sleep(50); + err = _i40evf_execute_vf_cmd(dev, args); + rte_spinlock_unlock(&vf->cmd_send_lock); + return err; +} + /* * Check API version with sync wait until version read or fail from admin queue */ @@ -1065,8 +1078,18 @@ i40evf_add_vlan(struct rte_eth_dev *dev, uint16_t vlanid) args.out_buffer = vf->aq_resp; args.out_size = I40E_AQ_BUF_SZ; err = i40evf_execute_vf_cmd(dev, &args); - if (err) + if (err) { PMD_DRV_LOG(ERR, "fail to execute command OP_ADD_VLAN"); + return err; + } + /** + * In linux kernel driver on receiving ADD_VLAN it enables + * VLAN_STRIP by default. So reconfigure the vlan_offload + * as it was done by the app earlier. + */ + err = i40evf_vlan_offload_set(dev, ETH_VLAN_STRIP_MASK); + if (err) + PMD_DRV_LOG(ERR, "fail to set vlan_strip"); return err; } @@ -1246,6 +1269,7 @@ i40evf_init_vf(struct rte_eth_dev *dev) vf->adapter = I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); vf->dev_data = dev->data; + rte_spinlock_init(&vf->cmd_send_lock); err = i40e_set_mac_type(hw); if (err) { PMD_INIT_LOG(ERR, "set_mac_type failed: %d", err); @@ -1575,6 +1599,7 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev) } i40e_set_default_ptype_table(eth_dev); rte_eth_copy_pci_info(eth_dev, pci_dev); + eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS; hw->vendor_id = pci_dev->id.vendor_id; hw->device_id = pci_dev->id.device_id; @@ -1586,11 +1611,6 @@ i40evf_dev_init(struct rte_eth_dev *eth_dev) hw->adapter_stopped = 1; hw->adapter_closed = 0; - /* Pass the information to the rte_eth_dev_close() that it should also - * release the private port resources. - */ - eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; - if(i40evf_init_vf(eth_dev) != 0) { PMD_INIT_LOG(ERR, "Init vf failed"); return -1; @@ -2181,7 +2201,7 @@ err_queue: return -1; } -static void +static int i40evf_dev_stop(struct rte_eth_dev *dev) { struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev); @@ -2195,7 +2215,7 @@ i40evf_dev_stop(struct rte_eth_dev *dev) rte_intr_disable(intr_handle); if (hw->adapter_stopped == 1) - return; + return 0; i40evf_stop_queues(dev); i40evf_disable_queues_intr(dev); i40e_dev_clear_queues(dev); @@ -2212,7 +2232,9 @@ i40evf_dev_stop(struct rte_eth_dev *dev) i40evf_add_del_mc_addr_list(dev, vf->mc_addrs, vf->mc_addrs_num, FALSE); hw->adapter_stopped = 1; + dev->data->dev_started = 0; + return 0; } static int @@ -2394,6 +2416,7 @@ i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) stats->imissed = pstats->rx_discards; stats->oerrors = pstats->tx_errors + pstats->tx_discards; stats->ibytes = pstats->rx_bytes; + stats->ibytes -= stats->ipackets * RTE_ETHER_CRC_LEN; stats->obytes = pstats->tx_bytes; } else { PMD_DRV_LOG(ERR, "Get statistics failed"); @@ -2406,8 +2429,13 @@ i40evf_dev_close(struct rte_eth_dev *dev) { struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct i40e_vf *vf = I40EVF_DEV_PRIVATE_TO_VF(dev->data->dev_private); + int ret; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; + + ret = i40evf_dev_stop(dev); - i40evf_dev_stop(dev); i40e_dev_free_queues(dev); /* * disable promiscuous mode before reset vf @@ -2423,17 +2451,13 @@ i40evf_dev_close(struct rte_eth_dev *dev) i40e_shutdown_adminq(hw); i40evf_disable_irq0(hw); - dev->dev_ops = NULL; - dev->rx_pkt_burst = NULL; - dev->tx_pkt_burst = NULL; - rte_free(vf->vf_res); vf->vf_res = NULL; rte_free(vf->aq_resp); vf->aq_resp = NULL; hw->adapter_closed = 1; - return 0; + return ret; } /*