diff options
author | Petri Savolainen <petri.savolainen@nokia.com> | 2016-02-19 14:11:47 +0200 |
---|---|---|
committer | Maxim Uvarov <maxim.uvarov@linaro.org> | 2016-03-04 11:15:24 +0300 |
commit | 82af7993921bd0880908e6a1f95b73d35ce244ad (patch) | |
tree | 79c3756ce9505967a890806faeca3ec2600ca964 /example | |
parent | 3af9f51437a895a3da3432807c60e11e811e8344 (diff) |
example: ipsec: port to use new pktio api
Ported the example from old single queue pktio API
to the new API. Loopback mode is temporarely disabled. Needs
a decision to remove it, or port to use pktout event queues which
are not yet introduced.
Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r-- | example/ipsec/odp_ipsec.c | 60 | ||||
-rw-r--r-- | example/ipsec/odp_ipsec_fwd_db.c | 7 | ||||
-rw-r--r-- | example/ipsec/odp_ipsec_fwd_db.h | 4 |
3 files changed, 33 insertions, 38 deletions
diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index e4b0a2264..e7f27fb24 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -160,7 +160,7 @@ typedef struct { odp_buffer_t buffer; /**< Buffer for context */ pkt_state_e state; /**< Next processing step */ ipsec_ctx_t ipsec; /**< IPsec specific context */ - odp_queue_t outq; /**< transmit queue */ + odp_pktout_queue_t pktout; /**< Packet output queue */ } pkt_ctx_t; #define SHM_CTX_POOL_BUF_SIZE (sizeof(pkt_ctx_t)) @@ -419,6 +419,7 @@ void ipsec_init_post(crypto_api_mode_e api_mode) * * @param intf Loopback interface name string */ +#if 0 /* Temporarely disable loopback mode. Needs packet output event queues */ static void initialize_loop(char *intf) { @@ -478,7 +479,7 @@ void initialize_loop(char *intf) /* Resolve any routes using this interface for output */ resolve_fwd_db(intf, outq_def, mac); } - +#endif /** * Initialize interface * @@ -491,14 +492,13 @@ static void initialize_intf(char *intf) { odp_pktio_t pktio; - odp_queue_t outq_def; - odp_queue_t inq_def; - char inq_name[ODP_QUEUE_NAME_LEN]; - odp_queue_param_t qparam; + odp_pktout_queue_t pktout; + odp_queue_t inq; int ret; uint8_t src_mac[ODPH_ETHADDR_LEN]; char src_mac_str[MAX_STRING]; odp_pktio_param_t pktio_param; + odp_pktin_queue_param_t pktin_param; odp_pktio_param_init(&pktio_param); @@ -515,31 +515,27 @@ void initialize_intf(char *intf) EXAMPLE_ERR("Error: pktio create failed for %s\n", intf); exit(EXIT_FAILURE); } - outq_def = odp_pktio_outq_getdef(pktio); - /* - * Create and set the default INPUT queue associated with the 'pktio' - * resource - */ - odp_queue_param_init(&qparam); - qparam.type = ODP_QUEUE_TYPE_PKTIN; - qparam.sched.prio = ODP_SCHED_PRIO_DEFAULT; - qparam.sched.sync = ODP_SCHED_SYNC_ATOMIC; - qparam.sched.group = ODP_SCHED_GROUP_ALL; - snprintf(inq_name, sizeof(inq_name), "%" PRIu64 "-pktio_inq_def", - odp_pktio_to_u64(pktio)); - inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; + odp_pktin_queue_param_init(&pktin_param); + pktin_param.queue_param.sched.sync = ODP_SCHED_SYNC_ATOMIC; - inq_def = queue_create(inq_name, &qparam); - if (ODP_QUEUE_INVALID == inq_def) { - EXAMPLE_ERR("Error: pktio queue creation failed for %s\n", - intf); + if (odp_pktin_queue_config(pktio, &pktin_param)) { + EXAMPLE_ERR("Error: pktin config failed for %s\n", intf); exit(EXIT_FAILURE); } - ret = odp_pktio_inq_setdef(pktio, inq_def); - if (ret) { - EXAMPLE_ERR("Error: default input-Q setup for %s\n", intf); + if (odp_pktout_queue_config(pktio, NULL)) { + EXAMPLE_ERR("Error: pktout config failed for %s\n", intf); + exit(EXIT_FAILURE); + } + + if (odp_pktin_event_queue(pktio, &inq, 1) != 1) { + EXAMPLE_ERR("Error: failed to get input queue for %s\n", intf); + exit(EXIT_FAILURE); + } + + if (odp_pktout_queue(pktio, &pktout, 1) != 1) { + EXAMPLE_ERR("Error: failed to get pktout queue for %s\n", intf); exit(EXIT_FAILURE); } @@ -561,11 +557,11 @@ void initialize_intf(char *intf) " default pktio%02" PRIu64 "-INPUT queue:%" PRIu64 "\n" " source mac address %s\n", odp_pktio_to_u64(pktio), odp_pktio_to_u64(pktio), - odp_queue_to_u64(inq_def), + odp_queue_to_u64(inq), mac_addr_str(src_mac_str, src_mac)); /* Resolve any routes using this interface for output */ - resolve_fwd_db(intf, outq_def, src_mac); + resolve_fwd_db(intf, pktout, src_mac); } /** @@ -614,7 +610,7 @@ pkt_disposition_e do_route_fwd_db(odp_packet_t pkt, pkt_ctx_t *ctx) memcpy(ð->dst, entry->dst_mac, ODPH_ETHADDR_LEN); memcpy(ð->src, entry->src_mac, ODPH_ETHADDR_LEN); - ctx->outq = entry->queue; + ctx->pktout = entry->pktout; return PKT_CONTINUE; } @@ -1175,8 +1171,8 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED) case PKT_STATE_TRANSMIT: - if (odp_queue_enq(ctx->outq, ev)) { - odp_event_free(ev); + if (odp_pktio_send_queue(ctx->pktout, + &pkt, 1) < 1) { rc = PKT_DROP; } else { rc = PKT_DONE; @@ -1324,9 +1320,11 @@ main(int argc, char *argv[]) /* Initialize interfaces (which resolves FWD DB entries */ for (i = 0; i < args->appl.if_count; i++) { +#if 0 /* Temporarely disable loopback mode. Needs packet output event queues */ if (!strncmp("loop", args->appl.if_names[i], strlen("loop"))) initialize_loop(args->appl.if_names[i]); else +#endif initialize_intf(args->appl.if_names[i]); } diff --git a/example/ipsec/odp_ipsec_fwd_db.c b/example/ipsec/odp_ipsec_fwd_db.c index 38fc2833a..7b0bc08b4 100644 --- a/example/ipsec/odp_ipsec_fwd_db.c +++ b/example/ipsec/odp_ipsec_fwd_db.c @@ -99,9 +99,6 @@ int create_fwd_db_entry(char *input) return -1; } - /* Reset queue to invalid */ - entry->queue = ODP_QUEUE_INVALID; - /* Add route to the list */ fwd_db->index++; entry->next = fwd_db->list; @@ -111,7 +108,7 @@ int create_fwd_db_entry(char *input) return 0; } -void resolve_fwd_db(char *intf, odp_queue_t outq, uint8_t *mac) +void resolve_fwd_db(char *intf, odp_pktout_queue_t pktout, uint8_t *mac) { fwd_db_entry_t *entry; @@ -120,7 +117,7 @@ void resolve_fwd_db(char *intf, odp_queue_t outq, uint8_t *mac) if (strcmp(intf, entry->oif)) continue; - entry->queue = outq; + entry->pktout = pktout; memcpy(entry->src_mac, mac, ODPH_ETHADDR_LEN); } } diff --git a/example/ipsec/odp_ipsec_fwd_db.h b/example/ipsec/odp_ipsec_fwd_db.h index 0e2e9edeb..094253e32 100644 --- a/example/ipsec/odp_ipsec_fwd_db.h +++ b/example/ipsec/odp_ipsec_fwd_db.h @@ -23,7 +23,7 @@ extern "C" { typedef struct fwd_db_entry_s { struct fwd_db_entry_s *next; /**< Next entry on list */ char oif[OIF_LEN]; /**< Output interface name */ - odp_queue_t queue; /**< Output transmit queue */ + odp_pktout_queue_t pktout; /**< Output transmit queue */ uint8_t src_mac[ODPH_ETHADDR_LEN]; /**< Output source MAC */ uint8_t dst_mac[ODPH_ETHADDR_LEN]; /**< Output destination MAC */ ip_addr_range_t subnet; /**< Subnet for this router */ @@ -62,7 +62,7 @@ int create_fwd_db_entry(char *input); * @param outq Output queue for packet transmit * @param mac MAC address of this interface */ -void resolve_fwd_db(char *intf, odp_queue_t outq, uint8_t *mac); +void resolve_fwd_db(char *intf, odp_pktout_queue_t pktout, uint8_t *mac); /** * Display one fowarding database entry |