linux/include/linux/intel_rapl.h

/* SPDX-License-Identifier: GPL-2.0 */
/*
 *  Data types and headers for RAPL support
 *
 *  Copyright (C) 2019  Intel Corporation.
 *
 *  Author: Zhang Rui <[email protected]>
 */

#ifndef __INTEL_RAPL_H__
#define __INTEL_RAPL_H__

#include <linux/types.h>
#include <linux/powercap.h>
#include <linux/cpuhotplug.h>

enum rapl_if_type {};

enum rapl_domain_type {};

enum rapl_domain_reg_id {};

struct rapl_domain;

enum rapl_primitives {};

struct rapl_domain_data {};

#define NR_POWER_LIMITS

struct rapl_power_limit {};

struct rapl_package;

#define RAPL_DOMAIN_NAME_LENGTH

rapl_reg;

struct rapl_domain {};

struct reg_action {};

/**
 * struct rapl_if_priv: private data for different RAPL interfaces
 * @control_type:		Each RAPL interface must have its own powercap
 *				control type.
 * @platform_rapl_domain:	Optional. Some RAPL interface may have platform
 *				level RAPL control.
 * @pcap_rapl_online:		CPU hotplug state for each RAPL interface.
 * @reg_unit:			Register for getting energy/power/time unit.
 * @regs:			Register sets for different RAPL Domains.
 * @limits:			Number of power limits supported by each domain.
 * @read_raw:			Callback for reading RAPL interface specific
 *				registers.
 * @write_raw:			Callback for writing RAPL interface specific
 *				registers.
 * @defaults:			internal pointer to interface default settings
 * @rpi:			internal pointer to interface primitive info
 */
struct rapl_if_priv {};

#ifdef CONFIG_PERF_EVENTS
/**
 * struct rapl_package_pmu_data: Per package data for PMU support
 * @scale:		Scale of 2^-32 Joules for each energy counter increase.
 * @lock:		Lock to protect n_active and active_list.
 * @n_active:		Number of active events.
 * @active_list:	List of active events.
 * @timer_interval:	Maximum timer expiration time before counter overflow.
 * @hrtimer:		Periodically update the counter to prevent overflow.
 */
struct rapl_package_pmu_data {};
#endif

/* maximum rapl package domain name: package-%d-die-%d */
#define PACKAGE_DOMAIN_NAME_LENGTH

struct rapl_package {};

struct rapl_package *rapl_find_package_domain_cpuslocked(int id, struct rapl_if_priv *priv,
						       bool id_is_cpu);
struct rapl_package *rapl_add_package_cpuslocked(int id, struct rapl_if_priv *priv,
						 bool id_is_cpu);
void rapl_remove_package_cpuslocked(struct rapl_package *rp);

struct rapl_package *rapl_find_package_domain(int id, struct rapl_if_priv *priv, bool id_is_cpu);
struct rapl_package *rapl_add_package(int id, struct rapl_if_priv *priv, bool id_is_cpu);
void rapl_remove_package(struct rapl_package *rp);

#ifdef CONFIG_PERF_EVENTS
int rapl_package_add_pmu(struct rapl_package *rp);
void rapl_package_remove_pmu(struct rapl_package *rp);
#else
static inline int rapl_package_add_pmu(struct rapl_package *rp) { return 0; }
static inline void rapl_package_remove_pmu(struct rapl_package *rp) { }
#endif

#endif /* __INTEL_RAPL_H__ */