a7d0e7ea86aae5636dfeac095e408c32d5d7d59b
[samplevnf.git] / VNFs / DPPD-PROX / prox_cfg.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _PROX_CFG_H
18 #define _PROX_CFG_H
19
20 #include <inttypes.h>
21
22 #include "prox_globals.h"
23
24 #define PROX_CM_STR_LEN (2 + 2 * sizeof(prox_cfg.core_mask) + 1)
25 #define PROX_CM_DIM     (RTE_MAX_LCORE/(sizeof(uint64_t) * 8))
26
27 #define DSF_AUTOSTART             0x00000001      /* start all cores automatically */
28 #define DSF_CHECK_INIT            0x00000002      /* check initialization sequence and exit */
29 #define DSF_CHECK_SYNTAX          0x00000004      /* check configuration file syntax and exit */
30 #define DSF_SHUFFLE               0x00000008      /* shuffle memory addresses within memory pool */
31 #define DSF_WAIT_ON_QUIT          0x00000010      /* wait for all cores to stop before exiting */
32 #define DSF_LISTEN_TCP            0x00000020      /* Listen on TCP port 8474 for input */
33 #define DSF_LISTEN_UDS            0x00000040      /* Listen on /tmp/prox.sock for input */
34 #define DSF_DAEMON                0x00000080      /* Run process as Daemon */
35 #define UNIQUE_MEMPOOL_PER_SOCKET 0x00000100      /* Use Only one mempool per socket, shared between all cores on that socket */
36 #define DSF_KEEP_SRC_MAC          0x00000200      /* In gen mode, do not overwrite src_mac by mac of physical port */
37 #define DSF_MP_RINGS              0x00000400      /* Use Multi Producer rings when possible */
38 #define DSF_USE_DUMMY_DEVICES     0x00000800      /* Instead of relying on real PCI devices, create null devices instead */
39 #define DSF_USE_DUMMY_CPU_TOPO    0x00001000      /* Instead of relying on the cpu topology, load a cpu toplogy that will work with all cfgs. */
40 #define DSF_DISABLE_CMT           0x00002000      /* CMT disabled */
41 #define DSF_LIST_TASK_MODES       0x00004000      /* list supported task modes and exit */
42 #define DSF_ENABLE_BYPASS         0x00008000      /* Use Multi Producer rings to enable ring bypass */
43
44 #define MAX_PATH_LEN 1024
45
46 enum prox_ui {
47         PROX_UI_CURSES,
48         PROX_UI_CLI,
49         PROX_UI_NONE,
50 };
51
52 struct prox_cfg {
53         enum prox_ui    ui;             /* By default, curses is used as a UI. */
54         char            update_interval_str[16];
55         int             use_stats_logger;
56         uint32_t        flags;          /* TGSF_* flags above */
57         uint32_t        master;         /* master core to run user interface on */
58         uint64_t        core_mask[PROX_CM_DIM]; /* Active cores without master core */
59         uint32_t        start_time;     /* if set (not 0), average pps will be calculated starting after start_time seconds */
60         uint32_t        duration_time;      /* if set (not 0), prox will exit duration_time seconds after start_time */
61         char            name[MAX_NAME_SIZE];
62         uint8_t         log_name_pid;
63         char            log_name[MAX_PATH_LEN];
64         int32_t         cpe_table_ports[PROX_MAX_PORTS];
65         uint32_t        logbuf_size;
66         uint32_t        logbuf_pos;
67         char            *logbuf;
68 };
69
70 extern struct prox_cfg prox_cfg;
71
72 int prox_core_active(const uint32_t lcore_id, const int with_master);
73
74 /* Returns non-zero if supplied lcore_id is the last active core. The
75    first core can be found by setting *lcore_id == -1. The function is
76    indented to be used as an interator. */
77 int prox_core_next(uint32_t *lcore_id, const int with_master);
78
79 int prox_core_to_hex(char *dst, const size_t size, const int with_master);
80
81 int prox_core_to_str(char *dst, const size_t size, const int with_master);
82
83 void prox_core_clr(void);
84
85 int prox_core_set_active(const uint32_t lcore_id);
86
87 #endif /* __PROX_CFG_H_ */