Blame pqos/main.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
 * @brief Platform QoS utility - main module
Packit bcb633
 */
Packit bcb633
Packit bcb633
#ifndef __MAIN_H__
Packit bcb633
#define __MAIN_H__
Packit bcb633
Packit bcb633
#ifdef DEBUG
Packit bcb633
#include <assert.h>
Packit bcb633
#endif
Packit bcb633
Packit bcb633
#ifdef __cplusplus
Packit bcb633
extern "C" {
Packit bcb633
#endif
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * Macros
Packit bcb633
 */
Packit bcb633
#ifndef DIM
Packit bcb633
#define DIM(x) (sizeof(x)/sizeof(x[0]))
Packit bcb633
#endif
Packit bcb633
#ifndef MAX
Packit bcb633
/**
Packit bcb633
 * Macro to return the maximum of two numbers
Packit bcb633
 */
Packit bcb633
#define MAX(a, b) ({ \
Packit bcb633
        typeof(a) _a = (a); \
Packit bcb633
        typeof(b) _b = (b); \
Packit bcb633
        _a > _b ? _a : _b; \
Packit bcb633
})
Packit bcb633
#endif /* !MAX */
Packit bcb633
Packit bcb633
#ifdef DEBUG
Packit bcb633
#define ASSERT assert
Packit bcb633
#else
Packit bcb633
#define ASSERT(x)
Packit bcb633
#endif
Packit bcb633
Packit bcb633
#define UNUSED_ARG(_x) ((void)(_x))
Packit bcb633
Packit bcb633
#define PQOS_MAX_SOCKETS      8
Packit bcb633
#define PQOS_MAX_L2IDS        32
Packit bcb633
#define PQOS_MAX_SOCKET_CORES 64
Packit bcb633
#define PQOS_MAX_CORES        (PQOS_MAX_SOCKET_CORES*PQOS_MAX_SOCKETS)
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * Maintains alloc option - allocate cores or task id's
Packit bcb633
 */
Packit bcb633
extern int alloc_pid_flag;
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * Selected library interface
Packit bcb633
 */
Packit bcb633
extern enum pqos_interface sel_interface;
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Converts string into 64-bit unsigned number.
Packit bcb633
 *
Packit bcb633
 * Numbers can be in decimal or hexadecimal format.
Packit bcb633
 *
Packit bcb633
 * On error, this functions causes process to exit with FAILURE code.
Packit bcb633
 *
Packit bcb633
 * @param s string to be converted into 64-bit unsigned number
Packit bcb633
 *
Packit bcb633
 * @return Numeric value of the string representing the number
Packit bcb633
 */
Packit bcb633
uint64_t
Packit bcb633
strtouint64(const char *s);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Converts string of characters representing list of
Packit bcb633
 *        numbers into table of numbers.
Packit bcb633
 *
Packit bcb633
 * Allowed formats are:
Packit bcb633
 *     0,1,2,3
Packit bcb633
 *     0-10,20-18
Packit bcb633
 *     1,3,5-8,10,0x10-12
Packit bcb633
 *
Packit bcb633
 * Numbers can be in decimal or hexadecimal format.
Packit bcb633
 *
Packit bcb633
 * On error, this functions causes process to exit with FAILURE code.
Packit bcb633
 *
Packit bcb633
 * @param s string representing list of unsigned numbers.
Packit bcb633
 * @param tab table to put converted numeric values into
Packit bcb633
 * @param max maximum number of elements that \a tab can accommodate
Packit bcb633
 *
Packit bcb633
 * @return Number of elements placed into \a tab
Packit bcb633
 */
Packit bcb633
unsigned
Packit bcb633
strlisttotab(char *s, uint64_t *tab, const unsigned max);
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Common function to handle string parsing errors
Packit bcb633
 *
Packit bcb633
 * On error, this function causes process to exit with FAILURE code.
Packit bcb633
 *
Packit bcb633
 * @param arg string that caused error when parsing
Packit bcb633
 * @param note context and information about encountered error
Packit bcb633
 */
Packit bcb633
void parse_error(const char *arg, const char *note) __attribute__ ((noreturn));
Packit bcb633
Packit bcb633
/**
Packit bcb633
 * @brief Duplicates \a arg and stores at \a sel
Packit bcb633
 *
Packit bcb633
 * @param sel place to store duplicate of \a arg
Packit bcb633
 * @param arg string passed through command line option
Packit bcb633
 */
Packit bcb633
void selfn_strdup(char **sel, const char *arg);
Packit bcb633
Packit bcb633
Packit bcb633
#ifdef __cplusplus
Packit bcb633
}
Packit bcb633
#endif
Packit bcb633
Packit bcb633
#endif /* __MAIN_H__ */