aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-07-19 15:23:51 -0700
committerFlorin Coras <florin.coras@gmail.com>2021-07-19 22:22:12 +0000
commitbbc8faebf13f2db7299c948c441b526419fefe09 (patch)
tree6807dd45deea24b475d47b7f9d3ad1850c3be21a /src/vnet
parent05b5a5b3b4b04823776feed6403b5a99b2e06d76 (diff)
session: option to use memfd segs for builtin apps
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Iecb171c9451c0fa9a7c6ae4b3e9ab7774a4fe585
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application.c65
-rw-r--r--src/vnet/session/application_interface.h19
2 files changed, 43 insertions, 41 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index d7c5980774b..7fe81885725 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -769,18 +769,19 @@ application_alloc_and_init (app_init_args_t * a)
ssvm_segment_type_t seg_type = SSVM_SEGMENT_MEMFD;
segment_manager_props_t *props;
application_t *app;
- u64 *options;
+ u64 *opts;
app = application_alloc ();
- options = a->options;
+ opts = a->options;
/*
* Make sure we support the requested configuration
*/
- if (options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_IS_BUILTIN)
+ if ((opts[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_IS_BUILTIN) &&
+ !(opts[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_MEMFD_FOR_BUILTIN))
seg_type = SSVM_SEGMENT_PRIVATE;
- if ((options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
- && seg_type != SSVM_SEGMENT_MEMFD)
+ if ((opts[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD) &&
+ seg_type != SSVM_SEGMENT_MEMFD)
{
clib_warning ("mq eventfds can only be used if socket transport is "
"used for binary api");
@@ -790,17 +791,17 @@ application_alloc_and_init (app_init_args_t * a)
if (!application_verify_cfg (seg_type))
return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
- if (options[APP_OPTIONS_PREALLOC_FIFO_PAIRS]
- && options[APP_OPTIONS_PREALLOC_FIFO_HDRS])
+ if (opts[APP_OPTIONS_PREALLOC_FIFO_PAIRS] &&
+ opts[APP_OPTIONS_PREALLOC_FIFO_HDRS])
return VNET_API_ERROR_APP_UNSUPPORTED_CFG;
/* Check that the obvious things are properly set up */
application_verify_cb_fns (a->session_cb_vft);
- app->flags = options[APP_OPTIONS_FLAGS];
+ app->flags = opts[APP_OPTIONS_FLAGS];
app->cb_fns = *a->session_cb_vft;
- app->ns_index = options[APP_OPTIONS_NAMESPACE];
- app->proxied_transports = options[APP_OPTIONS_PROXY_TRANSPORT];
+ app->ns_index = opts[APP_OPTIONS_NAMESPACE];
+ app->proxied_transports = opts[APP_OPTIONS_PROXY_TRANSPORT];
app->name = vec_dup (a->name);
/* If no scope enabled, default to global */
@@ -810,32 +811,32 @@ application_alloc_and_init (app_init_args_t * a)
props = application_segment_manager_properties (app);
segment_manager_props_init (props);
- props->segment_size = options[APP_OPTIONS_SEGMENT_SIZE];
- props->prealloc_fifos = options[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
- props->prealloc_fifo_hdrs = options[APP_OPTIONS_PREALLOC_FIFO_HDRS];
- if (options[APP_OPTIONS_ADD_SEGMENT_SIZE])
+ props->segment_size = opts[APP_OPTIONS_SEGMENT_SIZE];
+ props->prealloc_fifos = opts[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
+ props->prealloc_fifo_hdrs = opts[APP_OPTIONS_PREALLOC_FIFO_HDRS];
+ if (opts[APP_OPTIONS_ADD_SEGMENT_SIZE])
{
- props->add_segment_size = options[APP_OPTIONS_ADD_SEGMENT_SIZE];
+ props->add_segment_size = opts[APP_OPTIONS_ADD_SEGMENT_SIZE];
props->add_segment = 1;
}
- if (options[APP_OPTIONS_RX_FIFO_SIZE])
- props->rx_fifo_size = options[APP_OPTIONS_RX_FIFO_SIZE];
- if (options[APP_OPTIONS_TX_FIFO_SIZE])
- props->tx_fifo_size = options[APP_OPTIONS_TX_FIFO_SIZE];
- if (options[APP_OPTIONS_EVT_QUEUE_SIZE])
- props->evt_q_size = options[APP_OPTIONS_EVT_QUEUE_SIZE];
- if (options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
+ if (opts[APP_OPTIONS_RX_FIFO_SIZE])
+ props->rx_fifo_size = opts[APP_OPTIONS_RX_FIFO_SIZE];
+ if (opts[APP_OPTIONS_TX_FIFO_SIZE])
+ props->tx_fifo_size = opts[APP_OPTIONS_TX_FIFO_SIZE];
+ if (opts[APP_OPTIONS_EVT_QUEUE_SIZE])
+ props->evt_q_size = opts[APP_OPTIONS_EVT_QUEUE_SIZE];
+ if (opts[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
props->use_mq_eventfd = 1;
- if (options[APP_OPTIONS_TLS_ENGINE])
- app->tls_engine = options[APP_OPTIONS_TLS_ENGINE];
- if (options[APP_OPTIONS_MAX_FIFO_SIZE])
- props->max_fifo_size = options[APP_OPTIONS_MAX_FIFO_SIZE];
- if (options[APP_OPTIONS_HIGH_WATERMARK])
- props->high_watermark = options[APP_OPTIONS_HIGH_WATERMARK];
- if (options[APP_OPTIONS_LOW_WATERMARK])
- props->low_watermark = options[APP_OPTIONS_LOW_WATERMARK];
- if (options[APP_OPTIONS_PCT_FIRST_ALLOC])
- props->pct_first_alloc = options[APP_OPTIONS_PCT_FIRST_ALLOC];
+ if (opts[APP_OPTIONS_TLS_ENGINE])
+ app->tls_engine = opts[APP_OPTIONS_TLS_ENGINE];
+ if (opts[APP_OPTIONS_MAX_FIFO_SIZE])
+ props->max_fifo_size = opts[APP_OPTIONS_MAX_FIFO_SIZE];
+ if (opts[APP_OPTIONS_HIGH_WATERMARK])
+ props->high_watermark = opts[APP_OPTIONS_HIGH_WATERMARK];
+ if (opts[APP_OPTIONS_LOW_WATERMARK])
+ props->low_watermark = opts[APP_OPTIONS_LOW_WATERMARK];
+ if (opts[APP_OPTIONS_PCT_FIRST_ALLOC])
+ props->pct_first_alloc = opts[APP_OPTIONS_PCT_FIRST_ALLOC];
props->segment_type = seg_type;
/* Add app to lookup by api_client_index table */
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index 46029f0307a..7d8b8ce4e1c 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -223,15 +223,16 @@ typedef enum
APP_OPTIONS_N_OPTIONS
} app_attach_options_index_t;
-#define foreach_app_options_flags \
- _(ACCEPT_REDIRECT, "Use FIFO with redirects") \
- _(ADD_SEGMENT, "Add segment and signal app if needed") \
- _(IS_BUILTIN, "Application is builtin") \
- _(IS_TRANSPORT_APP, "Application is a transport proto") \
- _(IS_PROXY, "Application is proxying") \
- _(USE_GLOBAL_SCOPE, "App can use global session scope") \
- _(USE_LOCAL_SCOPE, "App can use local session scope") \
- _(EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \
+#define foreach_app_options_flags \
+ _ (ACCEPT_REDIRECT, "Use FIFO with redirects") \
+ _ (ADD_SEGMENT, "Add segment and signal app if needed") \
+ _ (IS_BUILTIN, "Application is builtin") \
+ _ (IS_TRANSPORT_APP, "Application is a transport proto") \
+ _ (IS_PROXY, "Application is proxying") \
+ _ (USE_GLOBAL_SCOPE, "App can use global session scope") \
+ _ (USE_LOCAL_SCOPE, "App can use local session scope") \
+ _ (EVT_MQ_USE_EVENTFD, "Use eventfds for signaling") \
+ _ (MEMFD_FOR_BUILTIN, "Use memfd for builtin app segs")
typedef enum _app_options
{