Blame lib/monitoring.h

Packit bcb633
/*
Packit bcb633
 * BSD LICENSE
Packit bcb633
 *
Packit bcb633
 * Copyright(c) 2014-2017 Intel Corporation. All rights reserved.
Packit bcb633
 * All rights reserved.
Packit bcb633
 *
Packit bcb633
 * Redistribution and use in source and binary forms, with or without
Packit bcb633
 * modification, are permitted provided that the following conditions
Packit bcb633
 * are met:
Packit bcb633
 *
Packit bcb633
 *   * Redistributions of source code must retain the above copyright
Packit bcb633
 *     notice, this list of conditions and the following disclaimer.
Packit bcb633
 *   * Redistributions in binary form must reproduce the above copyright
Packit bcb633
 *     notice, this list of conditions and the following disclaimer in
Packit bcb633
 *     the documentation and/or other materials provided with the
Packit bcb633
 *     distribution.
Packit bcb633
 *   * Neither the name of Intel Corporation nor the names of its
Packit bcb633
 *     contributors may be used to endorse or promote products derived
Packit bcb633
 *     from this software without specific prior written permission.
Packit bcb633
 *
Packit bcb633
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit bcb633
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit bcb633
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit bcb633
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
Packit bcb633
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
Packit bcb633
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit bcb633
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
Packit bcb633
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Packit bcb633
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Packit bcb633
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit bcb633
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit bcb633
 *
Packit bcb633
 */
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Internal header file to PQoS monitoring initialization
Packit bcb633
 */
Packit bcb633
Packit bcb633
#ifndef __PQOS_HOSTMON_H__
Packit bcb633
#define __PQOS_HOSTMON_H__
Packit bcb633
Packit bcb633
#ifdef __cplusplus
Packit bcb633
extern "C" {
Packit bcb633
#endif
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Initializes monitoring sub-module of the library (CMT)
Packit bcb633
 *
Packit bcb633
 * @param cpu cpu topology structure
Packit bcb633
 * @param cap capabilities structure
Packit bcb633
 * @param cfg library configuration structure
Packit bcb633
 *
Packit bcb633
 * @return Operation status
Packit bcb633
 * @retval PQOS_RETVAL_OK success
Packit bcb633
 */
Packit bcb633
int pqos_mon_init(const struct pqos_cpuinfo *cpu,
Packit bcb633
                  const struct pqos_cap *cap,
Packit bcb633
                  const struct pqos_config *cfg);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Shuts down monitoring sub-module of the library
Packit bcb633
 *
Packit bcb633
 * @return Operation status
Packit bcb633
 */
Packit bcb633
int pqos_mon_fini(void);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Initializes hardware monitoring sub-module of the library (CMT)
Packit bcb633
 *
Packit bcb633
 * @param cpu cpu topology structure
Packit bcb633
 * @param cap capabilities structure
Packit bcb633
 * @param cfg library configuration structure
Packit bcb633
 *
Packit bcb633
 * @return Operation status
Packit bcb633
 * @retval PQOS_RETVAL_OK success
Packit bcb633
 */
Packit bcb633
int hw_mon_init(const struct pqos_cpuinfo *cpu,
Packit bcb633
                  const struct pqos_cap *cap,
Packit bcb633
                  const struct pqos_config *cfg);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Shuts down hardware monitoring sub-module of the library
Packit bcb633
 *
Packit bcb633
 * @return Operation status
Packit bcb633
 */
Packit bcb633
int hw_mon_fini(void);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Hardware interface to reset monitoring by binding all cores with RMID0
Packit bcb633
 *
Packit bcb633
 * @return Operations status
Packit bcb633
 * @retval PQOS_RETVAL_OK on success
Packit bcb633
 */
Packit bcb633
int hw_mon_reset(void);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Hardware interface to read RMID association of the \a lcore
Packit bcb633
 *
Packit bcb633
 * @param [in] lcore CPU logical core id
Packit bcb633
 * @param [out] rmid place to store resource monitoring id
Packit bcb633
 *
Packit bcb633
 * @return Operations status
Packit bcb633
 * @retval PQOS_RETVAL_OK on success
Packit bcb633
 */
Packit bcb633
int hw_mon_assoc_get(const unsigned lcore,
Packit bcb633
                     pqos_rmid_t *rmid);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Hardware interface to start resource monitoring on selected
Packit bcb633
 * group of cores
Packit bcb633
 *
Packit bcb633
 * The function sets up content of the \a group structure.
Packit bcb633
 *
Packit bcb633
 * Note that \a event cannot select PQOS_PERF_EVENT_IPC or
Packit bcb633
 * PQOS_PERF_EVENT_L3_MISS events without any PQoS event
Packit bcb633
 * selected at the same time.
Packit bcb633
 *
Packit bcb633
 * @param [in] num_cores number of cores in \a cores array
Packit bcb633
 * @param [in] cores array of logical core id's
Packit bcb633
 * @param [in] event combination of monitoring events
Packit bcb633
 * @param [in] context a pointer for application's convenience
Packit bcb633
 *            (unused by the library)
Packit bcb633
 * @param [in,out] group a pointer to monitoring structure
Packit bcb633
 *
Packit bcb633
 * @return Operations status
Packit bcb633
 * @retval PQOS_RETVAL_OK on success
Packit bcb633
 */
Packit bcb633
int hw_mon_start(const unsigned num_cores,
Packit bcb633
                 const unsigned *cores,
Packit bcb633
                 const enum pqos_mon_event event,
Packit bcb633
                 void *context,
Packit bcb633
                 struct pqos_mon_data *group);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Hardware interface to stop resource monitoring data for selected
Packit bcb633
 * monitoring group
Packit bcb633
 *
Packit bcb633
 * @param [in] group monitoring context for selected number of cores
Packit bcb633
 *
Packit bcb633
 * @return Operations status
Packit bcb633
 * @retval PQOS_RETVAL_OK on success
Packit bcb633
 */
Packit bcb633
int hw_mon_stop(struct pqos_mon_data *group);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Hardware interface poll monitoring data from requested cores
Packit bcb633
 *
Packit bcb633
 * @param [in] groups table of monitoring group pointers to be be updated
Packit bcb633
 * @param [in] num_groups number of monitoring groups in the table
Packit bcb633
 *
Packit bcb633
 * @return Operations status
Packit bcb633
 * @retval PQOS_RETVAL_OK on success
Packit bcb633
 */
Packit bcb633
int hw_mon_poll(struct pqos_mon_data **groups,
Packit bcb633
                const unsigned num_groups);
Packit bcb633
Packit bcb633
/*
Packit bcb633
 * =======================================
Packit bcb633
 * Allocation Technology
Packit bcb633
 * =======================================
Packit bcb633
 */
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Hardware interface to associate \a lcore with given class of service
Packit bcb633
 *
Packit bcb633
 * @param [in] lcore CPU logical core id
Packit bcb633
 * @param [in] class_id class of service
Packit bcb633
 *
Packit bcb633
 * @return Operations status
Packit bcb633
 */
Packit bcb633
int hw_alloc_assoc_set(const unsigned lcore,
Packit bcb633
                       const unsigned class_id);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Hardware interface to read association of \a lcore with
Packit bcb633
 * class of service
Packit bcb633
 *
Packit bcb633
 * @param [in] lcore CPU logical core id
Packit bcb633
 * @param [out] class_id class of service
Packit bcb633
 *
Packit bcb633
 * @return Operations status
Packit bcb633
 * @retval PQOS_RETVAL_OK on success
Packit bcb633
 */
Packit bcb633
int hw_alloc_assoc_get(const unsigned lcore,
Packit bcb633
                       unsigned *class_id);
Packit bcb633
Packit bcb633
#ifdef __cplusplus
Packit bcb633
}
Packit bcb633
#endif
Packit bcb633
Packit bcb633
#endif /* __PQOS_HOSTMON_H__ */