Blog
Community
Development
Documentation
CNDP
22.08.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cli_cmap.h
1
/* SPDX-License-Identifier: BSD-3-Clause
2
* Copyright (c) 2019-2022 Intel Corporation.
3
*/
4
5
#ifndef __CLI_CMAP_H
6
#define __CLI_CMAP_H
7
8
#include <stdint.h>
// for uint16_t, uint8_t, uint32_t
9
10
#include "
cne_common.h
"
// for CNDP_API
11
12
#define MAX_LINE_SIZE 4096
13
14
#define PROC_CPUINFO "/proc/cpuinfo"
15
16
typedef
union
{
17
struct
{
18
uint8_t lid;
/* Logical core ID */
19
uint8_t sid;
/* CPU socket ID */
20
uint8_t cid;
/* Physical CPU core ID */
21
uint8_t tid;
/* Hyper-thread ID */
22
};
23
uint32_t word;
24
} lc_info_t;
25
26
typedef
struct
lcore {
27
struct
lcore *next;
28
lc_info_t u;
29
} lcore_t;
30
31
struct
cmap {
32
uint16_t num_cores;
33
uint16_t sid_cnt;
34
uint16_t cid_cnt;
35
uint16_t tid_cnt;
36
lc_info_t *linfo;
37
char
*model;
38
int
cache_size;
39
};
40
41
typedef
lcore_t *(*do_line_fn)(
const
char
*line, lcore_t *);
42
typedef
unsigned (*getter_fn)(
const
lcore_t *);
43
typedef
void (*setter_fn)(lcore_t *,
unsigned
new_val);
44
45
typedef
struct
action {
46
const
char
*desc;
47
do_line_fn fn;
48
} action_t;
49
56
CNDP_API
struct
cmap *cmap_create(
void
);
57
64
CNDP_API
char
*cmap_cpu_model(
void
);
65
72
CNDP_API
void
cmap_free(
struct
cmap *cmap);
73
82
static
inline
unsigned
int
83
cmap_socket_id(
const
lcore_t *lc)
84
{
85
return
lc->u.sid;
86
}
87
98
static
inline
void
99
cmap_set_socket_id(lcore_t *lc,
unsigned
v)
100
{
101
lc->u.sid = v;
102
}
103
112
static
inline
unsigned
int
113
cmap_core_id(
const
lcore_t *lc)
114
{
115
return
lc->u.cid;
116
}
117
128
static
inline
void
129
cmap_set_core_id(lcore_t *lc,
unsigned
v)
130
{
131
lc->u.cid = v;
132
}
133
142
static
inline
unsigned
int
143
cmap_thread_id(
const
lcore_t *lc)
144
{
145
return
lc->u.tid;
146
}
147
156
static
inline
unsigned
int
157
cmap_cnt(lcore_t *lc, getter_fn get)
158
{
159
unsigned
cnt = 0;
160
161
if
(!get)
162
return
cnt;
163
164
while
(lc) {
165
if
(cnt < get(lc))
166
cnt = get(lc);
167
lc = lc->next;
168
}
169
return
cnt + 1;
170
}
171
172
#endif
/*_CLI_CMAP_H */
cne_common.h
lib
usr
app
cli
cli_cmap.h
Generated by
1.18.0