62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
#ifndef _BPF_CONFIG_KERNEL_H_
|
|
#define _BPF_CONFIG_KERNEL_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include "bpf_helpers.h"
|
|
#include "bpf_config_define.h"
|
|
|
|
/******************************************************************************
|
|
* Get By KernelSpace
|
|
******************************************************************************/
|
|
|
|
static inline void bpf_config_lookup_map(struct bpf_config *config)
|
|
{
|
|
__u32 *val;
|
|
|
|
__builtin_memcpy(config->debug_log.key.str, BPF_CONFIG_KEY_DEBUG_LOG, 13);
|
|
val = (__u32 *)bpf_map_lookup_elem(&bpf_config_map, &config->debug_log.key);
|
|
if (val)
|
|
{
|
|
config->debug_log.val = *val;
|
|
}
|
|
|
|
__builtin_memcpy(config->hash_mode.key.str, BPF_CONFIG_KEY_HASH_MODE, 13);
|
|
val = (__u32 *)bpf_map_lookup_elem(&bpf_config_map, &config->hash_mode.key);
|
|
if (val)
|
|
{
|
|
config->hash_mode.val = *val;
|
|
}
|
|
|
|
__builtin_memcpy(config->queue_num.key.str, BPF_CONFIG_KEY_QUEUE_NUM, 13);
|
|
val = (__u32 *)bpf_map_lookup_elem(&bpf_config_map, &config->queue_num.key);
|
|
if (val)
|
|
{
|
|
config->queue_num.val = *val;
|
|
}
|
|
}
|
|
|
|
static inline __u32 bpf_config_get_debug_log(struct bpf_config *config)
|
|
{
|
|
return config->debug_log.val;
|
|
}
|
|
|
|
static inline __u32 bpf_config_get_hash_mode(struct bpf_config *config)
|
|
{
|
|
return config->hash_mode.val;
|
|
}
|
|
|
|
static inline __u32 bpf_config_get_queue_num(struct bpf_config *config)
|
|
{
|
|
return config->queue_num.val;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|