16 #include <sys/socket.h>
17 #include <sys/queue.h>
19 #include <bsd/sys/bitstring.h>
20 #include <json-c/json_object.h>
21 #include <json-c/json_tokener.h>
22 #include <json-c/json_util.h>
23 #include <json-c/json_visit.h>
24 #include <json-c/linkhash.h>
31 #define DEFAULT_CHUNK_SIZE 1024
32 #define UMEM_MAX_REGIONS 128
33 #define JCFG_MAX_STRING_SIZE 32
44 #define APP_TAG "application"
45 #define DEFAULT_TAG "defaults"
46 #define OPTION_TAG "options"
47 #define UMEM_TAG "umems"
48 #define LPORT_TAG "lports"
49 #define LGROUP_TAG "lcore-groups"
50 #define THREAD_TAG "threads"
51 #define LPORT_GROUP_TAG "lport-groups"
52 #define USER_TAG "users"
59 #define JCFG_TAG_NAMES \
61 APP_TAG, DEFAULT_TAG, OPTION_TAG, UMEM_TAG, LPORT_TAG, LGROUP_TAG, THREAD_TAG, \
62 LPORT_GROUP_TAG, USER_TAG, \
114 #define JCFG_COMMON_HDR(_t) \
115 STAILQ_ENTRY(_t) next; \
119 jcfg_cb_type_t cbtype
136 typedef struct region_info {
178 #define JCFG_LPORT_PMD_NAME "pmd"
179 #define JCFG_LPORT_UMEM_NAME "umem"
180 #define JCFG_LPORT_REGION_NAME "region"
181 #define JCFG_LPORT_QID_NAME "qid"
182 #define JCFG_LPORT_DESCRIPTION_NAME "description"
183 #define JCFG_LPORT_DESC_NAME "desc"
184 #define JCFG_LPORT_BUSY_POLL_NAME "busy_poll"
185 #define JCFG_LPORT_BUSY_POLLING_NAME "busy_polling"
186 #define JCFG_LPORT_BUSY_TIMEOUT_NAME "busy_timeout"
187 #define JCFG_LPORT_BUSY_BUDGET_NAME "busy_budget"
188 #define JCFG_LPORT_UNPRIVILEGED_NAME "unprivileged"
189 #define JCFG_LPORT_FORCE_WAKEUP_NAME "force_wakeup"
190 #define JCFG_LPORT_SKB_MODE_NAME "skb_mode"
241 #define JCFG_LPORT_GROUP_NETDEV_NAMES_NAME "netdevs"
242 #define JCFG_LPORT_GROUP_QUEUES_NAME "queues"
243 #define JCFG_LPORT_GROUP_THREAD_NAMES_NAME "threads"
332 struct sockaddr_un
sun;
388 #define jcfg_application_foreach(j, f, a) jcfg_object_foreach(j, JCFG_APPLICATION_TYPE, f, a)
389 #define jcfg_defaults_foreach(j, f, a) jcfg_object_foreach(j, JCFG_DEFAULT_TYPE, f, a)
390 #define jcfg_option_foreach(j, f, a) jcfg_object_foreach(j, JCFG_OPTION_TYPE, f, a)
391 #define jcfg_umem_foreach(j, f, a) jcfg_object_foreach(j, JCFG_UMEM_TYPE, f, a)
392 #define jcfg_lport_foreach(j, f, a) jcfg_object_foreach(j, JCFG_LPORT_TYPE, f, a)
393 #define jcfg_lgroup_foreach(j, f, a) jcfg_object_foreach(j, JCFG_LGROUP_TYPE, f, a)
394 #define jcfg_thread_foreach(j, f, a) jcfg_object_foreach(j, JCFG_THREAD_TYPE, f, a)
395 #define jcfg_lport_group_foreach(j, f, a) jcfg_object_foreach(j, JCFG_LPORT_GROUP_TYPE, f, a)
396 #define jcfg_user_foreach(j, f, a) jcfg_object_foreach(j, JCFG_USER_TYPE, f, a)
412 #define jcfg_lookup_option(j, n) (jcfg_opt_t *)jcfg_object_lookup(j, JCFG_OPTION_TYPE, n)
413 #define jcfg_lookup_default(j, n) (jcfg_opt_t *)jcfg_object_lookup(j, JCFG_DEFAULT_TYPE, n)
414 #define jcfg_lookup_application(j, n) (jcfg_opt_t *)jcfg_object_lookup(j, JCFG_APPLICATION_TYPE, n)
415 #define jcfg_lookup_umem(j, n) (jcfg_umem_t *)jcfg_object_lookup(j, JCFG_UMEM_TYPE, n)
416 #define jcfg_lookup_lport(j, n) (jcfg_lport_t *)jcfg_object_lookup(j, JCFG_LPORT_TYPE, n)
417 #define jcfg_lookup_lport(j, n) (jcfg_lport_t *)jcfg_object_lookup(j, JCFG_LPORT_TYPE, n)
418 #define jcfg_lookup_lgroup(j, n) (jcfg_lgroup_t *)jcfg_object_lookup(j, JCFG_LGROUP_TYPE, n)
419 #define jcfg_lookup_thread(j, n) (jcfg_thd_t *)jcfg_object_lookup(j, JCFG_THREAD_TYPE, n)
420 #define jcfg_lookup_lport_group(j, n) \
421 (jcfg_lport_group_t *)jcfg_object_lookup(j, JCFG_LPORT_GROUP_TYPE, n)
422 #define jcfg_lookup_user(j, n) (jcfg_user_t *)jcfg_object_lookup(j, JCFG_USER_TYPE, n)
439 #define jcfg_num_applications(j) jcfg_num_objects(j, JCFG_APPLICATION_TYPE)
440 #define jcfg_num_defaults(j) jcfg_num_objects(j, JCFG_DEFAULT_TYPE)
441 #define jcfg_num_options(j) jcfg_num_objects(j, JCFG_OPTION_TYPE)
442 #define jcfg_num_lports(j) jcfg_num_objects(j, JCFG_LPORT_TYPE)
443 #define jcfg_num_lgroups(j) jcfg_num_objects(j, JCFG_LGROUP_TYPE)
444 #define jcfg_num_threads(j) jcfg_num_objects(j, JCFG_THREAD_TYPE)
445 #define jcfg_num_lport_groups(j) jcfg_num_objects(j, JCFG_LPORT_GROUP_TYPE)
446 #define jcfg_num_umems(j) jcfg_num_objects(j, JCFG_UMEM_TYPE)
693 CNDP_API
int jcfg_add_decoder(
const char *section, json_c_visit_userfunc *func);
CNDP_API int jcfg_default_get(jcfg_info_t *jinfo, const char *name, uint64_t *val)
CNDP_API int jcfg_option_array_get(jcfg_info_t *jinfo, const char *name, obj_value_t **val_arr)
CNDP_API jcfg_info_t * jcfg_parser(int flags, const char *s)
CNDP_API int jcfg_option_get(jcfg_info_t *jinfo, const char *name, uint64_t *val)
static int jcfg_default_get_u32(jcfg_info_t *jinfo, const char *name, uint32_t *v)
CNDP_API int jcfg_num_objects(jcfg_info_t *jinfo, jcfg_cb_type_t cbtype)
struct jcfg_thd jcfg_thd_t
CNDP_API void jcfg_dump_info(void)
CNDP_API int jcfg_default_array_get(jcfg_info_t *jinfo, const char *name, obj_value_t **val_arr)
CNDP_API jcfg_thd_t * jcfg_thd_by_index(jcfg_info_t *jinfo, int idx)
int jcfg_parse_cb_t(struct jcfg_info_s *jinfo, void *obj, void *arg, int idx)
CNDP_API int jcfg_socket_create(jcfg_info_t *jinfo, const char *runtime_dir)
int jcfg_cb_t(jcfg_info_t *jinfo, void *obj, void *arg, int idx)
static int jcfg_default_get_bool(jcfg_info_t *jinfo, const char *name, uint32_t *v)
CNDP_API int jcfg_object_foreach(jcfg_info_t *jinfo, jcfg_cb_type_t cbtype, jcfg_cb_t *func, void *arg)
static int jcfg_default_get_u16(jcfg_info_t *jinfo, const char *name, uint16_t *v)
CNDP_API int jcfg_dump_object(struct json_object *obj)
struct jcfg_opt jcfg_opt_t
CNDP_API int jcfg_decode(jcfg_info_t *jinfo, const char *key, void *arg)
CNDP_API int jcfg_dump(jcfg_info_t *jinfo)
struct obj_value obj_value_t
struct jcfg_lport_group jcfg_lport_group_t
CNDP_API struct json_object * jcfg_object_by_name(jcfg_info_t *jinfo, const char *key)
CNDP_API json_c_visit_userfunc * jcfg_get_decoder(const char *section)
struct jcfg_info_s jcfg_info_t
struct jcfg_user jcfg_user_t
CNDP_API int jcfg_del_decoder(const char *section)
CNDP_API int jcfg_json_string_set(jcfg_info_t *jinfo, const char *str)
CNDP_API char * jcfg_lport_region(jcfg_lport_t *lport, uint32_t *objcnt)
CNDP_API jcfg_lport_t * jcfg_lport_by_index(jcfg_info_t *jinfo, int idx)
struct jcfg_lport jcfg_lport_t
CNDP_API jcfg_data_t * jcfg_get_data(jcfg_info_t *jinfo)
CNDP_API void * jcfg_object_lookup(jcfg_info_t *jinfo, jcfg_cb_type_t cbtype, const char *name)
CNDP_API void jcfg_destroy(jcfg_info_t *jinfo)
CNDP_API int jcfg_dump_at(jcfg_info_t *jinfo, const char *key)
struct jcfg_hdr jcfg_hdr_t
CNDP_API void jcfg_socket_destroy(jcfg_info_t *jinfo)
struct jcfg_list jcfg_list_t
CNDP_API int jcfg_add_decoder(const char *section, json_c_visit_userfunc *func)
CNDP_API jcfg_umem_t * jcfg_umem_by_index(jcfg_info_t *jinfo, int idx)
struct jcfg_umem jcfg_umem_t
struct jcfg_data jcfg_data_t
static int jcfg_option_get_string(jcfg_info_t *jinfo, const char *name, char **v)
struct jcfg_lgroup jcfg_lgroup_t
static int jcfg_default_get_string(jcfg_info_t *jinfo, const char *name, char **v)
STAILQ_HEAD(, jcfg_umem) umems
STAILQ_HEAD(, jcfg_lport) lports
STAILQ_HEAD(, jcfg_opt) application
STAILQ_HEAD(, jcfg_opt) defaults
JCFG_COMMON_HDR(jcfg_hdr)
JCFG_COMMON_HDR(jcfg_lgroup)
JCFG_COMMON_HDR(jcfg_lport_group)
JCFG_COMMON_HDR(jcfg_lport)
JCFG_COMMON_HDR(jcfg_opt)
JCFG_COMMON_HDR(jcfg_thd)
JCFG_COMMON_HDR(jcfg_umem)
JCFG_COMMON_HDR(jcfg_user)