From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.ics.ntt-tx.co.jp (mail05.ics.ntt-tx.co.jp [210.232.35.69]) by dpdk.org (Postfix) with ESMTP id 4B418695D for ; Tue, 5 Feb 2019 12:48:53 +0100 (CET) Received: from gwchk03.silk.ntt-tx.co.jp (gwchk03.silk.ntt-tx.co.jp [10.107.0.111]) by mail04.ics.ntt-tx.co.jp (unknown) with ESMTP id x15BmqLR015477; Tue, 5 Feb 2019 20:48:53 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id x15BmqN5031034; Tue, 5 Feb 2019 20:48:52 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id WAA30820; Tue, 5 Feb 2019 20:47:43 +0900 Received: from imss03.silk.ntt-tx.co.jp (localhost [127.0.0.1]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id x15BlggX014231; Tue, 5 Feb 2019 20:47:42 +0900 Received: from mgate02.silk.ntt-tx.co.jp (smtp02.silk.ntt-tx.co.jp [10.107.0.37]) by imss03.silk.ntt-tx.co.jp (unknown) with ESMTP id x15BlgMc014227; Tue, 5 Feb 2019 20:47:42 +0900 Message-Id: <201902051147.x15BlgMc014227@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate02.silk.ntt-tx.co.jp (unknown) id x15BlgJY025667 ; Tue, 5 Feb 2019 20:47:42 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Cc: spp@dpdk.org Date: Tue, 5 Feb 2019 20:47:39 +0900 X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190205114742.24502-1-x-fn-spp@sl.ntt-tx.co.jp> References: <20190205114742.24502-1-x-fn-spp@sl.ntt-tx.co.jp> X-TM-AS-MML: No Subject: [spp] [PATCH 2/5] spp_vf: change to handle multiples component X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Feb 2019 11:48:54 -0000 From: Hideyuki Yamashita So far, slave_main assumes that only one component is assigned for one core. However there is a case when multiples component are assigned for one core in core-sharing usecase to reduce cpu core consumption. This patch changes to handle multiples component per core in slave_main function. Signed-off-by: Hideyuki Yamashita Signed-off-by: Naoki Takada --- src/vf/classifier_mac.c | 112 +++++++++++++++------------------------- 1 file changed, 42 insertions(+), 70 deletions(-) diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c index cfaf96a..27e2355 100644 --- a/src/vf/classifier_mac.c +++ b/src/vf/classifier_mac.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation + * Copyright(c) 2017-2019 Nippon Telegraph and Telephone Corporation */ #include @@ -774,7 +774,7 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx, /* change update index at classifier management information */ static inline void -change_update_index(struct management_info *mng_info, int id) +change_classifier_index(struct management_info *mng_info, int id) { if (unlikely(mng_info->ref_index == mng_info->upd_index)) { @@ -815,11 +815,6 @@ spp_classifier_mac_update(struct spp_component_info *component_info) RTE_LOG(INFO, SPP_CLASSIFIER_MAC, "Component[%u] Start update component.\n", id); - /* wait until no longer access the new update side */ - while (likely(mng_info->ref_index == - mng_info->upd_index)) - rte_delay_us_block(CHANGE_UPDATE_INDEX_WAIT_INTERVAL); - cmp_info = mng_info->cmp_infos + mng_info->upd_index; /* initialize update side classifier information */ @@ -833,6 +828,7 @@ spp_classifier_mac_update(struct spp_component_info *component_info) /* change index of reference side */ mng_info->upd_index = mng_info->ref_index; + mng_info->is_used = 1; /* wait until no longer access the new update side */ while (likely(mng_info->ref_index == @@ -852,10 +848,8 @@ spp_classifier_mac_update(struct spp_component_info *component_info) int spp_classifier_mac_do(int id) { - int ret = SPP_RET_NG; int i; int n_rx; - unsigned int lcore_id = rte_lcore_id(); struct management_info *mng_info = g_mng_infos + id; struct component_info *cmp_info = NULL; struct rte_mbuf *rx_pkts[MAX_PKT_BURST]; @@ -867,76 +861,54 @@ spp_classifier_mac_do(int id) const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) / US_PER_S * DRAIN_TX_PACKET_INTERVAL; - /* initialize */ - ret = init_classifier(mng_info); - if (unlikely(ret != SPP_RET_OK)) { - uninit_classifier(mng_info); - return ret; - } - - while (likely(spp_get_core_status(lcore_id) == SPP_CORE_FORWARD) && - likely(spp_check_core_update(lcore_id) == SPP_RET_NG)) { - /* change index of update side */ - change_update_index(mng_info, id); + /* change index of update classifier management information */ + change_classifier_index(mng_info, id); - /** - * decide classifier information of the current cycle - * If at least, one rx port, one tx port and one - * classifier_table exist, then start classifying. - * If not, stop classifying. - */ - cmp_info = mng_info->cmp_infos + mng_info->ref_index; - clsd_data_rx = &cmp_info->classified_data_rx; - clsd_data_tx = cmp_info->classified_data_tx; + /** + * decide classifier information of the current cycle If at least, + * one rx port, one tx port and one classifier_table exist, then start + * classifying. If not, stop classifying. + */ + cmp_info = mng_info->cmp_infos + mng_info->ref_index; + clsd_data_rx = &cmp_info->classified_data_rx; + clsd_data_tx = cmp_info->classified_data_tx; - /** - * Perform condition check if reception/transmission - * of packet should be done or not - */ - if (!(clsd_data_rx->iface_type != UNDEF && - cmp_info->n_classified_data_tx >= 1 && + /** + * Perform condition check if reception/transmission + * of packet should be done or not + */ + if (!(clsd_data_rx->iface_type != UNDEF && + cmp_info->n_classified_data_tx >= 1 && cmp_info->mac_addr_entry == 1)) - continue; + return SPP_RET_OK; - /* drain tx packets, if buffer is not filled for interval */ - cur_tsc = rte_rdtsc(); - if (unlikely(cur_tsc - prev_tsc > drain_tsc)) { - for (i = 0; i < cmp_info->n_classified_data_tx; - i++) { - if (likely(clsd_data_tx[i].num_pkt == 0)) - continue; - - RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC, - "transmit packets (drain). " - "index=%d, " - "num_pkt=%hu, " - "interval=%lu\n", - i, - clsd_data_tx[i].num_pkt, - cur_tsc - prev_tsc); + /* drain tx packets, if buffer is not filled for interval */ + cur_tsc = rte_rdtsc(); + if (unlikely(cur_tsc - prev_tsc > drain_tsc)) { + for (i = 0; i < cmp_info->n_classified_data_tx; i++) { + if (likely(clsd_data_tx[i].num_pkt == 0)) + continue; + + RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC, + "transmit packets (drain). index=%d, " + "num_pkt=%hu, interval=%lu\n", + i, clsd_data_tx[i].num_pkt, + cur_tsc - prev_tsc); transmit_packet(&clsd_data_tx[i]); - } - prev_tsc = cur_tsc; } - - if (clsd_data_rx->iface_type == UNDEF) - continue; - - /* retrieve packets */ - n_rx = spp_eth_rx_burst(clsd_data_rx->port, 0, - rx_pkts, MAX_PKT_BURST); - if (unlikely(n_rx == 0)) - continue; - - /* classify and transmit (filled) */ - classify_packet(rx_pkts, n_rx, cmp_info, clsd_data_tx); + prev_tsc = cur_tsc; } - /* just in case */ - change_update_index(mng_info, id); + if (clsd_data_rx->iface_type == UNDEF) + return SPP_RET_OK; + + /* retrieve packets */ + n_rx = spp_eth_rx_burst(clsd_data_rx->port, 0, rx_pkts, MAX_PKT_BURST); + if (unlikely(n_rx == 0)) + return SPP_RET_OK; - /* uninitialize */ - uninit_classifier(mng_info); + /* classify and interval that transmit burst packet */ + classify_packet(rx_pkts, n_rx, cmp_info, clsd_data_tx); return SPP_RET_OK; } -- 2.17.1