/*
 * BSD LICENSE
 *
 * Copyright(c) 2014-2023 Intel Corporation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *   * Neither the name of Intel Corporation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @brief Internal header file to share PQoS API lock mechanism
 * and library initialization status.
 */

#ifndef __PQOS_HOSTCAP_H__
#define __PQOS_HOSTCAP_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "pqos.h"
#include "types.h"

/**
 * @brief Modifies L3 CAT capability structure upon CDP config change
 *
 * Limited error checks done in this function and no errors reported.
 * It is up to caller to check for L3 CAT & CDP support.
 *
 * @param [in] cdp L3 cdp configuration
 */
PQOS_LOCAL void _pqos_cap_l3cdp_change(const enum pqos_cdp_config cdp);

/**
 * @brief Modifies L3 I/O RDT capability structure upon I/O RDT config change
 *
 * Limited error checks done in this function and no errors reported.
 * It is up to caller to check for L3 CAT & I/O RDT support.
 *
 * @param [in] iordt L3 I/O RDT configuration
 */
void _pqos_cap_l3iordt_change(const enum pqos_iordt_config iordt);

/**
 * @brief Modifies L2 CAT capability structure upon CDP config change
 *
 * Limited error checks done in this function and no errors reported.
 * It is up to caller to check for L2 CAT & CDP support.
 *
 * @param [in] cdp L2 cdp configuration
 */
PQOS_LOCAL void _pqos_cap_l2cdp_change(const enum pqos_cdp_config cdp);

/**
 * @brief Modifies SMBA capability structure upon MBA CTRL config change
 *
 * Limited error checks done in this function and no errors reported.
 * It is up to caller to check for SMBA & CTRL support.
 *
 * @param [in] cfg SMBA CTRL configuration
 */
PQOS_LOCAL void _pqos_cap_smba_change(const enum pqos_mba_config cfg);

/**
 * @brief Modifies MBA capability structure upon MBA CTRL config change
 *
 * Limited error checks done in this function and no errors reported.
 * It is up to caller to check for MBA & CTRL support.
 *
 * @param [in] cfg MBA CTRL configuration
 */
PQOS_LOCAL void _pqos_cap_mba_change(const enum pqos_mba_config cfg);

/**
 * @brief Modifies Mon I/O RDT capability structure upon I/O RDT config change
 *
 * Limited error checks done in this function and no errors reported.
 * It is up to caller to check for MON & I/O RDT support.
 *
 * @param [in] iordt L3 I/O RDT configuration
 */
void _pqos_cap_mon_iordt_change(const enum pqos_iordt_config iordt);

/**
 * @brief Modifies Mon SNC capability structure upon SNC config change
 *
 * Limited error checks done in this function and no errors reported.
 * It is up to caller to check for MON & SNC support.
 *
 * @param [in] snc SNC configuration
 */
PQOS_LOCAL void _pqos_cap_mon_snc_change(const enum pqos_snc_config cfg);

/**
 * @brief Checks library initialization state
 *
 * @param expect expected stated of library initialization state
 *
 * @return Check status
 * @retval PQOS_RETVAL_OK state as expected
 * @retval PQOS_RETVA_ERROR state different than expected
 */
PQOS_LOCAL int _pqos_check_init(const int expect);

/**
 * @brief Internal API to retrieve PQoS interface
 *
 * @return PQoS interface
 */
PQOS_LOCAL enum pqos_interface _pqos_get_inter(void);

/**
 * @brief Internal API to retrieve PQoS system configuration
 *
 * @return PQoS system configuration
 */
PQOS_LOCAL const struct pqos_sysconfig *_pqos_get_sysconfig(void);

/**
 * @brief Internal API to retrieve PQoS capabilities data
 *
 * @return PQoS capabilities data
 */
PQOS_LOCAL const struct pqos_cap *_pqos_get_cap(void);

/**
 * @brief Internal API to retrieve CPU information
 *
 * @return CPU information
 */
PQOS_LOCAL const struct pqos_cpuinfo *_pqos_get_cpu(void);

/**
 * @brief Internal API to retrieve Device information
 *
 * @return Device information
 */
PQOS_LOCAL const struct pqos_devinfo *_pqos_get_dev(void);

/**
 * @brief Returns value of L3 Non-Contiguous CBM(Cache Bit Mask) support
 *
 * @return Operation status
 * @retval struct pqos_cap_l3ca member non_contiguous_cbm on success
 */
PQOS_LOCAL int cap_get_l3ca_non_contignous(void);

/**
 * @brief Returns value of L2 Non-Contiguous CBM(Cache Bit Mask) support
 *
 * @return Operation status
 * @retval struct pqos_cap_l2ca member non_contiguous_cbm on success
 */
PQOS_LOCAL int cap_get_l2ca_non_contignous(void);

#ifdef __cplusplus
}
#endif

#endif /* __PQOS_HOSTCAP_H__ */
