per Intel policy to include file commit date using git cmd below. The policy does not apply to non-Intel (C) notices. git log --follow -C90% --format=%ad --date default <file> | tail -1 and then pull just the 4 digit year from the result. Intel copyrights were not added to files where Intel either had no contribution ot the contribution lacked substance (ie license header updates, formatting changes, etc). Contribution date used "--follow -C95%" to get the most accurate date. Note that several files in this patch didn't end the license/(c) block with a blank comment line so these were added as the vast majority of files do have this last blank line. Simply there for consistency. Signed-off-by: paul luse <paul.e.luse@intel.com> Change-Id: Id5b7ce4f658fe87132f14139ead58d6e285c04d4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15192 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Community-CI: Mellanox Build Bot
155 lines
3.7 KiB
C
155 lines
3.7 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright (C) 2017 Intel Corporation.
|
|
* All rights reserved.
|
|
*/
|
|
|
|
/**
|
|
* \file
|
|
* CPU set management functions
|
|
*/
|
|
|
|
#ifndef SPDK_CPUSET_H
|
|
#define SPDK_CPUSET_H
|
|
|
|
#include "spdk/stdinc.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define SPDK_CPUSET_SIZE 1024
|
|
|
|
/**
|
|
* List of CPUs.
|
|
*/
|
|
struct spdk_cpuset {
|
|
char str[SPDK_CPUSET_SIZE / 4 + 1];
|
|
uint8_t cpus[SPDK_CPUSET_SIZE / 8];
|
|
};
|
|
|
|
/**
|
|
* Allocate CPU set object.
|
|
*
|
|
* \return a pointer to the allocated zeroed cpuset on success, or NULL on failure.
|
|
*/
|
|
struct spdk_cpuset *spdk_cpuset_alloc(void);
|
|
|
|
/**
|
|
* Free allocated CPU set.
|
|
*
|
|
* \param set CPU set to be freed.
|
|
*/
|
|
void spdk_cpuset_free(struct spdk_cpuset *set);
|
|
|
|
/**
|
|
* Compare two CPU sets.
|
|
*
|
|
* \param set1 CPU set1.
|
|
* \param set2 CPU set2.
|
|
*
|
|
* \return true if both CPU sets are equal.
|
|
*/
|
|
bool spdk_cpuset_equal(const struct spdk_cpuset *set1, const struct spdk_cpuset *set2);
|
|
|
|
/**
|
|
* Copy the content of CPU set to another.
|
|
*
|
|
* \param dst Destination CPU set
|
|
* \param src Source CPU set
|
|
*/
|
|
void spdk_cpuset_copy(struct spdk_cpuset *dst, const struct spdk_cpuset *src);
|
|
|
|
/**
|
|
* Perform AND operation on two CPU sets. The result is stored in dst.
|
|
*
|
|
* \param dst First argument of operation. This value also stores the result of operation.
|
|
* \param src Second argument of operation.
|
|
*/
|
|
void spdk_cpuset_and(struct spdk_cpuset *dst, const struct spdk_cpuset *src);
|
|
|
|
/**
|
|
* Perform OR operation on two CPU sets. The result is stored in dst.
|
|
*
|
|
* \param dst First argument of operation. This value also stores the result of operation.
|
|
* \param src Second argument of operation.
|
|
*/
|
|
void spdk_cpuset_or(struct spdk_cpuset *dst, const struct spdk_cpuset *src);
|
|
|
|
/**
|
|
* Perform XOR operation on two CPU sets. The result is stored in dst.
|
|
*
|
|
* \param dst First argument of operation. This value also stores the result of operation.
|
|
* \param src Second argument of operation.
|
|
*/
|
|
void spdk_cpuset_xor(struct spdk_cpuset *dst, const struct spdk_cpuset *src);
|
|
|
|
/**
|
|
* Negate all CPUs in CPU set.
|
|
*
|
|
* \param set CPU set to be negated. This value also stores the result of operation.
|
|
*/
|
|
void spdk_cpuset_negate(struct spdk_cpuset *set);
|
|
|
|
/**
|
|
* Clear all CPUs in CPU set.
|
|
*
|
|
* \param set CPU set to be cleared.
|
|
*/
|
|
void spdk_cpuset_zero(struct spdk_cpuset *set);
|
|
|
|
/**
|
|
* Set or clear CPU state in CPU set.
|
|
*
|
|
* \param set CPU set object.
|
|
* \param cpu CPU index to be set or cleared.
|
|
* \param state *true* to set cpu, *false* to clear.
|
|
*/
|
|
void spdk_cpuset_set_cpu(struct spdk_cpuset *set, uint32_t cpu, bool state);
|
|
|
|
/**
|
|
* Get the state of CPU in CPU set.
|
|
*
|
|
* \param set CPU set object.
|
|
* \param cpu CPU index.
|
|
*
|
|
* \return the state of selected CPU.
|
|
*/
|
|
bool spdk_cpuset_get_cpu(const struct spdk_cpuset *set, uint32_t cpu);
|
|
|
|
/**
|
|
* Get the number of CPUs that are set in CPU set.
|
|
*
|
|
* \param set CPU set object.
|
|
*
|
|
* \return the number of CPUs.
|
|
*/
|
|
uint32_t spdk_cpuset_count(const struct spdk_cpuset *set);
|
|
|
|
/**
|
|
* Convert a CPU set to hex string.
|
|
*
|
|
* \param set CPU set.
|
|
*
|
|
* \return a pointer to hexadecimal representation of CPU set. Buffer to store a
|
|
* string is dynamically allocated internally and freed with CPU set object.
|
|
* Memory returned by this function might be changed after subsequent calls to
|
|
* this function so string should be copied by user.
|
|
*/
|
|
const char *spdk_cpuset_fmt(struct spdk_cpuset *set);
|
|
|
|
/**
|
|
* Convert a string containing a CPU core mask into a CPU set.
|
|
*
|
|
* \param set CPU set.
|
|
* \param mask String defining CPU set. By default hexadecimal value is used or
|
|
* as CPU list enclosed in square brackets defined as: 'c1[-c2][,c3[-c4],...]'.
|
|
*
|
|
* \return zero if success, non zero if fails.
|
|
*/
|
|
int spdk_cpuset_parse(struct spdk_cpuset *set, const char *mask);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif /* SPDK_CPUSET_H */
|