26 #include <odp/helper/odph_api.h>
29 #include <sys/socket.h>
31 #include <sys/ioctl.h>
33 #include <sys/socket.h>
34 #include <netpacket/packet.h>
35 #include <net/ethernet.h>
36 #include <arpa/inet.h>
38 #include <odp_ipsec_misc.h>
39 #include <odp_ipsec_sa_db.h>
40 #include <odp_ipsec_sp_db.h>
41 #include <odp_ipsec_fwd_db.h>
42 #include <odp_ipsec_cache.h>
45 #include <odp_ipsec_stream.h>
47 static void init_stream_db(
void) {}
48 static void deinit_stream_db(
void) {}
49 static void resolve_stream_db(
void) {}
50 static int create_stream_db_inputs(
void)
55 static odp_bool_t verify_stream_db_outputs(
void)
60 static int create_stream_db_entry(
char *input
ODP_UNUSED)
67 #define MAX_WORKERS (ODP_THREAD_COUNT_MAX - 1)
69 #define MAX_POLL_QUEUES 256
75 unsigned int cpu_count;
98 int num_polled_queues;
104 static void parse_args(
int argc,
char *argv[], appl_args_t *appl_args);
105 static void print_info(
char *progname, appl_args_t *appl_args);
106 static void usage(
char *progname);
111 #define SHM_PKT_POOL_BUF_COUNT 1024
112 #define SHM_PKT_POOL_BUF_SIZE 4096
113 #define SHM_PKT_POOL_SIZE (SHM_PKT_POOL_BUF_COUNT * SHM_PKT_POOL_BUF_SIZE)
119 PKT_STATE_INPUT_VERIFY,
120 PKT_STATE_IPSEC_IN_CLASSIFY,
121 PKT_STATE_ROUTE_LOOKUP,
122 PKT_STATE_IPSEC_OUT_CLASSIFY,
147 #define SHM_CTX_POOL_BUF_SIZE (sizeof(pkt_ctx_t))
148 #define SHM_CTX_POOL_BUF_COUNT (SHM_PKT_POOL_BUF_COUNT)
149 #define SHM_CTX_POOL_SIZE (SHM_CTX_POOL_BUF_COUNT * SHM_CTX_POOL_BUF_SIZE)
151 static global_data_t *global;
178 memset(ctx, 0,
sizeof(*ctx));
179 ctx->buffer = ctx_buf;
191 void free_pkt_ctx(pkt_ctx_t *ctx)
203 static queue_create_func_t queue_create;
204 static schedule_func_t schedule_fn;
210 odp_queue_t polled_odp_queue_create(
const char *name,
224 printf(
"%s: change %s to PLAIN\n", __func__, name);
231 global->poll_queues[global->num_polled_queues++] = my_queue;
232 printf(
"%s: adding %" PRIu64
"\n", __func__,
253 while (idx < global->num_polled_queues) {
277 void ipsec_init_pre(
void)
293 global->completionq = queue_create(
"completion", &qparam);
295 ODPH_ERR(
"Error: completion queue creation failed\n");
321 sp_db_entry_t *entry;
326 ODPH_ERR(
"Error: failure getting IPSec caps\n");
336 ODPH_ERR(
"Error: failure setting IPSec config\n");
341 for (entry = sp_db->list; NULL != entry; entry = entry->next) {
342 sa_db_entry_t *cipher_sa = NULL;
343 sa_db_entry_t *auth_sa = NULL;
344 tun_db_entry_t *tun = NULL;
347 cipher_sa = find_sa_db_entry(&entry->src_subnet,
350 tun = find_tun_db_entry(cipher_sa->src_ip,
354 auth_sa = find_sa_db_entry(&entry->src_subnet,
357 tun = find_tun_db_entry(auth_sa->src_ip,
361 if (cipher_sa || auth_sa) {
362 if (create_ipsec_cache_entry(cipher_sa,
366 global->completionq)) {
367 ODPH_ERR(
"Error: IPSec cache entry failed.\n"
372 printf(
" WARNING: SA not found for SP\n");
373 dump_sp_db_entry(entry);
380 int check_stream_db_in(
const char *intf)
382 stream_db_entry_t *stream = NULL;
385 for (stream = stream_db->list; NULL != stream; stream = stream->next) {
386 if (!strcmp(stream->input.intf, intf))
394 int check_stream_db_out(
const char *intf)
396 stream_db_entry_t *stream = NULL;
399 for (stream = stream_db->list; NULL != stream; stream = stream->next) {
400 if (!strcmp(stream->output.intf, intf))
408 int check_stream_db_in(
const char *intf
ODP_UNUSED)
414 int check_stream_db_out(
const char *intf
ODP_UNUSED)
429 void initialize_intf(
char *intf)
435 uint8_t src_mac[ODPH_ETHADDR_LEN];
436 char src_mac_str[MAX_STRING];
444 if (getenv(
"ODP_IPSEC_USE_POLL_QUEUES") ||
445 check_stream_db_out(intf))
455 ODPH_ERR(
"Error: pktio create failed for %s\n", intf);
463 ODPH_ERR(
"Error: pktin config failed for %s\n", intf);
468 ODPH_ERR(
"Error: pktout config failed for %s\n", intf);
473 ODPH_ERR(
"Error: failed to get input queue for %s\n", intf);
478 ODPH_ERR(
"Error: failed to get pktout queue for %s\n", intf);
483 ODPH_ERR(
"Error: failed to get capabilities for %s\n", intf);
488 if (check_stream_db_in(intf) &&
491 if (check_stream_db_out(intf) &&
496 ODPH_ERR(
"Error: failed to set config for %s\n", intf);
502 ODPH_ERR(
"Error: unable to start %s\n", intf);
509 ODPH_ERR(
"Error: failed during MAC address get for %s\n", intf);
513 printf(
"Created pktio:%02" PRIu64
", queue mode (ATOMIC queues)\n"
514 " default pktio%02" PRIu64
"-INPUT queue:%" PRIu64
"\n"
515 " source mac address %s\n",
518 mac_addr_str(src_mac_str, src_mac));
521 resolve_fwd_db(intf, pktio, pktout, src_mac);
557 pkt_disposition_e do_route_fwd_db(
odp_packet_t pkt, pkt_ctx_t *ctx)
560 fwd_db_entry_t *entry;
567 if (l3_offset >
sizeof(odph_ethhdr_t))
569 l3_offset -
sizeof(odph_ethhdr_t));
572 sizeof(odph_ethhdr_t) - l3_offset);
574 memcpy(&ctx->eth.dst, entry->dst_mac, ODPH_ETHADDR_LEN);
575 memcpy(&ctx->eth.src, entry->src_mac, ODPH_ETHADDR_LEN);
584 ctx->pktio = entry->pktio;
585 ctx->pktout = entry->pktout;
606 pkt_disposition_e do_ipsec_in_classify(
odp_packet_t *ppkt)
609 odph_ahhdr_t *ah = NULL;
610 odph_esphdr_t *esp = NULL;
611 ipsec_cache_entry_t *entry;
616 locate_ipsec_headers(ip, &ah, &esp);
626 memset(&in_param, 0,
sizeof(in_param));
627 if (global->appl.lookup) {
632 in_param.
sa = &entry->ipsec_sa;
651 ODPH_DBG(
"odp_ipsec_result() failed\n");
655 ODPH_DBG(
"Error in inbound IPsec processing\n");
677 pkt_disposition_e do_ipsec_out_classify(
odp_packet_t *ppkt, pkt_ctx_t *ctx)
680 ipsec_cache_entry_t *entry;
691 memset(&out_param, 0,
sizeof(out_param));
694 out_param.
sa = &entry->ipsec_sa;
695 out_param.
opt = NULL;
701 inline_param.
pktio = ctx->pktio;
724 ODPH_DBG(
"odp_ipsec_result() failed\n");
728 ODPH_DBG(
"Error in outbound IPsec processing\n");
756 unsigned long pkt_cnt = 0;
760 printf(
"Pktio thread [%02i] starts\n", thr);
766 pkt_disposition_e rc = PKT_CONTINUE;
772 ev = schedule_fn(&dispatchq);
780 if (ODP_EVENT_PACKET_BASIC == subtype) {
781 ctx = alloc_pkt_ctx(pkt);
786 ctx->state = PKT_STATE_INPUT_VERIFY;
787 }
else if (ODP_EVENT_PACKET_IPSEC == subtype) {
792 ODPH_DBG(
"Error Event\n");
798 ODPH_DBG(
"Error in IPsec\n");
803 ctx = alloc_pkt_ctx(pkt);
812 ctx->state = PKT_STATE_ROUTE_LOOKUP;
817 ODPH_DBG(
"Unsupported Packet\n");
825 ODPH_DBG(
"Error Event\n");
830 printf(
"IPsec status %d result %d for SA %" PRIx64
"\n",
852 while (rc == PKT_CONTINUE) {
853 switch (ctx->state) {
854 case PKT_STATE_INPUT_VERIFY:
856 rc = do_input_verify(pkt, ctx);
857 ctx->state = PKT_STATE_IPSEC_IN_CLASSIFY;
860 case PKT_STATE_IPSEC_IN_CLASSIFY:
862 ctx->state = PKT_STATE_ROUTE_LOOKUP;
863 rc = do_ipsec_in_classify(&pkt);
866 case PKT_STATE_ROUTE_LOOKUP:
868 rc = do_route_fwd_db(pkt, ctx);
869 ctx->state = PKT_STATE_IPSEC_OUT_CLASSIFY;
872 case PKT_STATE_IPSEC_OUT_CLASSIFY:
873 ctx->state = PKT_STATE_TRANSMIT;
874 rc = do_ipsec_out_classify(&pkt, ctx);
877 case PKT_STATE_TRANSMIT:
892 if ((PKT_DROP == rc) || (PKT_DONE == rc))
900 if (PKT_DONE == rc) {
902 printf(
" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt);
915 main(
int argc,
char *argv[])
917 odph_helper_options_t helper_options;
918 odph_thread_t thread_tbl[MAX_WORKERS];
919 odph_thread_common_param_t thr_common;
920 odph_thread_param_t thr_param;
935 schedule_fn = odp_schedule_cb;
938 if (getenv(
"ODP_IPSEC_USE_POLL_QUEUES")) {
939 queue_create = polled_odp_queue_create;
940 schedule_fn = polled_odp_schedule_cb;
944 argc = odph_parse_options(argc, argv);
945 if (odph_options(&helper_options)) {
946 ODPH_ERR(
"Error: reading ODP helper options failed.\n");
952 signal(SIGINT, sig_handler);
955 init_param.
mem_model = helper_options.mem_model;
959 ODPH_ERR(
"Error: ODP global init failed.\n");
965 ODPH_ERR(
"Error: ODP local init failed.\n");
970 ODPH_ERR(
"Error: IPsec capability request failed.\n");
974 if (queue_create == polled_odp_queue_create) {
976 ODPH_ERR(
"Error: Plain type dest queue not supported.\n");
981 ODPH_ERR(
"Error: scheduled type dest queue not supported.\n");
988 ODP_CACHE_LINE_SIZE, 0);
991 ODPH_ERR(
"Error: shared mem reserve failed.\n");
997 if (NULL == global) {
998 ODPH_ERR(
"Error: shared mem alloc failed.\n");
1001 memset(global, 0,
sizeof(global_data_t));
1014 parse_args(argc, argv, &global->appl);
1017 print_info(NO_PATH(argv[0]), &global->appl);
1019 num_workers = MAX_WORKERS;
1020 if (global->appl.cpu_count && global->appl.cpu_count < MAX_WORKERS)
1021 num_workers = global->appl.cpu_count;
1027 printf(
"num worker threads: %i\n", num_workers);
1029 printf(
"cpu mask: %s\n", cpumaskstr);
1037 params.
pkt.
len = SHM_PKT_POOL_BUF_SIZE;
1038 params.
pkt.
num = SHM_PKT_POOL_BUF_COUNT;
1044 ODPH_ERR(
"Error: packet pool create failed.\n");
1049 params.
buf.
size = SHM_CTX_POOL_BUF_SIZE;
1051 params.
buf.
num = SHM_CTX_POOL_BUF_COUNT;
1057 ODPH_ERR(
"Error: context pool create failed.\n");
1062 printf(
"Using %s mode for IPsec API\n\n",
1066 ipsec_init_post(global->appl.mode);
1069 for (i = 0; i < global->appl.if_count; i++)
1070 initialize_intf(global->appl.if_names[i]);
1073 resolve_stream_db();
1074 stream_count = create_stream_db_inputs();
1075 if (stream_count < 0) {
1076 ODPH_ERR(
"Error: creating input packets failed\n");
1083 odph_thread_common_param_init(&thr_common);
1084 thr_common.instance = instance;
1085 thr_common.cpumask = &cpumask;
1086 thr_common.share_param = 1;
1088 odph_thread_param_init(&thr_param);
1089 thr_param.start = pktio_thread;
1090 thr_param.arg = NULL;
1093 memset(thread_tbl, 0,
sizeof(thread_tbl));
1094 odph_thread_create(thread_tbl, &thr_common, &thr_param, num_workers);
1102 done = verify_stream_db_outputs();
1105 printf(
"All received\n");
1108 odph_thread_join(thread_tbl, num_workers);
1111 for (i = 0; i < global->appl.if_count; i++) {
1118 ODPH_ERR(
"Error: failed to close pktio %s\n",
1119 global->appl.if_names[i]);
1124 free(global->appl.if_names);
1125 free(global->appl.if_str);
1127 if (destroy_ipsec_cache())
1128 ODPH_ERR(
"Error: crypto session destroy failed\n");
1136 ODPH_ERR(
"Error: queue destroy failed\n");
1139 ODPH_ERR(
"Error: pool destroy failed\n");
1141 ODPH_ERR(
"Error: pool destroy failed\n");
1145 ODPH_ERR(
"Error: shm free shm_ipsec_cache failed\n");
1148 ODPH_ERR(
"Error: shm free shm_fwd_db failed\n");
1151 ODPH_ERR(
"Error: shm free shm_sa_db failed\n");
1154 ODPH_ERR(
"Error: shm free shm_tun_db failed\n");
1157 ODPH_ERR(
"Error: shm free shm_sp_db failed\n");
1162 ODPH_ERR(
"Error: shm free global data failed\n");
1167 ODPH_ERR(
"Error: term local failed\n");
1172 ODPH_ERR(
"Error: term global failed\n");
1188 static void parse_args(
int argc,
char *argv[], appl_args_t *appl_args)
1196 static const struct option longopts[] = {
1197 {
"count", required_argument, NULL,
'c'},
1198 {
"interface", required_argument, NULL,
'i'},
1199 {
"lookup", no_argument, NULL,
'l'},
1200 {
"mode", required_argument, NULL,
'm'},
1201 {
"route", required_argument, NULL,
'r'},
1202 {
"policy", required_argument, NULL,
'p'},
1203 {
"ah", required_argument, NULL,
'a'},
1204 {
"esp", required_argument, NULL,
'e'},
1205 {
"tunnel", required_argument, NULL,
't'},
1206 {
"stream", required_argument, NULL,
's'},
1207 {
"help", no_argument, NULL,
'h'},
1211 static const char *shortopts =
"+c:i:m:r:p:a:e:t:s:lh";
1213 appl_args->cpu_count = 1;
1215 printf(
"\nParsing command line options\n");
1218 opt = getopt_long(argc, argv, shortopts, longopts, NULL);
1225 appl_args->cpu_count = atoi(optarg);
1229 len = strlen(optarg);
1236 appl_args->if_str = malloc(len);
1237 if (appl_args->if_str == NULL) {
1243 strcpy(appl_args->if_str, optarg);
1244 for (token = strtok(appl_args->if_str,
","), i = 0;
1246 token = strtok(NULL,
","), i++)
1249 appl_args->if_count = i;
1251 if (0 == appl_args->if_count) {
1257 appl_args->if_names =
1258 calloc(appl_args->if_count,
sizeof(
char *));
1261 strcpy(appl_args->if_str, optarg);
1262 for (token = strtok(appl_args->if_str,
","), i = 0;
1263 token != NULL; token = strtok(NULL,
","), i++) {
1264 appl_args->if_names[i] = token;
1269 appl_args->lookup =
true;
1273 appl_args->mode = atoi(optarg);
1277 rc = create_fwd_db_entry(optarg, appl_args->if_names,
1278 appl_args->if_count);
1282 rc = create_sp_db_entry(optarg, FALSE);
1286 rc = create_sa_db_entry(optarg, FALSE);
1290 rc = create_sa_db_entry(optarg, TRUE);
1294 rc = create_tun_db_entry(optarg);
1298 rc = create_stream_db_entry(optarg);
1312 printf(
"ERROR: failed parsing -%c option\n", opt);
1317 if (0 == appl_args->if_count) {
1328 static void print_info(
char *progname, appl_args_t *appl_args)
1334 printf(
"Running ODP appl: \"%s\"\n"
1335 "-----------------\n"
1338 progname, appl_args->if_count);
1339 for (i = 0; i < appl_args->if_count; ++i)
1340 printf(
" %s", appl_args->if_names[i]);
1355 static void usage(
char *progname)
1358 "Usage: %s OPTIONS\n"
1359 " E.g. %s -i eth1,eth2,eth3 -m 0\n"
1361 "OpenDataPlane example application.\n"
1363 "Mandatory OPTIONS:\n"
1364 " -i, --interface Eth interfaces (comma-separated, no spaces)\n"
1365 " -m, --mode 0: SYNC\n"
1367 " Default: 1: ASYNC api mode\n"
1369 "Routing / IPSec OPTIONS:\n"
1370 " -r, --route SubNet,Intf,NextHopMAC\n"
1371 " -p, --policy SrcSubNet,DstSubNet,(in|out),(ah|esp)\n"
1372 " -e, --esp SrcIP,DstIP,(3des|null),SPI,Key192\n"
1373 " -a, --ah SrcIP,DstIP,(sha256|sha1|md5|null),SPI,Key(256|160|128)\n"
1375 " Where: NextHopMAC is raw hex/colon notation, i.e. 03:BA:44:9A:CE:02\n"
1376 " IP is decimal/dot notation, i.e. 192.168.1.1\n"
1377 " SubNet is decimal/dot/slash notation, i.e 192.168.0.0/16\n"
1378 " SPI is raw hex, 32 bits\n"
1379 " KeyXXX is raw hex, XXX bits long\n"
1382 " -r 192.168.222.0/24,p8p1,08:00:27:F5:8B:DB\n"
1383 " -p 192.168.111.0/24,192.168.222.0/24,out,esp\n"
1384 " -e 192.168.111.2,192.168.222.2,3des,201,656c8523255ccc23a66c1917aa0cf30991fce83532a4b224\n"
1385 " -a 192.168.111.2,192.168.222.2,md5,201,a731649644c5dee92cbd9c2e7e188ee6\n"
1387 "Optional OPTIONS\n"
1388 " -c, --count <number> CPU count, 0=all available, default=1\n"
1389 " -s, --stream SrcIP,DstIP,InIntf,OutIntf,Count,Length\n"
1390 " -h, --help Display help and exit.\n"
1391 " environment variables: ODP_IPSEC_USE_POLL_QUEUES\n"
1392 " to enable use of poll queues instead of scheduled (default)\n"
1393 " ODP_IPSEC_STREAM_VERIFY_MDEQ\n"
1394 " to enable use of multiple dequeue for queue draining during\n"
1395 " stream verification instead of single dequeue (default)\n"
1396 "\n", NO_PATH(progname), NO_PATH(progname)
1400 odp_bool_t sa_config_supported(
const sa_db_entry_t *sa_entry,
int *sa_flags);
void odp_atomic_init_u32(odp_atomic_u32_t *atom, uint32_t val)
Initialize atomic uint32 variable.
uint32_t odp_atomic_load_u32(odp_atomic_u32_t *atom)
Load value of atomic uint32 variable.
void odp_atomic_store_u32(odp_atomic_u32_t *atom, uint32_t val)
Store value to atomic uint32 variable.
void odp_barrier_init(odp_barrier_t *barr, int count)
Initialize barrier with thread count.
void odp_barrier_wait(odp_barrier_t *barr)
Synchronize thread execution on barrier.
odp_buffer_t odp_buffer_alloc(odp_pool_t pool)
Buffer alloc.
void odp_buffer_free(odp_buffer_t buf)
Buffer free.
void * odp_buffer_addr(odp_buffer_t buf)
Buffer start address.
#define ODP_BUFFER_INVALID
Invalid buffer.
#define odp_unlikely(x)
Branch unlikely taken.
odp_u16be_t odp_cpu_to_be_16(uint16_t cpu16)
Convert cpu native uint16_t to 16bit big endian.
#define ODP_UNUSED
Intentionally unused variables of functions.
uint32_t odp_be_to_cpu_32(odp_u32be_t be32)
Convert 32bit big endian to cpu native uint32_t.
int odp_cpumask_default_worker(odp_cpumask_t *mask, int num)
Default CPU mask for worker threads.
int odp_cpumask_first(const odp_cpumask_t *mask)
Find first set CPU in mask.
int32_t odp_cpumask_to_str(const odp_cpumask_t *mask, char *str, int32_t size)
Format a string from CPU mask.
#define ODP_CPUMASK_STR_SIZE
The maximum number of characters needed to record any CPU mask as a string (output of odp_cpumask_to_...
void odp_event_free(odp_event_t event)
Free event.
odp_event_type_t odp_event_type(odp_event_t event)
Event type of an event.
_odp_abi_event_t * odp_event_t
ODP event.
odp_event_subtype_t
Event subtype.
odp_event_type_t odp_event_types(odp_event_t event, odp_event_subtype_t *subtype)
Event type and subtype of an event.
#define ODP_EVENT_INVALID
Invalid event.
void odp_init_param_init(odp_init_t *param)
Initialize the odp_init_t to default values for all fields.
int odp_init_local(odp_instance_t instance, odp_thread_type_t thr_type)
Thread local ODP initialization.
int odp_init_global(odp_instance_t *instance, const odp_init_t *params, const odp_platform_init_t *platform_params)
Global ODP initialization.
int odp_term_local(void)
Thread local ODP termination.
int odp_term_global(odp_instance_t instance)
Global ODP termination.
uint64_t odp_instance_t
ODP instance ID.
int odp_ipsec_in_enq(const odp_packet_t pkt[], int num, const odp_ipsec_in_param_t *param)
Inbound asynchronous IPSEC operation.
int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in, odp_packet_t pkt_out[], int *num_out, const odp_ipsec_in_param_t *param)
Inbound synchronous IPSEC operation.
#define ODP_IPSEC_OK
IPSEC operation status has no errors.
int odp_ipsec_capability(odp_ipsec_capability_t *capa)
Query IPSEC capabilities.
int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in, odp_packet_t pkt_out[], int *num_out, const odp_ipsec_out_param_t *param)
Outbound synchronous IPSEC operation.
uint64_t odp_ipsec_sa_to_u64(odp_ipsec_sa_t sa)
Printable format of odp_ipsec_sa_t.
odp_ipsec_op_mode_t
IPSEC operation mode.
void odp_ipsec_config_init(odp_ipsec_config_t *config)
Initialize IPSEC configuration options.
int odp_ipsec_config(const odp_ipsec_config_t *config)
Global IPSEC configuration.
int odp_ipsec_out_inline(const odp_packet_t pkt[], int num, const odp_ipsec_out_param_t *param, const odp_ipsec_out_inline_param_t *inline_param)
Outbound inline IPSEC operation.
int odp_ipsec_out_enq(const odp_packet_t pkt[], int num, const odp_ipsec_out_param_t *param)
Outbound asynchronous IPSEC operation.
int odp_ipsec_status(odp_ipsec_status_t *status, odp_event_t event)
Get IPSEC status information from an ODP_EVENT_IPSEC_STATUS event.
int odp_ipsec_result(odp_ipsec_packet_result_t *result, odp_packet_t packet)
Get IPSEC operation results from an IPSEC processed packet.
@ ODP_IPSEC_OP_MODE_INLINE
Inline IPSEC operation.
@ ODP_IPSEC_OP_MODE_SYNC
Synchronous IPSEC operation.
@ ODP_IPSEC_OP_MODE_ASYNC
Asynchronous IPSEC operation.
int odp_pktio_mac_addr(odp_pktio_t pktio, void *mac_addr, int size)
Get the default MAC address of a packet IO interface.
void odp_pktin_queue_param_init(odp_pktin_queue_param_t *param)
Initialize packet input queue parameters.
void odp_pktio_param_init(odp_pktio_param_t *param)
Initialize pktio params.
int odp_pktio_close(odp_pktio_t pktio)
Close a packet IO interface.
odp_pktio_t odp_pktio_lookup(const char *name)
Return a packet IO handle for an already open device.
int odp_pktout_queue(odp_pktio_t pktio, odp_pktout_queue_t queues[], int num)
Direct packet output queues.
void odp_pktio_config_init(odp_pktio_config_t *config)
Initialize packet IO configuration options.
int odp_pktin_event_queue(odp_pktio_t pktio, odp_queue_t queues[], int num)
Event queues for packet input.
odp_pktio_t odp_pktio_open(const char *name, odp_pool_t pool, const odp_pktio_param_t *param)
Open a packet IO interface.
int odp_pktio_config(odp_pktio_t pktio, const odp_pktio_config_t *config)
Configure packet IO interface options.
int odp_pktio_start(odp_pktio_t pktio)
Start packet receive and transmit.
#define ODP_PKTIO_INVALID
Invalid packet IO handle.
int odp_pktio_stop(odp_pktio_t pktio)
Stop packet receive and transmit.
int odp_pktio_capability(odp_pktio_t pktio, odp_pktio_capability_t *capa)
Query packet IO interface capabilities.
int odp_pktout_send(odp_pktout_queue_t queue, const odp_packet_t packets[], int num)
Send packets directly to an interface output queue.
uint64_t odp_pktio_to_u64(odp_pktio_t pktio)
Get printable value for an odp_pktio_t.
int odp_pktin_queue_config(odp_pktio_t pktio, const odp_pktin_queue_param_t *param)
Configure packet input queues.
int odp_pktout_queue_config(odp_pktio_t pktio, const odp_pktout_queue_param_t *param)
Configure packet output queues.
@ ODP_PKTIN_MODE_QUEUE
Packet input through plain event queues.
@ ODP_PKTIN_MODE_SCHED
Packet input through scheduler and scheduled event queues.
void * odp_packet_pull_head(odp_packet_t pkt, uint32_t len)
Pull in packet head.
void * odp_packet_user_ptr(odp_packet_t pkt)
User context pointer.
void * odp_packet_push_head(odp_packet_t pkt, uint32_t len)
Push out packet head.
int odp_packet_has_ipv4(odp_packet_t pkt)
Check for IPv4.
int odp_packet_has_eth(odp_packet_t pkt)
Check for Ethernet header.
int odp_packet_has_error(odp_packet_t pkt)
Check for all parse errors in packet.
int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset)
Set layer 2 start offset.
odp_packet_t odp_packet_from_event(odp_event_t ev)
Get packet handle from event.
void odp_packet_free(odp_packet_t pkt)
Free packet.
uint32_t odp_packet_l3_offset(odp_packet_t pkt)
Layer 3 start offset.
int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, uint32_t len, const void *src)
Copy data from memory to packet.
void odp_packet_user_ptr_set(odp_packet_t pkt, const void *user_ptr)
Set user context pointer.
void * odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len)
Layer 3 start pointer.
@ ODP_PROTO_LAYER_ALL
All layers.
odp_pool_t odp_pool_create(const char *name, const odp_pool_param_t *param)
Create a pool.
void odp_pool_param_init(odp_pool_param_t *param)
Initialize pool params.
int odp_pool_destroy(odp_pool_t pool)
Destroy a pool previously created by odp_pool_create()
#define ODP_POOL_INVALID
Invalid pool.
@ ODP_POOL_BUFFER
Buffer pool.
@ ODP_POOL_PACKET
Packet pool.
_odp_abi_queue_t * odp_queue_t
ODP queue.
void odp_queue_param_init(odp_queue_param_t *param)
Initialize queue params.
#define ODP_QUEUE_INVALID
Invalid queue.
odp_event_t odp_queue_deq(odp_queue_t queue)
Dequeue an event from a queue.
odp_queue_type_t
Queue type.
odp_queue_t odp_queue_create(const char *name, const odp_queue_param_t *param)
Queue create.
int odp_queue_destroy(odp_queue_t queue)
Destroy ODP queue.
uint64_t odp_queue_to_u64(odp_queue_t hdl)
Get printable value for an odp_queue_t.
@ ODP_QUEUE_TYPE_SCHED
Scheduled queue.
@ ODP_QUEUE_TYPE_PLAIN
Plain queue.
#define ODP_SCHED_SYNC_ATOMIC
Atomic queue synchronization.
#define ODP_SCHED_NO_WAIT
Do not wait.
int odp_schedule_max_prio(void)
Maximum scheduling priority level.
int odp_schedule_config(const odp_schedule_config_t *config)
Global schedule configuration.
odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait)
Schedule an event.
#define ODP_SCHED_GROUP_ALL
Group of all threads.
odp_shm_t odp_shm_lookup(const char *name)
Lookup for a block of shared memory.
int odp_shm_free(odp_shm_t shm)
Free a contiguous block of shared memory.
#define ODP_SHM_INVALID
Invalid shared memory block.
void * odp_shm_addr(odp_shm_t shm)
Shared memory block address.
odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, uint32_t flags)
Reserve a contiguous block of shared memory.
bool odp_bool_t
Boolean type.
void odp_sys_info_print(void)
Print system info.
int odp_thread_id(void)
Get thread identifier.
@ ODP_THREAD_WORKER
Worker thread.
@ ODP_THREAD_CONTROL
Control thread.
Global initialization parameters.
odp_mem_model_t mem_model
Application memory model.
odp_bool_t queue_type_sched
Scheduled queue support.
odp_bool_t queue_type_plain
Plain queue support.
IPSEC configuration options.
odp_ipsec_op_mode_t outbound_mode
Outbound IPSEC operation mode.
odp_ipsec_inbound_config_t inbound
IPSEC inbound processing configuration.
odp_ipsec_op_mode_t inbound_mode
Inbound IPSEC operation mode.
uint32_t all
All error bits.
IPSEC inbound operation parameters.
const odp_ipsec_sa_t * sa
Pointer to an array of IPSEC SAs.
odp_queue_t default_queue
Default destination queue for IPSEC events.
odp_proto_layer_t parse_level
Parse packet headers after IPSEC transformation.
uint32_t inline_mode
Packet was processed in inline mode.
odp_ipsec_error_t error
IPSEC errors.
Outbound inline IPSEC operation parameters.
odp_pktio_t pktio
Packet output interface for inline outbound operation without TM.
uint32_t len
Outer header length in bytes.
const uint8_t * ptr
Points to first byte of outer headers to be copied in front of the outgoing IPSEC packet.
struct odp_ipsec_out_inline_param_t::@81 outer_hdr
Outer headers for inline output operation.
IPSEC outbound operation parameters.
int num_opt
Number of outbound operation options.
const odp_ipsec_sa_t * sa
Pointer to an array of IPSEC SAs.
const odp_ipsec_out_opt_t * opt
Pointer to an array of outbound operation options.
IPSEC operation result for a packet.
odp_ipsec_op_status_t status
IPSEC operation status.
odp_ipsec_op_flag_t flag
IPSEC operation flags.
int result
Result of the operation.
odp_ipsec_sa_t sa
IPSEC SA that was target of the operation.
odp_ipsec_status_id_t id
IPSEC status ID.
Packet input queue parameters.
odp_queue_param_t queue_param
Queue parameters.
odp_pktio_config_t config
Supported pktio configuration options.
Packet IO configuration options.
odp_bool_t outbound_ipsec
Outbound IPSEC inlined with packet output.
odp_bool_t inbound_ipsec
Inbound IPSEC inlined with packet input.
odp_pktin_mode_t in_mode
Packet input mode.
uint32_t num
Number of buffers in the pool.
uint32_t align
Minimum buffer alignment in bytes.
uint32_t size
Minimum buffer size in bytes.
odp_pool_type_t type
Pool type.
uint32_t len
Minimum length of 'num' packets.
uint32_t seg_len
Minimum number of packet data bytes that can be stored in the first segment of a newly allocated pack...
struct odp_pool_param_t::@126 pkt
Parameters for packet pools.
struct odp_pool_param_t::@125 buf
Parameters for buffer pools.
odp_schedule_param_t sched
Scheduler parameters.
odp_queue_type_t type
Queue type.
odp_schedule_group_t group
Thread group.
odp_schedule_prio_t prio
Priority level.
odp_schedule_sync_t sync
Synchronization method.