X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=VNFs%2FDPPD-PROX%2Ftask_init.c;h=fc12eae795067a44dc4214c5840c18ea37f65d4d;hb=6ecdeb8fb5c38a9c1b60eba98b7f8f23c5fe394d;hp=6d9c7b3d82e7934f20ad41dc56fb70b088aad1f6;hpb=cb94e0036256c6a3fb0aadb682a04d8ad30ddd2a;p=samplevnf.git diff --git a/VNFs/DPPD-PROX/task_init.c b/VNFs/DPPD-PROX/task_init.c index 6d9c7b3d..fc12eae7 100644 --- a/VNFs/DPPD-PROX/task_init.c +++ b/VNFs/DPPD-PROX/task_init.c @@ -1,5 +1,5 @@ /* -// Copyright (c) 2010-2017 Intel Corporation +// Copyright (c) 2010-2020 Intel Corporation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ LIST_HEAD(,task_init) head; void reg_task(struct task_init* t) { - PROX_PANIC(t->handle == NULL, "No handle function specified for task with name %d\n", t->mode); + // PROX_PANIC(t->handle == NULL, "No handle function specified for task with name %d\n", t->mode); if (t->thread_x == NULL) t->thread_x = thread_generic; @@ -70,6 +70,11 @@ static int compare_strcmp(const void *a, const void *b) return strcmp(*(const char * const *)a, *(const char * const *)b); } +int task_is_master(struct task_args *targ) +{ + return (targ->lconf->id == prox_cfg.master); +} + void tasks_list(void) { struct task_init *cur_t; @@ -169,13 +174,23 @@ static size_t init_rx_tx_rings_ports(struct task_args *targ, struct task_base *t } else { if (targ->nb_rxports == 1) { - tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw1_multi : rx_pkt_hw1; + if (targ->flags & TASK_ARG_L3) + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw1_multi_l3 : rx_pkt_hw1_l3; + else if (targ->flags & TASK_ARG_NDP) + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw1_multi_ndp : rx_pkt_hw1_ndp; + else + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw1_multi : rx_pkt_hw1; tbase->rx_params_hw1.rx_pq.port = targ->rx_port_queue[0].port; tbase->rx_params_hw1.rx_pq.queue = targ->rx_port_queue[0].queue; } else { PROX_ASSERT((targ->nb_rxports != 0) || (targ->task_init->flag_features & TASK_FEATURE_NO_RX)); - tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_multi : rx_pkt_hw; + if (targ->flags & TASK_ARG_L3) + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_multi_l3 : rx_pkt_hw_l3; + else if (targ->flags & TASK_ARG_NDP) + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_multi_ndp : rx_pkt_hw_ndp; + else + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_multi : rx_pkt_hw; tbase->rx_params_hw.nb_rxports = targ->nb_rxports; tbase->rx_params_hw.rx_pq = (struct port_queue *)(((uint8_t *)tbase) + offset); offset += sizeof(struct port_queue) * tbase->rx_params_hw.nb_rxports; @@ -185,7 +200,12 @@ static size_t init_rx_tx_rings_ports(struct task_args *targ, struct task_base *t } if (rte_is_power_of_2(targ->nb_rxports)) { - tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_pow2_multi : rx_pkt_hw_pow2; + if (targ->flags & TASK_ARG_L3) + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_pow2_multi_l3 : rx_pkt_hw_pow2_l3; + else if (targ->flags & TASK_ARG_NDP) + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_pow2_multi_ndp : rx_pkt_hw_pow2_ndp; + else + tbase->rx_pkt = (targ->task_init->flag_features & TASK_FEATURE_MULTI_RX)? rx_pkt_hw_pow2_multi : rx_pkt_hw_pow2; tbase->rx_params_hw.rxport_mask = targ->nb_rxports - 1; } } @@ -194,7 +214,7 @@ static size_t init_rx_tx_rings_ports(struct task_args *targ, struct task_base *t if ((targ->nb_txrings != 0) && (!targ->tx_opt_ring) && (!(targ->flags & TASK_ARG_DROP))) { // Transmitting to a ring in NO DROP. We need to make sure the receiving task in not running on the same core. // Otherwise we might end up in a dead lock: trying in a loop to transmit to a task which cannot receive anymore - // (as npt being scheduled). + // (as not being scheduled). struct core_task ct; struct task_args *dtarg; for (unsigned int j = 0; j < targ->nb_txrings; j++) { @@ -263,6 +283,7 @@ static size_t init_rx_tx_rings_ports(struct task_args *targ, struct task_base *t prev = prev->tx_opt_ring_task; } } + if (targ->nb_txrings == 1 || targ->nb_txports == 1 || targ->tx_opt_ring) { if (targ->task_init->flag_features & TASK_FEATURE_NEVER_DISCARDS) { if (targ->tx_opt_ring) { @@ -336,10 +357,6 @@ struct task_base *init_task_struct(struct task_args *targ) offset = init_rx_tx_rings_ports(targ, tbase, offset); tbase->aux = (struct task_base_aux *)(((uint8_t *)tbase) + offset); - if (targ->task_init->flag_features & TASK_FEATURE_RX_ALL) { - task_base_add_rx_pkt_function(tbase, rx_pkt_all); - tbase->aux->all_mbufs = prox_zmalloc(MAX_RX_PKT_ALL * sizeof(* tbase->aux->all_mbufs), task_socket); - } if (targ->task_init->flag_features & TASK_FEATURE_TSC_RX) { task_base_add_rx_pkt_function(tbase, rx_pkt_tsc); } @@ -348,6 +365,23 @@ struct task_base *init_task_struct(struct task_args *targ) tbase->handle_bulk = t->handle; + if (targ->flags & (TASK_ARG_L3|TASK_ARG_NDP)) { + plog_info("\tTask (%d,%d) configured in L3/NDP mode\n", targ->lconf->id, targ->id); + tbase->l3.ctrl_plane_ring = targ->ctrl_plane_ring; + if (targ->nb_txports != 0) { + tbase->aux->tx_pkt_l2 = tbase->tx_pkt; + tbase->aux->tx_ctrlplane_pkt = targ->nb_txrings ? tx_ctrlplane_sw : tx_ctrlplane_hw; + if (targ->flags & TASK_ARG_L3) { + tbase->tx_pkt = tx_pkt_l3; + task_init_l3(tbase, targ); + } else if (targ->flags & TASK_ARG_NDP) { + tbase->tx_pkt = tx_pkt_ndp; + task_init_l3(tbase, targ); + } + // Make sure control plane packets such as arp are not dropped + } + } + targ->tbase = tbase; if (t->init) { t->init(tbase, targ); @@ -372,8 +406,12 @@ struct task_base *init_task_struct(struct task_args *targ) struct task_args *find_reachable_task_sending_to_port(struct task_args *from) { - if (!from->nb_txrings) - return from; + if (!from->nb_txrings) { + if (from->tx_port_queue[0].port != OUT_DISCARD) + return from; + else + return NULL; + } struct core_task ct; struct task_args *dtarg, *ret;