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 1ECAD29AC for ; Thu, 28 Dec 2017 05:56:08 +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 vBS4u6vS025106 for unknown; Thu, 28 Dec 2017 13:56:07 +0900 Received: (from root@localhost) by gwchk03.silk.ntt-tx.co.jp (unknown) id vBS4u5V0027203 for unknown; Thu, 28 Dec 2017 13:56:05 +0900 Received: from gwchk.silk.ntt-tx.co.jp [10.107.0.110] by gwchk03.silk.ntt-tx.co.jp with ESMTP id PAA27194; Thu, 28 Dec 2017 13:56:05 +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 vBS4u47X010926 for unknown; Thu, 28 Dec 2017 13:56:04 +0900 Received: from mgate01.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 vBS4u4De010922 for unknown; Thu, 28 Dec 2017 13:56:04 +0900 Message-Id: <201712280456.vBS4u4De010922@imss03.silk.ntt-tx.co.jp> Received: from localhost by mgate01.silk.ntt-tx.co.jp (unknown) id vBS4u4ad025622 ; Thu, 28 Dec 2017 13:56:04 +0900 From: x-fn-spp@sl.ntt-tx.co.jp To: spp@dpdk.org Date: Thu, 28 Dec 2017 13:55:12 +0900 X-Mailer: git-send-email 1.9.1 In-Reply-To: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> References: <4aae78ff-3b6c-cdfe-a8b7-24ec08b73935@lab.ntt.co.jp> X-TM-AS-MML: No Subject: [spp] [PATCH 05/57] spp_vf: add procedure that mac address is null 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: Thu, 28 Dec 2017 04:56:10 -0000 From: Hiroyuki Nakamura spp_vf supports command for modifying classifier table. * Add procedure that MAC address is null. * Refactor classifier table initialization. * Refactor classifier table switching. Signed-off-by: Daiki Yamashita Signed-off-by: Yasufum Ogawa --- src/vf/classifier_mac.c | 55 ++++++++++++++++++++++++++----------------------- src/vf/classifier_mac.h | 4 ++++ 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/vf/classifier_mac.c b/src/vf/classifier_mac.c index 6d8b222..6808062 100644 --- a/src/vf/classifier_mac.c +++ b/src/vf/classifier_mac.c @@ -104,6 +104,10 @@ init_classifier_table(struct rte_hash **classifier_table, rte_hash_reset(*classifier_table); for (i = 0; i < core_info->num_tx_port; i++) { + if (core_info->tx_ports[i].mac_addr == 0) { + continue; + } + rte_memcpy(ð_addr, &core_info->tx_ports[i].mac_addr, ETHER_ADDR_LEN); /* add entry to classifier mac table */ @@ -188,25 +192,15 @@ init_classifier(const struct spp_core_info *core_info, classifier_mac_table = &classifier_mng_info->info[classifier_mng_info->ref_index]. classifier_table; - for (i = 0; i < core_info->num_tx_port; i++) { - rte_memcpy(ð_addr, &core_info->tx_ports[i].mac_addr, ETHER_ADDR_LEN); - - /* TODO:when modify this code, consider to use init_classifier_table function */ - - /* add entry to classifier mac table */ - ret = rte_hash_add_key_data(*classifier_mac_table, - (void*)ð_addr, (void*)(long)i); - if (unlikely(ret < 0)) { - ether_format_addr(mac_addr_str, sizeof(mac_addr_str), ð_addr); - RTE_LOG(ERR, SPP_CLASSIFIER_MAC, - "Cannot add entry to classifier mac table. " - "ret=%d, mac_addr=%s\n", ret, mac_addr_str); - rte_hash_free(*classifier_mac_table); - *classifier_mac_table = NULL; - return -1; - } + ret = init_classifier_table(classifier_mac_table, core_info); + if (unlikely(ret != 0)) { + RTE_LOG(ERR, SPP_CLASSIFIER_MAC, + "Cannot initialize classifer mac table. ret=%d\n", ret); + return -1; + } - /* set value */ + /* store ports information */ + for (i = 0; i < core_info->num_tx_port; i++) { classified_data[i].if_type = core_info->tx_ports[i].if_type; classified_data[i].if_no = i; classified_data[i].tx_port = core_info->tx_ports[i].dpdk_port; @@ -301,6 +295,19 @@ classify_packet(struct rte_mbuf **rx_pkts, uint16_t n_rx, } } +static inline void +change_update_index(struct classifier_mac_mng_info *classifier_mng_info, unsigned int lcore_id) +{ + if (unlikely(classifier_mng_info->ref_index == + classifier_mng_info->upd_index)) { + RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC, + "Core[%u] Change update index.", lcore_id); + classifier_mng_info->upd_index = + (classifier_mng_info->upd_index + 1) % + NUM_CLASSIFIER_MAC_INFO; + } +} + /* classifier(mac address) update component info. */ int spp_classifier_mac_update(struct spp_core_info *core_info) @@ -375,14 +382,7 @@ spp_classifier_mac_do(void *arg) while(likely(core_info->status == SPP_CORE_FORWARD)) { /* change index of update side */ - if (unlikely(classifier_mng_info->ref_index == - classifier_mng_info->upd_index)) { - RTE_LOG(DEBUG, SPP_CLASSIFIER_MAC, - "Core[%u] Change update index.", lcore_id); - classifier_mng_info->upd_index = - (classifier_mng_info->upd_index + 1) % - NUM_CLASSIFIER_MAC_INFO; - } + change_update_index(classifier_mng_info, lcore_id); /* decide classifier infomation of the current cycle */ classifier_info = classifier_mng_info->info + @@ -424,6 +424,9 @@ spp_classifier_mac_do(void *arg) } } + /* just in case */ + change_update_index(classifier_mng_info, lcore_id); + /* uninitialize */ uninit_classifier(classifier_mng_info); diff --git a/src/vf/classifier_mac.h b/src/vf/classifier_mac.h index 6bbdb15..98f47a5 100644 --- a/src/vf/classifier_mac.h +++ b/src/vf/classifier_mac.h @@ -1,6 +1,7 @@ #ifndef _CLASSIFIER_MAC_H_ #define _CLASSIFIER_MAC_H_ +/* forward declaration */ struct spp_core_info; /** @@ -8,6 +9,9 @@ struct spp_core_info; * * @param core_info * point to struct spp_core_info. + * + * @ret_val 0 succeeded. + * @ret_val -1 failed. */ int spp_classifier_mac_update(struct spp_core_info *core_info); -- 1.9.1