@@ -1685,4 +1685,177 @@ void rpmi_service_group_dpwr_destroy(struct rpmi_service_group *group);
16851685
16861686/** @} */
16871687
1688+ /******************************************************************************/
1689+
1690+ /**
1691+ * \defgroup LIBRPMI_PERFSRVGRP_INTERFACE RPMI Perf Service Group Library Interface
1692+ * @brief Global functions and data structures implemented by the RPMI library
1693+ * for RPMI perf service group.
1694+ * @{
1695+ */
1696+
1697+ /** Supported perf states */
1698+ enum rpmi_perf_state {
1699+ RPMI_PERF_STATE_INVALID = -1 ,
1700+ RPMI_PERF_STATE_DISABLED = -2 ,
1701+ RPMI_PERF_STATE_HW_FAULT = -3 ,
1702+ RPMI_PERF_STATE_ENABLED = 0 ,
1703+ RPMI_PERF_STATE_MAX_IDX ,
1704+ };
1705+
1706+ /** Perf capabilities */
1707+ #define RPMI_PERF_CAPABILITY_SET_LIMIT (1U << 2)
1708+ #define RPMI_PERF_CAPABILITY_SET_LEVEL (1U << 1)
1709+ #define RPMI_PERF_CAPABILITY_FAST_CHANNEL_SUPPORT (1U << 0)
1710+
1711+ /** Fastchannel flags */
1712+ #define RPMI_PERF_FST_CHN_DB_REG_08_BITS (0U << 1)
1713+ #define RPMI_PERF_FST_CHN_DB_REG_16_BITS (1U << 1)
1714+ #define RPMI_PERF_FST_CHN_DB_REG_32_BITS (2U << 1)
1715+
1716+ #define RPMI_PERF_FST_CHN_DB_NOT_SUPP (0U << 0)
1717+ #define RPMI_PERF_FST_CHN_DB_SUPP (1U << 0)
1718+
1719+ /** Fastchannel operation types */
1720+ enum {
1721+ /* get domain perf level using fastchannel */
1722+ RPMI_PERF_FC_GET_LEVEL = 0x0 ,
1723+ /* set domain perf level using fastchannel */
1724+ RPMI_PERF_FC_SET_LEVEL = 0x1 ,
1725+ /* get domain perf limit using fastchannel */
1726+ RPMI_PERF_FC_GET_LIMIT = 0x2 ,
1727+ /* set domain perf limit using fastchannel */
1728+ RPMI_PERF_FC_SET_LIMIT = 0x3 ,
1729+ /* maximum number of fastchannel operations */
1730+ RPMI_PERF_FC_MAX_IDX ,
1731+ };
1732+
1733+ /** A Perf level representation in RPMI */
1734+ struct rpmi_perf_level {
1735+ rpmi_uint32_t level_index ;
1736+ rpmi_uint32_t clock_freq ;
1737+ rpmi_uint32_t power_cost ;
1738+ rpmi_uint32_t transition_latency ;
1739+ };
1740+
1741+ /* Perf fast-channel shared memory info */
1742+ struct rpmi_perf_fc_memory_region {
1743+ rpmi_uint32_t addr_low ;
1744+ rpmi_uint32_t addr_high ;
1745+ rpmi_uint32_t size_low ;
1746+ rpmi_uint32_t size_high ;
1747+ };
1748+
1749+ /** Perf Domain Fast Channel Attributes */
1750+ struct rpmi_perf_fc_attrs {
1751+ /** Fast Channel flags */
1752+ rpmi_uint32_t flags ;
1753+ /** offset of phys addr low */
1754+ rpmi_uint32_t offset_phys_addr_low ;
1755+ /** offset of phys addr high */
1756+ rpmi_uint32_t offset_phys_addr_high ;
1757+ /** size */
1758+ rpmi_uint32_t size ;
1759+ /** doorbell addr low */
1760+ rpmi_uint32_t db_addr_low ;
1761+ /** doorbell addr high */
1762+ rpmi_uint32_t db_addr_high ;
1763+ /** doorbell id */
1764+ rpmi_uint32_t db_id ;
1765+ };
1766+
1767+ /**
1768+ * Perf Data and Tree details
1769+ *
1770+ * This structure represents the static
1771+ * perf data which platform has to maintain
1772+ * and pass to create the perf service group.
1773+ */
1774+ struct rpmi_perf_data {
1775+ /* Perf domain name */
1776+ const char * name ;
1777+ /* Min time required between two consecutive requests (us) */
1778+ rpmi_uint32_t trans_latency ;
1779+ /* Perf capabilities */
1780+ rpmi_uint32_t perf_capabilities ;
1781+ /* Number of levels supported */
1782+ rpmi_uint32_t perf_level_count ;
1783+ /* Perf level array */
1784+ struct rpmi_perf_level * perf_level_array ;
1785+ /* Fast Channel attributes array */
1786+ struct rpmi_perf_fc_attrs * fc_attrs_array ;
1787+ };
1788+
1789+ /** Perf Domain Attributes */
1790+ struct rpmi_perf_attrs {
1791+ /** perf service return status */
1792+ rpmi_int32_t status ;
1793+ /** perf capabilities and constraints */
1794+ rpmi_uint32_t capability ;
1795+ /** number of supported levels */
1796+ rpmi_uint32_t level_count ;
1797+ /** min time required between two consecutive requests (us) */
1798+ rpmi_uint32_t trans_latency ;
1799+ /** array of supported levels */
1800+ struct rpmi_perf_level * level_array ;
1801+ /** perf domain name */
1802+ const char * name ;
1803+ };
1804+
1805+ /** Platform specific perf operations(synchronous) */
1806+ struct rpmi_perf_platform_ops {
1807+ /**
1808+ * Get perf level
1809+ **/
1810+ enum rpmi_error (* get_level )(void * priv ,
1811+ rpmi_uint32_t perf_id ,
1812+ rpmi_uint32_t * state );
1813+
1814+ /**
1815+ * Set perf level
1816+ **/
1817+ enum rpmi_error (* set_level )(void * priv ,
1818+ rpmi_uint32_t perf_id ,
1819+ rpmi_uint32_t perf_level );
1820+
1821+ /**
1822+ * Get perf limit
1823+ **/
1824+ enum rpmi_error (* get_limit )(void * priv ,
1825+ rpmi_uint32_t perf_id ,
1826+ rpmi_uint32_t * max_perf_limit ,
1827+ rpmi_uint32_t * min_perf_limit );
1828+
1829+ /**
1830+ * Set perf limit
1831+ **/
1832+ enum rpmi_error (* set_limit )(void * priv ,
1833+ rpmi_uint32_t perf_id ,
1834+ rpmi_uint32_t max_perf_limit ,
1835+ rpmi_uint32_t min_perf_limit );
1836+ };
1837+
1838+ /**
1839+ * @brief Create a performance service group instance
1840+ *
1841+ * @param[in] perf_mod pointer to performance module
1842+ * @return rpmi_service_group * pointer to RPMI service group instance upon
1843+ * success and NULL upon failure
1844+ */
1845+ struct rpmi_service_group *
1846+ rpmi_service_group_perf_create (rpmi_uint32_t perf_count ,
1847+ const struct rpmi_perf_data * perf_tree_data ,
1848+ const struct rpmi_perf_platform_ops * ops ,
1849+ const struct rpmi_perf_fc_memory_region * fc_mem_region ,
1850+ void * ops_priv );
1851+
1852+ /**
1853+ * @brief Destroy(free) a performance service group instance
1854+ *
1855+ * @param[in] group pointer to RPMI service group instance
1856+ */
1857+ void rpmi_service_group_perf_destroy (struct rpmi_service_group * group );
1858+
1859+ /** @} */
1860+
16881861#endif /* __LIBRPMI_H__ */
0 commit comments