| 1563 | } |
| 1564 | |
| 1565 | int |
| 1566 | i40e_pf_host_init(struct rte_eth_dev *dev) |
| 1567 | { |
| 1568 | struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private); |
| 1569 | struct i40e_hw *hw = I40E_PF_TO_HW(pf); |
| 1570 | size_t size; |
| 1571 | int ret, i; |
| 1572 | uint32_t val; |
| 1573 | |
| 1574 | PMD_INIT_FUNC_TRACE(); |
| 1575 | |
| 1576 | /** |
| 1577 | * return if SRIOV not enabled, VF number not configured or |
| 1578 | * no queue assigned. |
| 1579 | */ |
| 1580 | if(!hw->func_caps.sr_iov_1_1 || pf->vf_num == 0 || pf->vf_nb_qps == 0) |
| 1581 | return I40E_SUCCESS; |
| 1582 | |
| 1583 | /* Allocate memory to store VF structure */ |
| 1584 | pf->vfs = rte_zmalloc("i40e_pf_vf",sizeof(*pf->vfs) * pf->vf_num, 0); |
| 1585 | if(pf->vfs == NULL) |
| 1586 | return -ENOMEM; |
| 1587 | |
| 1588 | /* Disable irq0 for VFR event */ |
| 1589 | i40e_pf_disable_irq0(hw); |
| 1590 | |
| 1591 | /* Disable VF link status interrupt */ |
| 1592 | val = I40E_READ_REG(hw, I40E_PFGEN_PORTMDIO_NUM); |
| 1593 | val &= ~I40E_PFGEN_PORTMDIO_NUM_VFLINK_STAT_ENA_MASK; |
| 1594 | I40E_WRITE_REG(hw, I40E_PFGEN_PORTMDIO_NUM, val); |
| 1595 | I40E_WRITE_FLUSH(hw); |
| 1596 | |
| 1597 | /* calculate the memory size for storing timestamp of messages */ |
| 1598 | size = pf->vf_msg_cfg.max_msg * sizeof(uint64_t); |
| 1599 | |
| 1600 | for (i = 0; i < pf->vf_num; i++) { |
| 1601 | pf->vfs[i].pf = pf; |
| 1602 | pf->vfs[i].state = I40E_VF_INACTIVE; |
| 1603 | pf->vfs[i].vf_idx = i; |
| 1604 | |
| 1605 | if (size) { |
| 1606 | /* allocate memory for store timestamp of messages */ |
| 1607 | pf->vfs[i].msg_timestamps = |
| 1608 | rte_zmalloc("i40e_pf_vf", size, 0); |
| 1609 | if (pf->vfs[i].msg_timestamps == NULL) { |
| 1610 | ret = -ENOMEM; |
| 1611 | goto fail; |
| 1612 | } |
| 1613 | } |
| 1614 | |
| 1615 | ret = i40e_pf_host_vf_reset(&pf->vfs[i], 0); |
| 1616 | if (ret != I40E_SUCCESS) |
| 1617 | goto fail; |
| 1618 | } |
| 1619 | |
| 1620 | RTE_ETH_DEV_SRIOV(dev).active = pf->vf_num; |
| 1621 | /* restore irq0 */ |
| 1622 | i40e_pf_enable_irq0(hw); |
no test coverage detected