| 1775 | } |
| 1776 | |
| 1777 | int ena_com_phc_config(struct ena_com_dev *ena_dev) |
| 1778 | { |
| 1779 | struct ena_com_phc_info *phc = &ena_dev->phc; |
| 1780 | struct ena_admin_get_feat_resp get_feat_resp; |
| 1781 | struct ena_admin_set_feat_resp set_feat_resp; |
| 1782 | struct ena_admin_set_feat_cmd set_feat_cmd; |
| 1783 | int ret = 0; |
| 1784 | |
| 1785 | /* Get device PHC default configuration */ |
| 1786 | ret = ena_com_get_feature(ena_dev, &get_feat_resp, ENA_ADMIN_PHC_CONFIG, 0); |
| 1787 | if (unlikely(ret)) { |
| 1788 | ena_trc_err(ena_dev, "Failed to get PHC feature configuration, error: %d\n", ret); |
| 1789 | return ret; |
| 1790 | } |
| 1791 | |
| 1792 | /* Supporting only readless PHC retrieval */ |
| 1793 | if (get_feat_resp.u.phc.type != ENA_ADMIN_PHC_TYPE_READLESS) { |
| 1794 | ena_trc_err(ena_dev, "Unsupported PHC type, error: %d\n", ENA_COM_UNSUPPORTED); |
| 1795 | return ENA_COM_UNSUPPORTED; |
| 1796 | } |
| 1797 | |
| 1798 | /* Update PHC doorbell offset according to device value, used to write req_id to PHC bar */ |
| 1799 | phc->doorbell_offset = get_feat_resp.u.phc.doorbell_offset; |
| 1800 | |
| 1801 | /* Update PHC expire timeout according to device or default driver value */ |
| 1802 | phc->expire_timeout_usec = (get_feat_resp.u.phc.expire_timeout_usec) ? |
| 1803 | get_feat_resp.u.phc.expire_timeout_usec : |
| 1804 | ENA_PHC_DEFAULT_EXPIRE_TIMEOUT_USEC; |
| 1805 | |
| 1806 | /* Update PHC block timeout according to device or default driver value */ |
| 1807 | phc->block_timeout_usec = (get_feat_resp.u.phc.block_timeout_usec) ? |
| 1808 | get_feat_resp.u.phc.block_timeout_usec : |
| 1809 | ENA_PHC_DEFAULT_BLOCK_TIMEOUT_USEC; |
| 1810 | |
| 1811 | /* Sanity check - expire timeout must not be above skip timeout */ |
| 1812 | if (phc->expire_timeout_usec > phc->block_timeout_usec) |
| 1813 | phc->expire_timeout_usec = phc->block_timeout_usec; |
| 1814 | |
| 1815 | /* Prepare PHC feature command with PHC output address */ |
| 1816 | memset(&set_feat_cmd, 0x0, sizeof(set_feat_cmd)); |
| 1817 | set_feat_cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE; |
| 1818 | set_feat_cmd.feat_common.feature_id = ENA_ADMIN_PHC_CONFIG; |
| 1819 | set_feat_cmd.u.phc.output_length = sizeof(*phc->virt_addr); |
| 1820 | ret = ena_com_mem_addr_set(ena_dev, &set_feat_cmd.u.phc.output_address, phc->phys_addr); |
| 1821 | if (unlikely(ret)) { |
| 1822 | ena_trc_err(ena_dev, "Failed setting PHC output address, error: %d\n", ret); |
| 1823 | return ret; |
| 1824 | } |
| 1825 | |
| 1826 | /* Send PHC feature command to the device */ |
| 1827 | ret = ena_com_execute_admin_command(&ena_dev->admin_queue, |
| 1828 | (struct ena_admin_aq_entry *)&set_feat_cmd, |
| 1829 | sizeof(set_feat_cmd), |
| 1830 | (struct ena_admin_acq_entry *)&set_feat_resp, |
| 1831 | sizeof(set_feat_resp)); |
| 1832 | |
| 1833 | if (unlikely(ret)) { |
| 1834 | ena_trc_err(ena_dev, "Failed to enable PHC, error: %d\n", ret); |
nothing calls this directly
no test coverage detected