Lines Matching full:phc

79 /* PHC definitions */
1806 struct ena_com_phc_info *phc = &ena_dev->phc; in ena_com_phc_init() local
1808 memset(phc, 0x0, sizeof(*phc)); in ena_com_phc_init()
1810 /* Allocate shared mem used PHC timestamp retrieved from device */ in ena_com_phc_init()
1812 sizeof(*phc->virt_addr), in ena_com_phc_init()
1813 phc->virt_addr, in ena_com_phc_init()
1814 phc->phys_addr, in ena_com_phc_init()
1815 phc->mem_handle); in ena_com_phc_init()
1816 if (unlikely(!phc->virt_addr)) in ena_com_phc_init()
1819 ENA_SPINLOCK_INIT(phc->lock); in ena_com_phc_init()
1821 phc->virt_addr->req_id = 0; in ena_com_phc_init()
1822 phc->virt_addr->timestamp = 0; in ena_com_phc_init()
1829 struct ena_com_phc_info *phc = &ena_dev->phc; in ena_com_phc_config() local
1835 /* Get default device PHC configuration */ in ena_com_phc_config()
1841 ena_trc_err(ena_dev, "Failed to get PHC feature configuration, error: %d\n", ret); in ena_com_phc_config()
1845 /* Supporting only PHC V0 (readless mode with error bound) */ in ena_com_phc_config()
1846 if (get_feat_resp.u.phc.version != ENA_ADMIN_PHC_FEATURE_VERSION_0) { in ena_com_phc_config()
1847 ena_trc_err(ena_dev, "Unsupprted PHC version (0x%X), error: %d\n", in ena_com_phc_config()
1848 get_feat_resp.u.phc.version, in ena_com_phc_config()
1853 /* Update PHC doorbell offset according to device value, used to write req_id to PHC bar */ in ena_com_phc_config()
1854 phc->doorbell_offset = get_feat_resp.u.phc.doorbell_offset; in ena_com_phc_config()
1856 /* Update PHC expire timeout according to device or default driver value */ in ena_com_phc_config()
1857 phc->expire_timeout_usec = (get_feat_resp.u.phc.expire_timeout_usec) ? in ena_com_phc_config()
1858 get_feat_resp.u.phc.expire_timeout_usec : in ena_com_phc_config()
1861 /* Update PHC block timeout according to device or default driver value */ in ena_com_phc_config()
1862 phc->block_timeout_usec = (get_feat_resp.u.phc.block_timeout_usec) ? in ena_com_phc_config()
1863 get_feat_resp.u.phc.block_timeout_usec : in ena_com_phc_config()
1867 if (phc->expire_timeout_usec > phc->block_timeout_usec) in ena_com_phc_config()
1868 phc->expire_timeout_usec = phc->block_timeout_usec; in ena_com_phc_config()
1870 /* Prepare PHC config feature command */ in ena_com_phc_config()
1874 set_feat_cmd.u.phc.output_length = sizeof(*phc->virt_addr); in ena_com_phc_config()
1875 ret = ena_com_mem_addr_set(ena_dev, &set_feat_cmd.u.phc.output_address, phc->phys_addr); in ena_com_phc_config()
1877 ena_trc_err(ena_dev, "Failed setting PHC output address, error: %d\n", ret); in ena_com_phc_config()
1881 /* Send PHC feature command to the device */ in ena_com_phc_config()
1889 ena_trc_err(ena_dev, "Failed to enable PHC, error: %d\n", ret); in ena_com_phc_config()
1893 phc->active = true; in ena_com_phc_config()
1894 ena_trc_dbg(ena_dev, "PHC is active in the device\n"); in ena_com_phc_config()
1901 struct ena_com_phc_info *phc = &ena_dev->phc; in ena_com_phc_destroy() local
1904 /* In case PHC is not supported by the device, silently exiting */ in ena_com_phc_destroy()
1905 if (!phc->virt_addr) in ena_com_phc_destroy()
1908 ENA_SPINLOCK_LOCK(phc->lock, flags); in ena_com_phc_destroy()
1909 phc->active = false; in ena_com_phc_destroy()
1910 ENA_SPINLOCK_UNLOCK(phc->lock, flags); in ena_com_phc_destroy()
1913 sizeof(*phc->virt_addr), in ena_com_phc_destroy()
1914 phc->virt_addr, in ena_com_phc_destroy()
1915 phc->phys_addr, in ena_com_phc_destroy()
1916 phc->mem_handle); in ena_com_phc_destroy()
1917 phc->virt_addr = NULL; in ena_com_phc_destroy()
1919 ENA_SPINLOCK_DESTROY(phc->lock); in ena_com_phc_destroy()
1924 volatile struct ena_admin_phc_resp *read_resp = ena_dev->phc.virt_addr; in ena_com_phc_get_timestamp()
1926 struct ena_com_phc_info *phc = &ena_dev->phc; in ena_com_phc_get_timestamp() local
1932 if (!phc->active) { in ena_com_phc_get_timestamp()
1933 ena_trc_err(ena_dev, "PHC feature is not active in the device\n"); in ena_com_phc_get_timestamp()
1937 ENA_SPINLOCK_LOCK(phc->lock, flags); in ena_com_phc_get_timestamp()
1939 /* Check if PHC is in blocked state */ in ena_com_phc_get_timestamp()
1940 if (unlikely(ENA_TIME_COMPARE_HIGH_RES(phc->system_time, zero_system_time))) { in ena_com_phc_get_timestamp()
1942 block_time = ENA_GET_SYSTEM_TIMEOUT_HIGH_RES(phc->system_time, in ena_com_phc_get_timestamp()
1943 phc->block_timeout_usec); in ena_com_phc_get_timestamp()
1945 /* PHC is still in blocked state, skip PHC request */ in ena_com_phc_get_timestamp()
1946 phc->stats.phc_skp++; in ena_com_phc_get_timestamp()
1951 /* PHC is in active state, update statistics according to req_id and error_flags */ in ena_com_phc_get_timestamp()
1952 if ((READ_ONCE16(read_resp->req_id) != phc->req_id) || in ena_com_phc_get_timestamp()
1957 phc->stats.phc_err++; in ena_com_phc_get_timestamp()
1960 phc->stats.phc_exp++; in ena_com_phc_get_timestamp()
1965 phc->system_time = ENA_GET_SYSTEM_TIME_HIGH_RES(); in ena_com_phc_get_timestamp()
1966 block_time = ENA_GET_SYSTEM_TIMEOUT_HIGH_RES(phc->system_time, phc->block_timeout_usec); in ena_com_phc_get_timestamp()
1967 expire_time = ENA_GET_SYSTEM_TIMEOUT_HIGH_RES(phc->system_time, phc->expire_timeout_usec); in ena_com_phc_get_timestamp()
1969 /* We expect the device to return this req_id once the new PHC timestamp is updated */ in ena_com_phc_get_timestamp()
1970 phc->req_id++; in ena_com_phc_get_timestamp()
1972 /* Initialize PHC shared memory with different req_id value to be able to identify once the in ena_com_phc_get_timestamp()
1975 read_resp->req_id = phc->req_id + ENA_PHC_REQ_ID_OFFSET; in ena_com_phc_get_timestamp()
1977 /* Writing req_id to PHC bar */ in ena_com_phc_get_timestamp()
1978 ENA_REG_WRITE32(ena_dev->bus, phc->req_id, ena_dev->reg_bar + phc->doorbell_offset); in ena_com_phc_get_timestamp()
1983 /* Gave up waiting for updated req_id, PHC enters into blocked state until in ena_com_phc_get_timestamp()
1984 * passing blocking time, during this time any get PHC timestamp or in ena_com_phc_get_timestamp()
1987 phc->error_bound = ENA_PHC_MAX_ERROR_BOUND; in ena_com_phc_get_timestamp()
1993 if (READ_ONCE16(read_resp->req_id) != phc->req_id) { in ena_com_phc_get_timestamp()
1998 /* req_id was updated by the device which indicates that PHC timestamp, error_bound in ena_com_phc_get_timestamp()
2003 /* Retrieved timestamp or error bound errors, PHC enters into blocked state in ena_com_phc_get_timestamp()
2004 * until passing blocking time, during this time any get PHC timestamp or in ena_com_phc_get_timestamp()
2007 phc->error_bound = ENA_PHC_MAX_ERROR_BOUND; in ena_com_phc_get_timestamp()
2012 /* PHC timestamp value is returned to the caller */ in ena_com_phc_get_timestamp()
2016 phc->error_bound = read_resp->error_bound; in ena_com_phc_get_timestamp()
2018 /* Update statistic on valid PHC timestamp retrieval */ in ena_com_phc_get_timestamp()
2019 phc->stats.phc_cnt++; in ena_com_phc_get_timestamp()
2021 /* This indicates PHC state is active */ in ena_com_phc_get_timestamp()
2022 phc->system_time = zero_system_time; in ena_com_phc_get_timestamp()
2027 ENA_SPINLOCK_UNLOCK(phc->lock, flags); in ena_com_phc_get_timestamp()
2034 struct ena_com_phc_info *phc = &ena_dev->phc; in ena_com_phc_get_error_bound() local
2035 u32 local_error_bound = phc->error_bound; in ena_com_phc_get_error_bound()
2037 if (!phc->active) { in ena_com_phc_get_error_bound()
2038 ena_trc_err(ena_dev, "PHC feature is not active in the device\n"); in ena_com_phc_get_error_bound()